OLD | NEW |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package sshstorage | 4 package sshstorage |
5 | 5 |
6 import ( | 6 import ( |
7 "bytes" | 7 "bytes" |
8 "fmt" | 8 "fmt" |
9 "io" | 9 "io" |
10 "io/ioutil" | 10 "io/ioutil" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 for _, name := range []string{"b", filepath.Join("a", "b")} { | 157 for _, name := range []string{"b", filepath.Join("a", "b")} { |
158 err = ioutil.WriteFile(filepath.Join(storageDir, name), data, 06
44) | 158 err = ioutil.WriteFile(filepath.Join(storageDir, name), data, 06
44) |
159 c.Assert(err, gc.IsNil) | 159 c.Assert(err, gc.IsNil) |
160 r, err := storage.Get(stor, name) | 160 r, err := storage.Get(stor, name) |
161 c.Assert(err, gc.IsNil) | 161 c.Assert(err, gc.IsNil) |
162 out, err := ioutil.ReadAll(r) | 162 out, err := ioutil.ReadAll(r) |
163 c.Assert(err, gc.IsNil) | 163 c.Assert(err, gc.IsNil) |
164 c.Assert(out, gc.DeepEquals, data) | 164 c.Assert(out, gc.DeepEquals, data) |
165 } | 165 } |
166 _, err = storage.Get(stor, "notthere") | 166 _, err = storage.Get(stor, "notthere") |
167 » c.Assert(err, jc.Satisfies, coreerrors.IsNotFoundError) | 167 » c.Assert(err, jc.Satisfies, coreerrors.IsNotFound) |
168 } | 168 } |
169 | 169 |
170 func (s *storageSuite) TestWriteFailure(c *gc.C) { | 170 func (s *storageSuite) TestWriteFailure(c *gc.C) { |
171 // Invocations: | 171 // Invocations: |
172 // 1: first "install" | 172 // 1: first "install" |
173 // 2: touch, Put | 173 // 2: touch, Put |
174 // 3: second "install" | 174 // 3: second "install" |
175 // 4: touch | 175 // 4: touch |
176 var invocations int | 176 var invocations int |
177 badSshCommand := func(host string, command ...string) *ssh.Cmd { | 177 badSshCommand := func(host string, command ...string) *ssh.Cmd { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 func (s *storageSuite) TestPathCharacters(c *gc.C) { | 392 func (s *storageSuite) TestPathCharacters(c *gc.C) { |
393 storageDirBase := c.MkDir() | 393 storageDirBase := c.MkDir() |
394 storageDir := filepath.Join(storageDirBase, "'") | 394 storageDir := filepath.Join(storageDirBase, "'") |
395 tmpdir := filepath.Join(storageDirBase, `"`) | 395 tmpdir := filepath.Join(storageDirBase, `"`) |
396 c.Assert(os.Mkdir(storageDir, 0755), gc.IsNil) | 396 c.Assert(os.Mkdir(storageDir, 0755), gc.IsNil) |
397 c.Assert(os.Mkdir(tmpdir, 0755), gc.IsNil) | 397 c.Assert(os.Mkdir(tmpdir, 0755), gc.IsNil) |
398 _, err := newSSHStorage("example.com", storageDir, tmpdir) | 398 _, err := newSSHStorage("example.com", storageDir, tmpdir) |
399 c.Assert(err, gc.IsNil) | 399 c.Assert(err, gc.IsNil) |
400 } | 400 } |
OLD | NEW |