Correcting times I really messed that part up :O

This commit is contained in:
Micheal Wilkinson
2026-03-17 21:38:56 +00:00
parent d32d8bd696
commit 0887901020
2 changed files with 14 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ package repository
import ( import (
"fmt" "fmt"
"time"
"git.hrafn.xyz/aether/notes/internal/models" "git.hrafn.xyz/aether/notes/internal/models"
) )
@@ -20,6 +21,7 @@ func (r *NoteRepository) CreateNote(content string) (models.Note, error) {
} }
note := models.Note{ note := models.Note{
Content: content, Content: content,
LastUpdate: time.Now(),
} }
return r.store.SaveNote(note) return r.store.SaveNote(note)
} }

View File

@@ -23,7 +23,7 @@ func TestCreateNote(t *testing.T) {
content: "This is a good note with valid content.", content: "This is a good note with valid content.",
expectedNote: models.Note{ expectedNote: models.Note{
ID: 1, 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.", Content: "This is a good note with valid content.",
}, },
expectedError: false, 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.", content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
expectedNote: models.Note{ expectedNote: models.Note{
ID: 2, 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.", Content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
}, },
expectedError: false, expectedError: false,
@@ -76,11 +76,11 @@ func TestCreateNote(t *testing.T) {
func TestGetNotes(t *testing.T) { func TestGetNotes(t *testing.T) {
notes := []models.Note{ notes := []models.Note{
{ID: 1, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, {ID: 1, LastUpdate: time.Date(2000, 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: 2, LastUpdate: time.Date(2000, 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: 3, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"},
// 4th note was clearly deleted, :sadface: // 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} store := &mockNoteStore{Notes: notes}
repo := repository.NewNoteRepository(store) repo := repository.NewNoteRepository(store)
@@ -156,14 +156,14 @@ func TestListNotes(t *testing.T) {
{ {
name: "Multiple notes", name: "Multiple notes",
notes: []models.Note{ notes: []models.Note{
{ID: 1, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, {ID: 1, LastUpdate: time.Date(2000, 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: 2, LastUpdate: time.Date(2000, 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: 3, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"},
}, },
expectedNotes: []models.Note{ expectedNotes: []models.Note{
{ID: 1, LastUpdate: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"}, {ID: 1, LastUpdate: time.Date(2000, 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: 2, LastUpdate: time.Date(2000, 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: 3, LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third note"},
}, },
expectedError: false, expectedError: false,
}, },