Correcting times I really messed that part up :O
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user