Validation is cheap so do it more

This commit is contained in:
2026-03-19 00:49:35 +00:00
parent de6c9d6ae5
commit 4e5b535f09
3 changed files with 47 additions and 24 deletions

View File

@@ -86,11 +86,13 @@ func TestSaveNote(t *testing.T) {
name: "new note",
note: models.Note{
Content: "Test note",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedNote: models.Note{
ID: 1,
Content: "Test note",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedError: false,
@@ -98,11 +100,13 @@ func TestSaveNote(t *testing.T) {
name: "new 2 note",
note: models.Note{
Content: "Test note 2!",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedNote: models.Note{
ID: 2,
Content: "Test note 2!",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedError: false,
@@ -112,11 +116,13 @@ func TestSaveNote(t *testing.T) {
note: models.Note{
ID: 1,
Content: "Updated note",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedNote: models.Note{
ID: 1,
Content: "Updated note",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedError: false,
@@ -126,6 +132,7 @@ func TestSaveNote(t *testing.T) {
note: models.Note{
ID: 999,
Content: "This note does not exist",
Title: "No Problem",
LastUpdate: time.Now(),
},
expectedNote: models.Note{},
@@ -168,6 +175,7 @@ func TestGetNoteByID(t *testing.T) {
}()
store.SaveNote(context.Background(), models.Note{
Content: "Test note",
Title: "Saved No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
})
@@ -183,6 +191,7 @@ func TestGetNoteByID(t *testing.T) {
expectedNote: models.Note{
ID: 1,
Content: "Test note",
Title: "Saved No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
},
expectedError: false,
@@ -259,10 +268,12 @@ func TestGetAllNotes(t *testing.T) {
store.SaveNote(context.Background(), models.Note{
Content: "Test note 1",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
})
store.SaveNote(context.Background(), models.Note{
Content: "Test note 2",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC),
})
@@ -277,11 +288,13 @@ func TestGetAllNotes(t *testing.T) {
{
ID: 1,
Content: "Test note 1",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
},
{
ID: 2,
Content: "Test note 2",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC),
},
},
@@ -324,14 +337,17 @@ func TestDeleteNoteByID(t *testing.T) {
store.SaveNote(context.Background(), models.Note{
Content: "Test note 1",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
})
store.SaveNote(context.Background(), models.Note{
Content: "Test note 2",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
})
store.SaveNote(context.Background(), models.Note{
Content: "Test note 3",
Title: "No Problem",
LastUpdate: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
})