151
151
c.Assert(err, jc.Satisfies, coreerrors.IsNotFoundError)
154
func (s *storageSuite) TestWriteFailure(c *gc.C) {
156
// 1: first "install"
158
// 3: second "install"
161
badSshCommand := func(host string, tty bool, command string) *exec.Cmd {
165
return exec.Command("bash", "-c", "echo alles gut")
167
// Note: must close stdin before responding the first time, or
168
// the second command will race with closing stdin, and may
170
return exec.Command("bash", "-c", "head -n 1 > /dev/null; exec 0<&-; echo JUJU-RC: 0; echo blah blah")
172
return exec.Command("bash", "-c", `head -n 1 > /dev/null; echo "Hey it's JUJU-RC: , but not at the beginning of the line"`)
174
c.Errorf("unexpected invocation: #%d, %s", invocations, command)
178
s.PatchValue(&sshCommand, badSshCommand)
180
stor, err := NewSSHStorage("example.com", c.MkDir(), c.MkDir())
181
c.Assert(err, gc.IsNil)
183
err = stor.Put("whatever", bytes.NewBuffer(nil), 0)
184
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to flush input: write |1: broken pipe (output: "blah blah")`))
186
_, err = NewSSHStorage("example.com", c.MkDir(), c.MkDir())
187
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to locate "JUJU-RC: " (output: "Hey it's JUJU-RC: , but not at the beginning of the line")`))
154
190
func (s *storageSuite) TestPut(c *gc.C) {
155
191
stor, storageDir := s.makeStorage(c)
156
192
data := []byte("abc\000def")