Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
pkg/fileutils: add unit test for IsRegularFile
Browse files Browse the repository at this point in the history
Signed-off-by: Zhou Hao <[email protected]>
  • Loading branch information
Zhou Hao committed Feb 14, 2020
1 parent 1481da3 commit e33b08f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/fileutils/fileutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,17 @@ func (s *FileUtilTestSuite) TestLoadYaml(c *check.C) {

}
}

func (s *FileUtilTestSuite) TestIsRegularFile(c *check.C) {
pathStr := filepath.Join(s.tmpDir, "TestIsRegularFile")
c.Assert(IsRegularFile(pathStr), check.Equals, false)

os.Create(pathStr)
c.Assert(IsRegularFile(pathStr), check.Equals, true)
os.Remove(pathStr)

// Don't set mode to create a non-regular file
os.OpenFile(pathStr, 0, 0666)
c.Assert(IsRegularFile(pathStr), check.Equals, false)
os.Remove(pathStr)
}

0 comments on commit e33b08f

Please sign in to comment.