Skip to content

Commit

Permalink
fix: add testing for sets and some type fixes (#159)
Browse files Browse the repository at this point in the history
* fix: add testing for sets and some type fixes

* Fix the refreshTTL tests.

* "returns a miss after overriding the client timeout with a short duration" needed
  a sleep to be reliable.
* "returns a miss after the client default when refreshTTL is false" needed to
  create the Set before testing its refresh. The TTL will always be applied when
  creating a new Set.
* Switch those tests to a more compact and complete testing style.

* fix: seed set for collection ttl tests in BeforeEach

* fix: prefer less verbose Expect

---------

Co-authored-by: Michael G. Schwern <schwern@pobox.com>
  • Loading branch information
2 people authored and cprice404 committed Mar 14, 2023
1 parent 3df36fb commit a8d215f
Show file tree
Hide file tree
Showing 4 changed files with 458 additions and 6 deletions.
4 changes: 3 additions & 1 deletion momento/set_add_elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ type SetAddElementsRequest struct {

func (r *SetAddElementsRequest) cacheName() string { return r.CacheName }

func (r *SetAddElementsRequest) ttl() time.Duration { return r.CollectionTTL.Ttl }
func (r *SetAddElementsRequest) ttl() time.Duration {
return r.CollectionTTL.Ttl
}

func (r *SetAddElementsRequest) requestName() string { return "SetAddElements" }

Expand Down
4 changes: 2 additions & 2 deletions momento/set_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ func (r *SetFetchRequest) makeGrpcRequest(metadata context.Context, client scsDa
func (r *SetFetchRequest) interpretGrpcResponse() error {
switch rtype := r.grpcResponse.Set.(type) {
case *pb.XSetFetchResponse_Found:
r.response = SetFetchHit{
r.response = &SetFetchHit{
elements: rtype.Found.Elements,
}
case *pb.XSetFetchResponse_Missing:
r.response = SetFetchMiss{}
r.response = &SetFetchMiss{}
default:
return errUnexpectedGrpcResponse(r, r.grpcResponse)
}
Expand Down
Loading

0 comments on commit a8d215f

Please sign in to comment.