NewExecutorTest sets up a new [task.Executor] with the given options and runs a task with the given [ExecutorTestOption]s. The output of the task is written to a set of fixture files depending on the configuration of the test.
(t *testing.T, opts ...ExecutorTestOption)
| 44 | // a task with the given [ExecutorTestOption]s. The output of the task is |
| 45 | // written to a set of fixture files depending on the configuration of the test. |
| 46 | func NewExecutorTest(t *testing.T, opts ...ExecutorTestOption) { |
| 47 | t.Helper() |
| 48 | tt := &ExecutorTest{ |
| 49 | task: "default", |
| 50 | vars: map[string]any{}, |
| 51 | TaskTest: TaskTest{ |
| 52 | experiments: map[*experiments.Experiment]int{}, |
| 53 | fixtureTemplateData: map[string]any{}, |
| 54 | }, |
| 55 | } |
| 56 | // Apply the functional options |
| 57 | for _, opt := range opts { |
| 58 | opt.applyToExecutorTest(tt) |
| 59 | } |
| 60 | // Enable any experiments that have been set |
| 61 | for x, v := range tt.experiments { |
| 62 | prev := *x |
| 63 | *x = experiments.Experiment{ |
| 64 | Name: prev.Name, |
| 65 | AllowedValues: []int{v}, |
| 66 | Value: v, |
| 67 | } |
| 68 | t.Cleanup(func() { |
| 69 | *x = prev |
| 70 | }) |
| 71 | } |
| 72 | tt.run(t) |
| 73 | } |
| 74 | |
| 75 | // Functional options |
| 76 |
no test coverage detected
searching dependent graphs…