Extend swift storage with link and file exists methods

This commit is contained in:
Oliver Sauder
2017-11-02 10:24:05 +01:00
parent 7498fd8fc8
commit 438e206b3d
2 changed files with 57 additions and 10 deletions
+34
View File
@@ -194,3 +194,37 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
c.Check(err, IsNil)
c.Check(data, DeepEquals, []byte("Spam"))
}
func (s *PublishedStorageSuite) TestSymLink(c *C) {
dir := c.MkDir()
err := ioutil.WriteFile(filepath.Join(dir, "a"), []byte("welcome to swift!"), 0644)
c.Assert(err, IsNil)
err = s.storage.PutFile("a/b.txt", filepath.Join(dir, "a"))
c.Check(err, IsNil)
err = s.storage.SymLink("a/b.txt", "a/b.txt.link")
c.Check(err, IsNil)
var link string
link, err = s.storage.ReadLink("a/b.txt.link")
c.Check(err, IsNil)
c.Check(link, Equals, "a/b")
c.Skip("copy not availbale in s3test")
}
func (s *PublishedStorageSuite) TestFileExists(c *C) {
dir := c.MkDir()
err := ioutil.WriteFile(filepath.Join(dir, "a"), []byte("welcome to swift!"), 0644)
c.Assert(err, IsNil)
err = s.storage.PutFile("a/b.txt", filepath.Join(dir, "a"))
c.Check(err, IsNil)
exists := s.storage.FileExists("a/b.txt")
c.Check(exists, Equals, true)
exists = s.storage.FileExists("a/b.invalid")
c.Check(exists, Equals, false)
}