-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default our experimental features to true
Added logic so users can turn them off if it breaks their logic in some way. Fixes #1436 Fixes #1437 Signed-off-by: John Schnake <[email protected]>
- Loading branch information
1 parent
b51156c
commit df0e77d
Showing
3 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_FeatureEnabled(t *testing.T) { | ||
// Choose arbitrary feature to test against | ||
feature := "foo" | ||
tests := []struct { | ||
name string | ||
want bool | ||
allEnv string | ||
featureEnv string | ||
defaultVal bool | ||
}{ | ||
{ | ||
name: "All false", | ||
want: false, | ||
allEnv: "false", featureEnv: "false", defaultVal: false, | ||
}, { | ||
name: "Explicit false overrides all else", | ||
want: false, | ||
allEnv: "true", featureEnv: "false", defaultVal: true, | ||
}, { | ||
name: "Explicit true overrides all else", | ||
want: true, | ||
allEnv: "false", featureEnv: "true", defaultVal: false, | ||
}, { | ||
name: "FeaturesAll true overrides default", | ||
want: true, | ||
allEnv: "true", featureEnv: "", defaultVal: false, | ||
}, { | ||
name: "Can default to true even if all env is false", | ||
want: true, | ||
allEnv: "false", featureEnv: "", defaultVal: true, | ||
}, { | ||
name: "Default value used if others empty", | ||
want: true, | ||
allEnv: "", featureEnv: "", defaultVal: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := featureEnabledCore(feature, tt.allEnv, tt.featureEnv, map[string]bool{feature: tt.defaultVal}); got != tt.want { | ||
t.Errorf("featureEnabled() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters