mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Test utils
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
@@ -10,3 +14,24 @@ import (
|
||||
func Test(t *testing.T) {
|
||||
TestingT(t)
|
||||
}
|
||||
|
||||
type UtilsSuite struct {
|
||||
tempfile *os.File
|
||||
}
|
||||
|
||||
var _ = Suite(&UtilsSuite{})
|
||||
|
||||
func (s *UtilsSuite) SetUpSuite(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(c.MkDir(), "aptly-test-inaccessible")
|
||||
if err := os.Chmod(s.tempfile.Name(), 0000); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *UtilsSuite) TestDirIsAccessibleNotExist(c *C) {
|
||||
c.Check(DirIsAccessible("does/not/exist.invalid"), Equals, nil)
|
||||
}
|
||||
|
||||
func (s *UtilsSuite) TestDirIsAccessibleNotAccessible(c *C) {
|
||||
c.Check(DirIsAccessible(s.tempfile.Name()).Error(), Equals, fmt.Errorf("'%s' is inaccessible, check access rights", s.tempfile.Name()).Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user