mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-30 04:20:53 +00:00
New layout for pool files, public subdir & operations.
This commit is contained in:
Vendored
+27
-18
@@ -2,6 +2,7 @@ package debian
|
||||
|
||||
import (
|
||||
. "launchpad.net/gocheck"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
@@ -16,24 +17,32 @@ func (s *RepositorySuite) SetUpTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *RepositorySuite) TestPoolPath(c *C) {
|
||||
path, err := s.repo.PoolPath("a/b/package.deb")
|
||||
path, err := s.repo.PoolPath("a/b/package.deb", "91b1a1480b90b9e269ca44d897b12575")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(path, Equals, filepath.Join(s.repo.RootPath, "pool", "a/b/package.deb"))
|
||||
c.Assert(path, Equals, filepath.Join(s.repo.RootPath, "pool", "91/b1/package.deb"))
|
||||
|
||||
path, err = s.repo.PoolPath("pool/a/b/package.deb")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(path, Equals, filepath.Join(s.repo.RootPath, "pool", "a/b/package.deb"))
|
||||
|
||||
_, err = s.repo.PoolPath("/dev/stdin")
|
||||
c.Assert(err, ErrorMatches, "absolute filename.*")
|
||||
|
||||
_, err = s.repo.PoolPath("../../../etc/passwd")
|
||||
c.Assert(err, ErrorMatches, ".*starts with dot")
|
||||
|
||||
_, err = s.repo.PoolPath("pool/a/../../../etc/passwd")
|
||||
c.Assert(err, ErrorMatches, ".*starts with dot")
|
||||
|
||||
path, err = s.repo.PoolPath("./etc/passwd")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(path, Equals, filepath.Join(s.repo.RootPath, "pool", "etc/passwd"))
|
||||
_, err = s.repo.PoolPath("/", "91b1a1480b90b9e269ca44d897b12575")
|
||||
c.Assert(err, ErrorMatches, ".*is invalid")
|
||||
_, err = s.repo.PoolPath("", "91b1a1480b90b9e269ca44d897b12575")
|
||||
c.Assert(err, ErrorMatches, ".*is invalid")
|
||||
}
|
||||
|
||||
func (s *RepositorySuite) TestMkDir(c *C) {
|
||||
err := s.repo.MkDir("ppa/dists/squeeze/")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
_, err = os.Stat(filepath.Join(s.repo.RootPath, "public/ppa/dists/squeeze/"))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *RepositorySuite) TestCreateFile(c *C) {
|
||||
err := s.repo.MkDir("ppa/dists/squeeze/")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
file, err := s.repo.CreateFile("ppa/dists/squeeze/Release")
|
||||
c.Assert(err, IsNil)
|
||||
defer file.Close()
|
||||
|
||||
_, err = os.Stat(filepath.Join(s.repo.RootPath, "public/ppa/dists/squeeze/Release"))
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user