summaryrefslogtreecommitdiff
path: root/app/db/in_memory_repository_test.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-07 10:47:31 -0700
committermo khan <mo@mokhan.ca>2025-05-07 10:47:31 -0700
commitc82468b1b32ad5bfb347fe65cd5dcfb6680795d1 (patch)
tree679b4728fdae2ed296730a49f5100ddcf3c25f98 /app/db/in_memory_repository_test.go
parentf0fbdab72254d68d0a3a4a49a4a1646f89f0f913 (diff)
refactor: provide context to repository to apply timeout
Diffstat (limited to 'app/db/in_memory_repository_test.go')
-rw-r--r--app/db/in_memory_repository_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/app/db/in_memory_repository_test.go b/app/db/in_memory_repository_test.go
index bd9d12f..cf516aa 100644
--- a/app/db/in_memory_repository_test.go
+++ b/app/db/in_memory_repository_test.go
@@ -13,17 +13,17 @@ func TestInMemoryRepository(t *testing.T) {
t.Run("Save", func(t *testing.T) {
t.Run("an invalid Sparkle", func(t *testing.T) {
- err := storage.Save(&domain.Sparkle{Reason: "because"})
+ err := storage.Save(t.Context(), &domain.Sparkle{Reason: "because"})
assert.Error(t, err)
- assert.Equal(t, 0, len(storage.All()))
+ assert.Equal(t, 0, len(storage.All(t.Context())))
})
t.Run("a valid Sparkle", func(t *testing.T) {
sparkle := &domain.Sparkle{Sparklee: "@tanuki", Reason: "because"}
- require.NoError(t, storage.Save(sparkle))
+ require.NoError(t, storage.Save(t.Context(), sparkle))
- sparkles := storage.All()
+ sparkles := storage.All(t.Context())
assert.Equal(t, 1, len(sparkles))
assert.NotEmpty(t, sparkles[0].ID)
assert.Equal(t, "@tanuki", sparkles[0].Sparklee)
@@ -35,15 +35,15 @@ func TestInMemoryRepository(t *testing.T) {
t.Run("when the entity exists", func(t *testing.T) {
sparkle, err := domain.NewSparkle("@tanuki for testing this func")
require.NoError(t, err)
- require.NoError(t, storage.Save(sparkle))
+ require.NoError(t, storage.Save(t.Context(), sparkle))
- result := storage.Find(sparkle.ID)
+ result := storage.Find(t.Context(), sparkle.ID)
require.NotNil(t, result)
require.Equal(t, sparkle, result)
})
t.Run("when the entity does not exist", func(t *testing.T) {
- result := storage.Find("unknown")
+ result := storage.Find(t.Context(), "unknown")
require.Nil(t, result)
})
})