Added NoteStore interface, mock and repository with Create method
This commit is contained in:
@@ -4,8 +4,8 @@ import (
|
||||
"testing"
|
||||
"testing/synctest"
|
||||
|
||||
"time"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.hrafn.xyz/aether/notes/internal/models"
|
||||
"git.hrafn.xyz/aether/notes/internal/repository"
|
||||
@@ -71,4 +71,4 @@ func TestCreateNote(t *testing.T) {
|
||||
fmt.Printf("Test case '%s' passed.\n", tc.name)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"git.hrafn.xyz/aether/notes/internal/models"
|
||||
)
|
||||
|
||||
type NoteStore interface {
|
||||
SaveNote(models.Note) (models.Note, error)
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
)
|
||||
|
||||
type mockNoteStore struct {
|
||||
notes []models.Note
|
||||
Notes []models.Note
|
||||
}
|
||||
|
||||
func (m *mockNoteStore) SaveNote(note models.Note) (models.Note, error) {
|
||||
note.ID = len(m.notes) + 1
|
||||
m.notes = append(m.notes, note)
|
||||
note.ID = len(m.Notes) + 1
|
||||
m.Notes = append(m.Notes, note)
|
||||
return note, nil
|
||||
}
|
||||
Reference in New Issue
Block a user