Skip to content

Commit

Permalink
fix: test that it works for functions too
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Dec 18, 2023
1 parent 2d278e3 commit 00292ad
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,6 @@ func TestClient_VariantFromEnabledFeatureWithNoVariants(t *testing.T) {
// 3. feature is enabled but no variants -> FeatureEnabled : true
// 4. test strategy variants too


func TestGetVariantWithFallbackVariant(t *testing.T) {
assert := assert.New(t)
defer gock.OffAll()
Expand Down Expand Up @@ -1215,20 +1214,13 @@ func TestGetVariantWithFallbackVariant(t *testing.T) {

assert.Equal(fallbackVariant, *variant)

variantFromResolver := client.GetVariant(feature, WithVariantFallback(&fallbackVariant), WithVariantResolver(func(featureName string) *api.Feature {
if featureName == features[0].Name {
return &features[0]
} else {
t.Fatalf("the feature name passed %s was not the expected one %s", featureName, features[0].Name)
return nil
}
}))

assert.False(variantFromResolver.Enabled)
fallbackFunc := func(feature string, ctx *context.Context) *api.Variant {
return &fallbackVariant
}

assert.False(variantFromResolver.FeatureEnabled)
variantWithFallbackFunc := client.GetVariant(feature, WithVariantFallbackFunc(fallbackFunc))

assert.Equal(fallbackVariant, *variantFromResolver)
assert.Equal(fallbackVariant, *variantWithFallbackFunc)

assert.True(gock.IsDone(), "there should be no more mocks")
}

0 comments on commit 00292ad

Please sign in to comment.