Skip to content
Snippets Groups Projects
Commit 7f2466d3 authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

#1 Add unit tests for TTL optional parameter

parent 0b519ce1
No related branches found
No related tags found
No related merge requests found
......@@ -165,6 +165,22 @@ func TestService_Set(t *testing.T) {
},
errtext: "",
},
{
name: "successfully set value in cache with TTL provided in request",
req: &goacache.CacheSetRequest{
Key: "key",
Namespace: ptr.String("namespace"),
Scope: ptr.String("scope"),
Data: map[string]interface{}{"test": "value"},
TTL: ptr.Int(60),
},
cache: &cachefakes.FakeCache{
SetStub: func(ctx context.Context, key string, value []byte, ttl time.Duration) error {
return nil
},
},
errtext: "",
},
}
for _, test := range tests {
......@@ -248,6 +264,25 @@ func TestService_SetExternal(t *testing.T) {
}},
errtext: "",
},
{
name: "successfully set value in cache with TTL provided in request and send an event to events",
req: &goacache.CacheSetRequest{
Key: "key",
Namespace: ptr.String("namespace"),
Scope: ptr.String("scope"),
Data: map[string]interface{}{"test": "value"},
TTL: ptr.Int(60),
},
cache: &cachefakes.FakeCache{
SetStub: func(ctx context.Context, key string, value []byte, ttl time.Duration) error {
return nil
},
},
events: &cachefakes.FakeEvents{SendStub: func(ctx context.Context, s string) error {
return nil
}},
errtext: "",
},
}
for _, test := range tests {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment