MCPcopy
hub / github.com/passteque/gluetun / Test_start

Function Test_start

internal/command/start_test.go:20–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func Test_start(t *testing.T) {
21 t.Parallel()
22
23 errDummy := errors.New("dummy")
24
25 testCases := map[string]struct {
26 stdout []string
27 stdoutPipeErr error
28 stderr []string
29 stderrPipeErr error
30 startErr error
31 waitErr error
32 err error
33 }{
34 "no output": {},
35 "success": {
36 stdout: []string{"hello", "world"},
37 stderr: []string{"some", "error"},
38 },
39 "stdout pipe error": {
40 stdoutPipeErr: errDummy,
41 err: errDummy,
42 },
43 "stderr pipe error": {
44 stderrPipeErr: errDummy,
45 err: errDummy,
46 },
47 "start error": {
48 startErr: errDummy,
49 err: errDummy,
50 },
51 "wait error": {
52 waitErr: errDummy,
53 },
54 }
55
56 for name, testCase := range testCases {
57 t.Run(name, func(t *testing.T) {
58 t.Parallel()
59
60 ctrl := gomock.NewController(t)
61
62 stdout := linesToReadCloser(testCase.stdout)
63 stderr := linesToReadCloser(testCase.stderr)
64
65 mockCmd := NewMockexecCmd(ctrl)
66
67 mockCmd.EXPECT().StdoutPipe().
68 Return(stdout, testCase.stdoutPipeErr)
69 if testCase.stdoutPipeErr == nil {
70 mockCmd.EXPECT().StderrPipe().Return(stderr, testCase.stderrPipeErr)
71 if testCase.stderrPipeErr == nil {
72 mockCmd.EXPECT().Start().Return(testCase.startErr)
73 if testCase.startErr == nil {
74 mockCmd.EXPECT().Wait().Return(testCase.waitErr)
75 }
76 }
77 }

Callers

nothing calls this directly

Calls 11

EXPECTMethod · 0.95
linesToReadCloserFunction · 0.85
NewMockexecCmdFunction · 0.85
startFunction · 0.70
RunMethod · 0.65
StdoutPipeMethod · 0.65
StderrPipeMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
ErrorMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected