Skip to content

Commit

Permalink
default type should be a map
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidlazio committed Jun 3, 2024
1 parent d56de80 commit 541605d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/confidence/confidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ func (e Confidence) GetStringValue(ctx context.Context, flag string, defaultValu
return e.GetStringFlag(ctx, flag, defaultValue).Value
}

func (e Confidence) GetObjectFlag(ctx context.Context, flag string, defaultValue string) InterfaceResolutionDetail {
func (e Confidence) GetObjectFlag(ctx context.Context, flag string, defaultValue map[string]interface{}) InterfaceResolutionDetail {
resp := e.ResolveFlag(ctx, flag, defaultValue, reflect.Map)
return resp
}

func (e Confidence) GetObjectValue(ctx context.Context, flag string, defaultValue string) interface{} {
func (e Confidence) GetObjectValue(ctx context.Context, flag string, defaultValue map[string]interface{}) interface{} {
return e.GetObjectFlag(ctx, flag, defaultValue).Value
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/confidence/confidence_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestResolveObjectValue(t *testing.T) {
client := client(t, templateResponse(), nil)
client.PutContext("targeting_key", "user1")

evalDetails := client.GetObjectFlag(context.Background(), "test-flag.struct-key", "default")
evalDetails := client.GetObjectFlag(context.Background(), "test-flag.struct-key", map[string]interface{}{})
_, ok := evalDetails.Value.(map[string]interface{})
assert.True(t, ok)
}
Expand All @@ -88,7 +88,7 @@ func TestResolveWholeFlagAsObject(t *testing.T) {
client := client(t, templateResponse(), nil)
client.PutContext("targeting_key", "user1")

evalDetails := client.GetObjectFlag(context.Background(), "test-flag", "default")
evalDetails := client.GetObjectFlag(context.Background(), "test-flag", map[string]interface{}{})
_, ok := evalDetails.Value.(map[string]interface{})
assert.True(t, ok)
}
Expand All @@ -97,7 +97,7 @@ func TestResolveWholeFlagAsObjectWithInts(t *testing.T) {
client := client(t, templateResponse(), nil)
client.PutContext("targeting_key", "user1")

evalDetails := client.GetObjectFlag(context.Background(), "test-flag", "default")
evalDetails := client.GetObjectFlag(context.Background(), "test-flag", map[string]interface{}{})

value, _ := evalDetails.Value.(map[string]interface{})
rootIntValue := value["integer-key"]
Expand Down

0 comments on commit 541605d

Please sign in to comment.