Skip to content

Commit 37232b7

Browse files
committed
fix: Simplify function for enabling experiments in tests
1 parent 353477b commit 37232b7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

task_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ func TestIncludesMultiLevel(t *testing.T) {
10501050
}
10511051

10521052
func TestIncludesRemote(t *testing.T) {
1053-
overrideExperimentValue(t, &experiments.RemoteTaskfiles, true, "1")
1053+
enableExperimentForTest(t, &experiments.RemoteTaskfiles, "1")
10541054

10551055
dir := "testdata/includes_remote"
10561056

@@ -2657,16 +2657,16 @@ func TestReference(t *testing.T) {
26572657
}
26582658
}
26592659

2660-
// overrideExperimentValue allows one to change the value of an experiment value for a set of tests,
2661-
// with the value being restored to its previous state when tests complete.
2660+
// enableExperimentForTest enables the experiment behind pointer e for the duration of test t and sub-tests,
2661+
// with the experiment being restored to its previous state when tests complete.
26622662
//
26632663
// Typically experiments are controlled via TASK_X_ env vars, but we cannot use those in tests
26642664
// because the experiment settings are parsed during experiments.init(), before any tests run.
2665-
func overrideExperimentValue(t *testing.T, e *experiments.Experiment, enabled bool, val string) {
2665+
func enableExperimentForTest(t *testing.T, e *experiments.Experiment, val string) {
26662666
prev := *e
26672667
*e = experiments.Experiment{
26682668
Name: prev.Name,
2669-
Enabled: enabled,
2669+
Enabled: true,
26702670
Value: val,
26712671
}
26722672
t.Cleanup(func() { *e = prev })

0 commit comments

Comments
 (0)