From ebc47f7d5dc41bf884f6e1cae87cebe72f5c9b45 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 11 Jun 2014 20:32:45 +0400 Subject: [PATCH] Add unit-test. #65 --- files/public_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/files/public_test.go b/files/public_test.go index c7ea0be4..7dabda53 100644 --- a/files/public_test.go +++ b/files/public_test.go @@ -168,4 +168,15 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) { info := st.Sys().(*syscall.Stat_t) c.Check(int(info.Nlink), Equals, 2) } + + // test linking files to duplicate final name + sourcePath := "pool/02/bc/mars-invaders_1.03.deb" + err := os.MkdirAll(filepath.Dir(sourcePath), 0755) + c.Assert(err, IsNil) + + err = ioutil.WriteFile(sourcePath, []byte("Contents"), 0644) + c.Assert(err, IsNil) + + err = s.storage.LinkFromPool(filepath.Join("", "pool", "main", "m/mars-invaders"), pool, sourcePath) + c.Check(err, ErrorMatches, ".*file already exists and is different") }