Skip to content

Commit 0a0f0bd

Browse files
committed
tests: add test for WithMockStdout
1 parent ceefc0f commit 0a0f0bd

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

executor/local/opts_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,39 @@ func TestLocal_Opt_WithVersion(t *testing.T) {
331331
})
332332
}
333333
}
334+
335+
func TestLocal_Opt_WithMockStdout(t *testing.T) {
336+
// setup tests
337+
tests := []struct {
338+
name string
339+
mock bool
340+
wantNil bool
341+
}{
342+
{
343+
name: "standard",
344+
mock: false,
345+
wantNil: true,
346+
},
347+
{
348+
name: "mocked",
349+
mock: true,
350+
wantNil: false,
351+
},
352+
}
353+
354+
// run tests
355+
for _, test := range tests {
356+
t.Run(test.name, func(t *testing.T) {
357+
_engine, err := New(
358+
WithMockStdout(test.mock),
359+
)
360+
if err != nil {
361+
t.Errorf("unable to create local engine: %v", err)
362+
}
363+
364+
if !reflect.DeepEqual(_engine.MockStdout() == nil, test.wantNil) {
365+
t.Errorf("WithMockStdout is %v, wantNil = %v", _engine.MockStdout() == nil, test.wantNil)
366+
}
367+
})
368+
}
369+
}

0 commit comments

Comments
 (0)