65
66
func (s *runnerSuite) TestRunCallRunTestsCommand(c *check.C) {
66
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.fromBranch)
67
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.arch, s.fromBranch)
68
runCmd := runCmd(s.path, s.cmdTpl, s.ip, s.goPath, false)
69
runCmd := runCmd(s.path, s.cmdTpl, s.ip, s.arch, s.goPath, false)
69
70
c.Assert(s.fakeUtil.ExecCalls[runCmd], check.Equals, 1,
70
71
check.Commentf("The command %s was not called", runCmd))
73
74
func (s *runnerSuite) TestRunCallInstallGodepsCommand(c *check.C) {
74
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.fromBranch)
75
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.arch, s.fromBranch)
76
77
installGodepCmd := installGodepCmd(s.path, s.goPath)
77
78
c.Assert(s.fakeUtil.ExecCalls[installGodepCmd], check.Equals, 1,
81
82
func (s *runnerSuite) TestRunCallInstallDependenciesCommand(c *check.C) {
82
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.fromBranch)
83
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.arch, s.fromBranch)
84
85
installDepCmd := installDepCmd(s.path, s.goPath)
85
86
c.Assert(s.fakeUtil.ExecCalls[installDepCmd], check.Equals, 1,
89
90
func (s *runnerSuite) TestRunReturnError(c *check.C) {
90
91
s.fakeUtil.FailExec = true
92
err := s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.fromBranch)
93
err := s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.arch, s.fromBranch)
94
95
c.Assert(err, check.NotNil, check.Commentf("Expected error not returned by Runner.RunTests"))
97
98
func (s *runnerSuite) TestRunCallRunTestsFromBranchCommand(c *check.C) {
99
s.subject.RunTests(s.path, s.cmdTpl, s.ip, fromBranch)
101
runCmd := runCmd(s.path, s.cmdTpl, s.ip, s.goPath, fromBranch)
102
c.Assert(s.fakeUtil.ExecCalls[runCmd], check.Equals, 1,
103
check.Commentf("The command %s was not called", runCmd))
106
func runCmd(path, cmdTpl, ip, goPath string, fromBranch bool) string {
107
var snappyFromBranch string
100
s.subject.RunTests(s.path, s.cmdTpl, s.ip, s.arch, fromBranch)
102
runCmd := runCmd(s.path, s.cmdTpl, s.ip, s.arch, s.goPath, fromBranch)
103
c.Assert(s.fakeUtil.ExecCalls[runCmd], check.Equals, 1,
104
check.Commentf("The command %s was not called", runCmd))
107
func (s *runnerSuite) TestRunCallRunTestsWithArchCommand(c *check.C) {
109
s.subject.RunTests(s.path, s.cmdTpl, s.ip, arch, s.fromBranch)
111
runCmd := runCmd(s.path, s.cmdTpl, s.ip, arch, s.goPath, s.fromBranch)
112
c.Assert(s.fakeUtil.ExecCalls[runCmd], check.Equals, 1,
113
check.Commentf("The command %s was not called", runCmd))
116
func runCmd(path, cmdTpl, ip, arch, goPath string, fromBranch bool) string {
119
args = append(args, "-arch "+arch)
109
snappyFromBranch = "-snappy-from-branch"
122
args = append(args, "-snappy-from-branch")
112
cmd := fmt.Sprintf(cmdTpl, ip, snappyFromBranch)
125
cmd := fmt.Sprintf(cmdTpl, ip, strings.Join(args, " "))
113
126
params := utils.NewExecCommandParams(path, strings.Fields(cmd), true)
114
127
params.AppendEnv(fmt.Sprintf("GOPATH=%s", goPath))
115
128
return params.String()