From 08879010208f4a1f6fa1965e36b30a9ea7db97ed Mon Sep 17 00:00:00 2001 From: Micheal Wilkinson Date: Tue, 17 Mar 2026 21:38:56 +0000 Subject: [PATCH] Correcting times I really messed that part up :O --- internal/repository/notes.go | 2 ++ internal/repository/notes_test.go | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/repository/notes.go b/internal/repository/notes.go index 80a9ca5..285f40a 100644 --- a/internal/repository/notes.go +++ b/internal/repository/notes.go @@ -2,6 +2,7 @@ package repository import ( "fmt" + "time" "git.hrafn.xyz/aether/notes/internal/models" ) @@ -20,6 +21,7 @@ func (r *NoteRepository) CreateNote(content string) (models.Note, error) { } note := models.Note{ Content: content, + LastUpdate: time.Now(), } return r.store.SaveNote(note) } diff --git a/internal/repository/notes_test.go b/internal/repository/notes_test.go index ce7b61c..46caa5b 100644 --- a/internal/repository/notes_test.go +++ b/internal/repository/notes_test.go @@ -23,7 +23,7 @@ func TestCreateNote(t *testing.T) { content: "This is a good note with valid content.", expectedNote: models.Note{ ID: 1, - LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), //LastUpdate is set by synctest to this specific time + LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), //LastUpdate is set by synctest to this specific time Content: "This is a good note with valid content.", }, expectedError: false, @@ -39,7 +39,7 @@ func TestCreateNote(t *testing.T) { content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", expectedNote: models.Note{ ID: 2, - LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), + LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", }, expectedError: false, @@ -76,11 +76,11 @@ func TestCreateNote(t *testing.T) { func TestGetNotes(t *testing.T) { notes := []models.Note{ - {ID: 1, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, - {ID: 2, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"}, - {ID: 3, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"}, + {ID: 1, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, + {ID: 2, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"}, + {ID: 3, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"}, // 4th note was clearly deleted, :sadface: - {ID: 5, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Lorem ipsum note dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}, + {ID: 5, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Lorem ipsum note dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}, } store := &mockNoteStore{Notes: notes} repo := repository.NewNoteRepository(store) @@ -156,14 +156,14 @@ func TestListNotes(t *testing.T) { { name: "Multiple notes", notes: []models.Note{ - {ID: 1, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, - {ID: 2, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"}, - {ID: 3, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"}, + {ID: 1, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, + {ID: 2, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"}, + {ID: 3, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"}, }, expectedNotes: []models.Note{ - {ID: 1, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, - {ID: 2, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"}, - {ID: 3, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"}, + {ID: 1, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, + {ID: 2, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"}, + {ID: 3, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"}, }, expectedError: false, },