MCPcopy Index your code
hub / github.com/go-task/task / TestGroupWithBeginEnd

Function TestGroupWithBeginEnd

internal/output/output_test.go:53–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestGroupWithBeginEnd(t *testing.T) {
54 t.Parallel()
55
56 tmpl := templater.Cache{
57 Vars: ast.NewVars(
58 &ast.VarElement{
59 Key: "VAR1",
60 Value: ast.Var{Value: "example-value"},
61 },
62 ),
63 }
64
65 var o output.Output = output.Group{
66 Begin: "::group::{{ .VAR1 }}",
67 End: "::endgroup::",
68 }
69 t.Run("simple", func(t *testing.T) {
70 t.Parallel()
71
72 var b bytes.Buffer
73 w, _, cleanup := o.WrapWriter(&b, io.Discard, "", &tmpl)
74
75 fmt.Fprintln(w, "foo\nbar")
76 assert.Equal(t, "", b.String())
77 fmt.Fprintln(w, "baz")
78 assert.Equal(t, "", b.String())
79 require.NoError(t, cleanup(nil))
80 assert.Equal(t, "::group::example-value\nfoo\nbar\nbaz\n::endgroup::\n", b.String())
81 })
82 t.Run("no output", func(t *testing.T) {
83 t.Parallel()
84
85 var b bytes.Buffer
86 _, _, cleanup := o.WrapWriter(&b, io.Discard, "", &tmpl)
87 require.NoError(t, cleanup(nil))
88 assert.Equal(t, "", b.String())
89 })
90}
91
92func TestGroupErrorOnlySwallowsOutputOnNoError(t *testing.T) {
93 t.Parallel()

Callers

nothing calls this directly

Calls 4

WrapWriterMethod · 0.95
NewVarsFunction · 0.92
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…