refactoring createdat to last update ... it will make sense

This commit is contained in:
Micheal Wilkinson
2026-03-17 21:31:06 +00:00
parent 95f4eb38f4
commit 26b16cc411
2 changed files with 21 additions and 21 deletions

View File

@@ -22,9 +22,9 @@ func TestCreateNote(t *testing.T) {
name: "Good note",
content: "This is a good note with valid content.",
expectedNote: models.Note{
ID: 1,
CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), //CreatedAt is set by synctest to this specific time
Content: "This is a good note with valid content.",
ID: 1,
LastUpdate: time.Date(0001, 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,
},
@@ -38,9 +38,9 @@ func TestCreateNote(t *testing.T) {
name: "Long content",
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,
CreatedAt: time.Date(0001, 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.",
ID: 2,
LastUpdate: time.Date(0001, 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,
},
@@ -65,8 +65,8 @@ func TestCreateNote(t *testing.T) {
if note.ID != tc.expectedNote.ID {
t.Errorf("expected ID %d but got %d", tc.expectedNote.ID, note.ID)
}
if !note.CreatedAt.Equal(tc.expectedNote.CreatedAt) {
t.Errorf("expected CreatedAt %v but got %v", tc.expectedNote.CreatedAt, note.CreatedAt)
if !note.LastUpdate.Equal(tc.expectedNote.LastUpdate) {
t.Errorf("expected LastUpdate %v but got %v", tc.expectedNote.LastUpdate, note.LastUpdate)
}
fmt.Printf("Test case '%s' passed.\n", tc.name)
})
@@ -75,11 +75,11 @@ func TestCreateNote(t *testing.T) {
func TestGetNotes(t *testing.T) {
notes := []models.Note{
{ID: 1, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"},
{ID: 2, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"},
{ID: 3, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third 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"},
// 4th note was clearly deleted, :sadface:
{ID: 5, CreatedAt: 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(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."},
}
store := &mockNoteStore{Notes: notes}
repo := repository.NewNoteRepository(store)
@@ -155,14 +155,14 @@ func TestListNotes(t *testing.T) {
{
name: "Multiple notes",
notes: []models.Note{
{ID: 1, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"},
{ID: 2, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"},
{ID: 3, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third 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"},
},
expectedNotes: []models.Note{
{ID: 1, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "First note"},
{ID: 2, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Second note"},
{ID: 3, CreatedAt: time.Date(0001, 1, 1, 0, 0, 0, 0, time.UTC), Content: "Third 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"},
},
expectedError: false,
},