forked from docker-flow/docker-flow-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_test.go
More file actions
65 lines (50 loc) · 1.04 KB
/
run_test.go
File metadata and controls
65 lines (50 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// +build !integration
package main
import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
"testing"
)
type RunTestSuite struct {
suite.Suite
}
func (s *RunTestSuite) SetupTest() {
logPrintf = func(format string, v ...interface{}) {}
}
// Execute
func (s RunTestSuite) Test_Execute_ExecutesCommand() {
actual := HaProxyTestSuite{}.mockHaExecCmd()
expected := []string{
"haproxy",
"-f",
"/cfg/haproxy.cfg",
"-D",
"-p",
"/var/run/haproxy.pid",
}
NewRun().Execute([]string{})
s.Equal(expected, *actual)
}
// NewRun
func (s RunTestSuite) Test_NewRun_ReturnsNewStruct() {
s.NotNil(NewRun())
}
// Suite
func TestRunUnitTestSuite(t *testing.T) {
suite.Run(t, new(RunTestSuite))
}
// Mock
type RunMock struct {
mock.Mock
}
func (m *RunMock) Execute(args []string) error {
params := m.Called(args)
return params.Error(0)
}
func getRunMock(skipMethod string) *ReconfigureMock {
mockObj := new(ReconfigureMock)
if skipMethod != "Execute" {
mockObj.On("Execute", mock.Anything).Return(nil)
}
return mockObj
}