Contextualise all the things ....
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"testing/synctest"
|
||||
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -49,7 +50,7 @@ func TestCreateNote(t *testing.T) {
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
note, err := repo.CreateNote(tc.content)
|
||||
note, err := repo.CreateNote(context.Background(), tc.content)
|
||||
if tc.expectedError {
|
||||
if err == nil {
|
||||
t.Errorf("expected an error but got none")
|
||||
@@ -118,7 +119,7 @@ func TestGetNotes(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
note, err := repo.GetNote(tc.id)
|
||||
note, err := repo.GetNote(context.Background(), tc.id)
|
||||
if tc.expectedError {
|
||||
if err == nil {
|
||||
t.Errorf("expected an error but got none")
|
||||
@@ -172,7 +173,7 @@ func TestListNotes(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
store := &mockNoteStore{Notes: tc.notes}
|
||||
repo := repository.NewNoteRepository(store)
|
||||
notes, err := repo.ListNotes()
|
||||
notes, err := repo.ListNotes(context.Background())
|
||||
if tc.expectedError {
|
||||
if err == nil {
|
||||
t.Errorf("expected an error but got none")
|
||||
@@ -241,7 +242,7 @@ func TestUpdateNote(t *testing.T) {
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
note, err := repo.UpdateNote(tc.id, tc.content)
|
||||
note, err := repo.UpdateNote(context.Background(), tc.id, tc.content)
|
||||
if tc.expectedError {
|
||||
if err == nil {
|
||||
t.Errorf("expected an error but got none")
|
||||
@@ -304,7 +305,7 @@ func TestDeleteNote(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
store := &mockNoteStore{Notes: tc.setupNotes}
|
||||
repo := repository.NewNoteRepository(store)
|
||||
err := repo.DeleteNote(tc.id)
|
||||
err := repo.DeleteNote(context.Background(), tc.id)
|
||||
if tc.expectedError {
|
||||
if err == nil {
|
||||
t.Errorf("expected an error but got none")
|
||||
@@ -314,7 +315,7 @@ func TestDeleteNote(t *testing.T) {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
notes, _ := repo.ListNotes()
|
||||
notes, _ := repo.ListNotes(context.Background())
|
||||
if len(notes) != len(tc.expectedNotes) {
|
||||
t.Errorf("expected %d notes but got %d", len(tc.expectedNotes), len(notes))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user