Added NoteStore interface, mock and repository with Create method

This commit is contained in:
Micheal Wilkinson
2026-03-17 21:13:11 +00:00
parent c05603d624
commit 2f035ee485
6 changed files with 42 additions and 41 deletions

View File

@@ -4,8 +4,8 @@ import (
"testing" "testing"
"testing/synctest" "testing/synctest"
"time"
"fmt" "fmt"
"time"
"git.hrafn.xyz/aether/notes/internal/models" "git.hrafn.xyz/aether/notes/internal/models"
"git.hrafn.xyz/aether/notes/internal/repository" "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) fmt.Printf("Test case '%s' passed.\n", tc.name)
}) })
} }
} }

View File

@@ -3,6 +3,7 @@ package repository
import ( import (
"git.hrafn.xyz/aether/notes/internal/models" "git.hrafn.xyz/aether/notes/internal/models"
) )
type NoteStore interface { type NoteStore interface {
SaveNote(models.Note) (models.Note, error) SaveNote(models.Note) (models.Note, error)
} }

View File

@@ -5,11 +5,11 @@ import (
) )
type mockNoteStore struct { type mockNoteStore struct {
notes []models.Note Notes []models.Note
} }
func (m *mockNoteStore) SaveNote(note models.Note) (models.Note, error) { func (m *mockNoteStore) SaveNote(note models.Note) (models.Note, error) {
note.ID = len(m.notes) + 1 note.ID = len(m.Notes) + 1
m.notes = append(m.notes, note) m.Notes = append(m.Notes, note)
return note, nil return note, nil
} }