MCPcopy
hub / github.com/go-task/task / enableExperimentForTest

Function enableExperimentForTest

task_test.go:3041–3050  ·  view source on GitHub ↗

enableExperimentForTest enables the experiment behind pointer e for the duration of test t and sub-tests, with the experiment being restored to its previous state when tests complete. Typically experiments are controlled via TASK_X_ env vars, but we cannot use those in tests because the experiment

(t *testing.T, e *experiments.Experiment, val int)

Source from the content-addressed store, hash-verified

3039// Typically experiments are controlled via TASK_X_ env vars, but we cannot use those in tests
3040// because the experiment settings are parsed during experiments.init(), before any tests run.
3041func enableExperimentForTest(t *testing.T, e *experiments.Experiment, val int) {
3042 t.Helper()
3043 prev := *e
3044 *e = experiments.Experiment{
3045 Name: prev.Name,
3046 AllowedValues: []int{val},
3047 Value: val,
3048 }
3049 t.Cleanup(func() { *e = prev })
3050}

Callers 3

TestVarInheritanceFunction · 0.85
TestIncludesRemoteFunction · 0.85
TestIncludesHttpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…