Quality of life improvements for feature sets
While feature sets solve a real problem, they're currently quite unwieldy. All callsites which use the featureset helper have the same pattern of creating a feature set, looping around all feature sets, creating a new testcase, setting up the context and then finally disabling the given set of features in that context. This is extremely repetitive and easy to get wrong. As a result, they're more of a burden to use. Furthermore, they do have a serious bug which causes us to not generate all combinations of feature flags, but only a small subset of those.
This MR fixes both issues. First, we now generate all combinations of feature flags. Second, it introduces a new Run()
function which handles all of the setup for us. E.g. the typical use previous to that refactoring
featureSets, err := testhelper.NewFeatureSets([]featureflag.FeatureFlag{
featureflag.GoListConflictFiles,
})
require.NoError(t, err)
for _, featureSet := range featureSets {
t.Run("disabled "+featureSet.String(), func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
ctx = featureSet.Disable(ctx)
testcase(t, ctx)
})
}
... now looks like this:
testhelper.NewFeatureSets([]featureflag.FeatureFlag{
featureflag.GoListConflictFiles,
}).Run(t, func(t *testing.T, ctx context.Context) {
testcase(t, ctx)
})
I've also added some testcases to finally verify they're doing the correct thing.