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

Function NewFormatterTest

formatter_test.go:41–68  ·  view source on GitHub ↗

NewFormatterTest sets up a new [task.Executor] with the given options and runs a task with the given [FormatterTestOption]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 ...FormatterTestOption)

Source from the content-addressed store, hash-verified

39// runs a task with the given [FormatterTestOption]s. The output of the task is
40// written to a set of fixture files depending on the configuration of the test.
41func NewFormatterTest(t *testing.T, opts ...FormatterTestOption) {
42 t.Helper()
43 tt := &FormatterTest{
44 task: "default",
45 vars: map[string]any{},
46 TaskTest: TaskTest{
47 experiments: map[*experiments.Experiment]int{},
48 fixtureTemplateData: map[string]any{},
49 },
50 }
51 // Apply the functional options
52 for _, opt := range opts {
53 opt.applyToFormatterTest(tt)
54 }
55 // Enable any experiments that have been set
56 for x, v := range tt.experiments {
57 prev := *x
58 *x = experiments.Experiment{
59 Name: prev.Name,
60 AllowedValues: []int{v},
61 Value: v,
62 }
63 t.Cleanup(func() {
64 *x = prev
65 })
66 }
67 tt.run(t)
68}
69
70// Functional options
71

Callers 5

TestNoLabelInListFunction · 0.85
TestListAllShowsNoDescFunction · 0.85
TestListCanListDescOnlyFunction · 0.85
TestJsonListFormatFunction · 0.85

Calls 2

runMethod · 0.95
applyToFormatterTestMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…