30
31
c.Assert(err, gc.IsNil)
33
result, message := IsNonEmptyFile.Check([]interface{}{file.Name()}, nil)
34
c.Assert(result, IsFalse)
34
result, message := jc.IsNonEmptyFile.Check([]interface{}{file.Name()}, nil)
35
c.Assert(result, jc.IsFalse)
35
36
c.Assert(message, gc.Equals, file.Name()+" is empty")
38
39
func (s *FileSuite) TestIsNonEmptyFileWithMissingFile(c *gc.C) {
39
40
name := filepath.Join(c.MkDir(), "missing")
41
result, message := IsNonEmptyFile.Check([]interface{}{name}, nil)
42
c.Assert(result, IsFalse)
42
result, message := jc.IsNonEmptyFile.Check([]interface{}{name}, nil)
43
c.Assert(result, jc.IsFalse)
43
44
c.Assert(message, gc.Equals, name+" does not exist")
46
47
func (s *FileSuite) TestIsNonEmptyFileWithNumber(c *gc.C) {
47
result, message := IsNonEmptyFile.Check([]interface{}{42}, nil)
48
c.Assert(result, IsFalse)
48
result, message := jc.IsNonEmptyFile.Check([]interface{}{42}, nil)
49
c.Assert(result, jc.IsFalse)
49
50
c.Assert(message, gc.Equals, "obtained value is not a string and has no .String(), int:42")
52
53
func (s *FileSuite) TestIsDirectory(c *gc.C) {
54
c.Assert(dir, IsDirectory)
55
c.Assert(dir, jc.IsDirectory)
57
58
func (s *FileSuite) TestIsDirectoryMissing(c *gc.C) {
58
59
absentDir := filepath.Join(c.MkDir(), "foo")
60
result, message := IsDirectory.Check([]interface{}{absentDir}, nil)
61
c.Assert(result, IsFalse)
61
result, message := jc.IsDirectory.Check([]interface{}{absentDir}, nil)
62
c.Assert(result, jc.IsFalse)
62
63
c.Assert(message, gc.Equals, absentDir+" does not exist")
67
68
c.Assert(err, gc.IsNil)
70
result, message := IsDirectory.Check([]interface{}{file.Name()}, nil)
71
c.Assert(result, IsFalse)
71
result, message := jc.IsDirectory.Check([]interface{}{file.Name()}, nil)
72
c.Assert(result, jc.IsFalse)
72
73
c.Assert(message, gc.Equals, file.Name()+" is not a directory")
75
76
func (s *FileSuite) TestIsDirectoryWithNumber(c *gc.C) {
76
result, message := IsDirectory.Check([]interface{}{42}, nil)
77
c.Assert(result, IsFalse)
77
result, message := jc.IsDirectory.Check([]interface{}{42}, nil)
78
c.Assert(result, jc.IsFalse)
78
79
c.Assert(message, gc.Equals, "obtained value is not a string and has no .String(), int:42")
81
82
func (s *FileSuite) TestDoesNotExist(c *gc.C) {
82
83
absentDir := filepath.Join(c.MkDir(), "foo")
83
c.Assert(absentDir, DoesNotExist)
84
c.Assert(absentDir, jc.DoesNotExist)
86
87
func (s *FileSuite) TestDoesNotExistWithPath(c *gc.C) {
88
result, message := DoesNotExist.Check([]interface{}{dir}, nil)
89
c.Assert(result, IsFalse)
89
result, message := jc.DoesNotExist.Check([]interface{}{dir}, nil)
90
c.Assert(result, jc.IsFalse)
90
91
c.Assert(message, gc.Equals, dir+" exists")
93
94
func (s *FileSuite) TestDoesNotExistWithNumber(c *gc.C) {
94
result, message := DoesNotExist.Check([]interface{}{42}, nil)
95
c.Assert(result, IsFalse)
95
result, message := jc.DoesNotExist.Check([]interface{}{42}, nil)
96
c.Assert(result, jc.IsFalse)
96
97
c.Assert(message, gc.Equals, "obtained value is not a string and has no .String(), int:42")