Fix pure-go unittests

So they can run on e.g. LXC containers as root, or other conceivable setups.
This commit is contained in:
Lorenzo Bolla
2021-11-02 17:30:48 +01:00
parent 370e3cdfea
commit 6826efc723
4 changed files with 41 additions and 4 deletions

View File

@@ -119,7 +119,15 @@ func (s *DownloaderSuite) TestDownloadConnectError(c *C) {
ErrorMatches, ".*no such host")
}
func skipIfRoot(c *C) {
user := os.Getenv("USER")
if user == "root" {
c.Skip("Root user")
}
}
func (s *DownloaderSuite) TestDownloadFileError(c *C) {
skipIfRoot(c)
c.Assert(s.d.Download(s.ctx, s.url+"/test", "/"),
ErrorMatches, ".*permission denied")
}