~axwalk/juju-core/api-uniter-machine

« back to all changes in this revision

Viewing changes to cmd/jujud/run_test.go

[r=dave-cheney] testing: make RunCommand variadic

This change alters the testing.RunCommand helper to be variadic. In terms of LOC this is probably a net nil, but being variadic this removes the requirement to wrap arguments to this method in a []string{ ... }

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
func (s *RunTestSuite) TestMissingAgent(c *gc.C) {
87
87
        s.PatchValue(&AgentDir, c.MkDir())
88
88
 
89
 
        _, err := testing.RunCommand(c, &RunCommand{}, []string{"foo", "bar"})
 
89
        _, err := testing.RunCommand(c, &RunCommand{}, "foo", "bar")
90
90
        c.Assert(err, gc.ErrorMatches, `unit "foo" not found on this machine`)
91
91
}
92
92
 
102
102
func startRunAsync(c *gc.C, params []string) <-chan *cmd.Context {
103
103
        resultChannel := make(chan *cmd.Context)
104
104
        go func() {
105
 
                ctx, err := testing.RunCommand(c, &RunCommand{}, params)
 
105
                ctx, err := testing.RunCommand(c, &RunCommand{}, params...)
106
106
                c.Assert(err, jc.Satisfies, cmd.IsRcPassthroughError)
107
107
                c.Assert(err, gc.ErrorMatches, "subprocess encountered error code 0")
108
108
                resultChannel <- ctx
115
115
        s.PatchValue(&LockDir, c.MkDir())
116
116
        s.PatchValue(&AgentDir, c.MkDir())
117
117
 
118
 
        ctx, err := testing.RunCommand(c, &RunCommand{}, []string{"--no-context", "echo done"})
 
118
        ctx, err := testing.RunCommand(c, &RunCommand{}, "--no-context", "echo done")
119
119
        c.Assert(err, jc.Satisfies, cmd.IsRcPassthroughError)
120
120
        c.Assert(err, gc.ErrorMatches, "subprocess encountered error code 0")
121
121
        c.Assert(testing.Stdout(ctx), gc.Equals, "done\n")
157
157
        err := os.Mkdir(testAgentDir, 0755)
158
158
        c.Assert(err, gc.IsNil)
159
159
 
160
 
        _, err = testing.RunCommand(c, &RunCommand{}, []string{"foo", "bar"})
 
160
        _, err = testing.RunCommand(c, &RunCommand{}, "foo", "bar")
161
161
        c.Assert(err, gc.ErrorMatches, `dial unix .*/run.socket: no such file or directory`)
162
162
}
163
163
 
165
165
        loggo.GetLogger("worker.uniter").SetLogLevel(loggo.TRACE)
166
166
        s.runListenerForAgent(c, "foo")
167
167
 
168
 
        ctx, err := testing.RunCommand(c, &RunCommand{}, []string{"foo", "bar"})
 
168
        ctx, err := testing.RunCommand(c, &RunCommand{}, "foo", "bar")
169
169
        c.Check(cmd.IsRcPassthroughError(err), jc.IsTrue)
170
170
        c.Assert(err, gc.ErrorMatches, "subprocess encountered error code 42")
171
171
        c.Assert(testing.Stdout(ctx), gc.Equals, "bar stdout")