Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: default cache client testing #299

Merged
merged 5 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions batchutils/batch_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,15 @@ var _ = Describe("Batch operations", func() {
}
}
})

It("doesn't error trying to batch delete nonexistent keys", func() {
keys := []Key{String("i"), String("don't"), String("exist")}
errors := batchutils.BatchDelete(ctx, &batchutils.BatchDeleteRequest{
Client: client,
CacheName: cacheName,
Keys: keys,
})
Expect(errors).To(BeNil())
})

})
43 changes: 36 additions & 7 deletions momento/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var _ = Describe("Control ops", func() {
DeferCleanup(func() { sharedContext.Close() })
})

Describe(`Happy Path`, func() {
It(`creates, lists, and deletes caches`, func() {
Describe("Happy Path", func() {
It("creates, lists, and deletes caches", func() {
cacheNames := []string{uuid.NewString(), uuid.NewString()}
defer func() {
for _, cacheName := range cacheNames {
Expand Down Expand Up @@ -80,11 +80,40 @@ var _ = Describe("Control ops", func() {
sharedContext.ClientWithDefaultCacheName.DeleteCache(sharedContext.Ctx, &DeleteCacheRequest{}),
).To(BeAssignableToTypeOf(&DeleteCacheSuccess{}))
})

})

Describe("cache client with default cache name", func() {
It("overrides default cache name", func() {
Expect(
sharedContext.ClientWithDefaultCacheName.CreateCache(
sharedContext.Ctx, &CreateCacheRequest{CacheName: sharedContext.CacheName},
),
).To(BeAssignableToTypeOf(&CreateCacheSuccess{}))
Expect(
sharedContext.ClientWithDefaultCacheName.Get(
sharedContext.Ctx, &GetRequest{Key: String("hi")},
),
).Error().To(HaveMomentoErrorCode(NotFoundError))
Expect(
sharedContext.ClientWithDefaultCacheName.Get(
sharedContext.Ctx, &GetRequest{
CacheName: sharedContext.CacheName,
Key: String("hi"),
},
),
).To(BeAssignableToTypeOf(&GetMiss{}))
Expect(
sharedContext.ClientWithDefaultCacheName.DeleteCache(
sharedContext.Ctx, &DeleteCacheRequest{CacheName: sharedContext.CacheName},
),
).To(BeAssignableToTypeOf(&DeleteCacheSuccess{}))
})
})

Describe(`Validate cache name`, func() {
It(`CreateCache and DeleteCache errors on bad cache names`, func() {
badCacheNames := []string{``, ` `}
Describe("Validate cache name", func() {
It("CreateCache and DeleteCache errors on bad cache names", func() {
badCacheNames := []string{"", " "}
for _, badCacheName := range badCacheNames {
createResp, err := sharedContext.Client.CreateCache(sharedContext.Ctx, &CreateCacheRequest{CacheName: badCacheName})
Expect(createResp).To(BeNil())
Expand All @@ -102,8 +131,8 @@ var _ = Describe("Control ops", func() {
})
})

Describe(`DeleteCache`, func() {
It(`succeeds even if the cache does not exist`, func() {
Describe("DeleteCache", func() {
It("succeeds even if the cache does not exist", func() {
Expect(
sharedContext.Client.DeleteCache(sharedContext.Ctx, &DeleteCacheRequest{CacheName: uuid.NewString()}),
).To(BeAssignableToTypeOf(&DeleteCacheSuccess{}))
Expand Down
Loading