Remember to wrap the synctest in a run for the name of the thing
This commit is contained in:
@@ -47,28 +47,29 @@ func TestCreateNote(t *testing.T) {
|
|||||||
}
|
}
|
||||||
repo := repository.NewNoteRepository(&mockNoteStore{})
|
repo := repository.NewNoteRepository(&mockNoteStore{})
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
synctest.Test(t, func(t *testing.T) {
|
synctest.Test(t, func(t *testing.T) {
|
||||||
note, err := repo.CreateNote(tc.content)
|
note, err := repo.CreateNote(tc.content)
|
||||||
if tc.expectedError {
|
if tc.expectedError {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("expected an error but got none")
|
t.Errorf("expected an error but got none")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if note.Content != tc.expectedNote.Content {
|
||||||
if note.Content != tc.expectedNote.Content {
|
t.Errorf("expected content %q but got %q", tc.expectedNote.Content, note.Content)
|
||||||
t.Errorf("expected content %q but got %q", tc.expectedNote.Content, note.Content)
|
}
|
||||||
}
|
if note.ID != tc.expectedNote.ID {
|
||||||
if note.ID != tc.expectedNote.ID {
|
t.Errorf("expected ID %d but got %d", tc.expectedNote.ID, note.ID)
|
||||||
t.Errorf("expected ID %d but got %d", tc.expectedNote.ID, note.ID)
|
}
|
||||||
}
|
if !note.LastUpdate.Equal(tc.expectedNote.LastUpdate) {
|
||||||
if !note.LastUpdate.Equal(tc.expectedNote.LastUpdate) {
|
t.Errorf("expected LastUpdate %v but got %v", tc.expectedNote.LastUpdate, note.LastUpdate)
|
||||||
t.Errorf("expected LastUpdate %v but got %v", tc.expectedNote.LastUpdate, note.LastUpdate)
|
}
|
||||||
}
|
fmt.Printf("Test case '%s' passed.\n", tc.name)
|
||||||
fmt.Printf("Test case '%s' passed.\n", tc.name)
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user