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: verify pointer responses #231

Merged
merged 2 commits into from
Mar 6, 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
5 changes: 1 addition & 4 deletions momento/dictionary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,7 @@ var _ = Describe("Dictionary methods", func() {
case *DictionaryGetFieldsHit:
Expect(result.ValueMap()).To(BeEmpty())
for _, value := range result.Responses() {
switch value.(type) {
case *DictionaryGetFieldHit:
Fail("got a hit response for a field that should return a miss")
}
Expect(value).To(BeAssignableToTypeOf(&DictionaryGetFieldMiss{}))
}
}
})
Expand Down
14 changes: 13 additions & 1 deletion momento/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package momento_test

import (
"fmt"
"sort"

"github.com/google/uuid"
. "github.com/momentohq/client-sdk-go/momento"
Expand Down Expand Up @@ -148,12 +149,23 @@ var _ = Describe("List methods", func() {

It("pushes strings and bytes on the happy path", func() {
numItems := 10
expected := populateList(sharedContext, numItems)
values, expected := getValueAndExpectedValueLists(numItems)
sort.Sort(sort.Reverse(sort.StringSlice(expected)))
for _, value := range values {
Expect(
sharedContext.Client.ListPushFront(sharedContext.Ctx, &ListPushFrontRequest{
CacheName: sharedContext.CacheName,
ListName: sharedContext.CollectionName,
Value: value,
}),
).To(BeAssignableToTypeOf(&ListPushFrontSuccess{}))
}
fetchResp, err := sharedContext.Client.ListFetch(sharedContext.Ctx, &ListFetchRequest{
CacheName: sharedContext.CacheName,
ListName: sharedContext.CollectionName,
})
Expect(err).To(BeNil())
Expect(fetchResp).To(BeAssignableToTypeOf(&ListFetchHit{}))
Expect(fetchResp).To(HaveListLength(numItems))
switch result := fetchResp.(type) {
case *ListFetchHit:
Expand Down
9 changes: 9 additions & 0 deletions momento/scalar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ var _ = Describe("Scalar methods", func() {
).Error().To(HaveMomentoErrorCode(InvalidArgumentError))
})

It("returns a miss when the key doesn't exist", func() {
Expect(
sharedContext.Client.Get(sharedContext.Ctx, &GetRequest{
CacheName: sharedContext.CacheName,
Key: String(uuid.NewString()),
}),
).To(BeAssignableToTypeOf(&GetMiss{}))
})

DescribeTable(`invalid cache names and keys`,
func(cacheName string, key Key, value Key) {
getResp, err := sharedContext.Client.Get(sharedContext.Ctx, &GetRequest{
Expand Down
9 changes: 9 additions & 0 deletions momento/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ var _ = Describe("Set methods", func() {
).Error().To(HaveMomentoErrorCode(InvalidArgumentError))
})

It("gets a miss trying to fetch a nonexistent set", func() {
Expect(
sharedContext.Client.SetFetch(sharedContext.Ctx, &SetFetchRequest{
CacheName: sharedContext.CacheName,
SetName: uuid.NewString(),
}),
).To(BeAssignableToTypeOf(&SetFetchMiss{}))
})

Describe("add", func() {
DescribeTable("add string and byte single elements happy path",
func(element Value, expectedStrings []string, expectedBytes [][]byte) {
Expand Down
1 change: 1 addition & 0 deletions momento/topic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (c defaultTopicClient) Publish(ctx context.Context, request *TopicPublishRe

return &responses.TopicPublishSuccess{}, err
}

func (c defaultTopicClient) Close() {
defer c.pubSubClient.Close()
}
1 change: 1 addition & 0 deletions momento/topic_value.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package momento

// TopicValue
// For now, topics take the same types as normal methods.
// In the future this might not be so, topics might take
// different types than methods.
Expand Down