Skip to content

Commit

Permalink
fix: update if statement to determine cache already exists in test; c…
Browse files Browse the repository at this point in the history
…hore: remove unused structs from external responses
  • Loading branch information
poppoerika committed Jan 30, 2022
1 parent f3d4739 commit 5e6a882
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
37 changes: 0 additions & 37 deletions momento/cache_operation_responses.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
package momento

import (
"github.com/momentohq/client-sdk-go/internal/models"
pb "github.com/momentohq/client-sdk-go/internal/protos"
)

type ListCachesResponse struct {
nextToken string
caches []CacheInfo
}

func NewListCacheResponse(resp *pb.ListCachesResponse) *ListCachesResponse {
var caches = []CacheInfo{}
for _, cache := range resp.Cache {
caches = append(caches, NewCacheInfo(cache))
}
return &ListCachesResponse{nextToken: resp.NextToken, caches: caches}
}

func (resp *ListCachesResponse) NextToken() string {
return resp.nextToken
}
Expand All @@ -34,10 +21,6 @@ func (ci CacheInfo) Name() string {
return ci.name
}

func NewCacheInfo(cache *pb.Cache) CacheInfo {
return CacheInfo{name: cache.CacheName}
}

const (
HIT string = "HIT"
MISS string = "MISS"
Expand All @@ -48,22 +31,6 @@ type GetCacheResponse struct {
result string
}

func NewGetCacheResponse(resp *pb.GetResponse) (*GetCacheResponse, error) {
var result string
if resp.Result == pb.ECacheResult_Hit {
result = HIT
} else if resp.Result == pb.ECacheResult_Miss {
result = MISS
} else {
return nil, models.ConvertEcacheResult(models.ConvertEcacheResultRequest{
ECacheResult: resp.Result,
Message: resp.Message,
OpName: "GET",
})
}
return &GetCacheResponse{value: resp.CacheBody, result: result}, nil
}

func (resp *GetCacheResponse) StringValue() string {
if resp.result == HIT {
return string(resp.value)
Expand All @@ -86,10 +53,6 @@ type SetCacheResponse struct {
value []byte
}

func NewSetCacheResponse(resp *pb.SetResponse, value []byte) *SetCacheResponse {
return &SetCacheResponse{value: value}
}

func (resp *SetCacheResponse) StringValue() string {
return string(resp.value)
}
Expand Down
2 changes: 1 addition & 1 deletion momento/simple_cache_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func setUp() (*ScsClient, error) {
err := client.CreateCache(&CreateCacheRequest{
CacheName: TestCacheName,
})
if !strings.Contains(err.Error(), scserrors.AlreadyExists) {
if err != nil && !strings.Contains(err.Error(), scserrors.AlreadyExists) {
return nil, err
}
return client, nil
Expand Down

0 comments on commit 5e6a882

Please sign in to comment.