diff --git a/internal/service/cache/service_test.go b/internal/service/cache/service_test.go index ae2f3d697d662a5dce719d4c02f5da6275e12668..e4ecf103458501c3a7eb9312298ba62e8701b487 100644 --- a/internal/service/cache/service_test.go +++ b/internal/service/cache/service_test.go @@ -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 {