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 SymbolicLink
Browse files Browse the repository at this point in the history
Signed-off-by: Lu Fengqi <[email protected]>
  • Loading branch information
Lu Fengqi committed Feb 14, 2020
1 parent a8ddaaa commit 17d7815
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/fileutils/fileutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,35 @@ func (s *FileUtilTestSuite) TestLink(c *check.C) {
c.Assert(err, check.NotNil)
}

func (s *FileUtilTestSuite) TestSymbolicLink(c *check.C) {
dirStr := filepath.Join(s.tmpDir, "TestSymLinkDir")
os.Mkdir(dirStr, 0755)
dirLinkStr := filepath.Join(s.tmpDir, "TestSymDirLinkName")

err := SymbolicLink(dirStr, dirLinkStr)
c.Assert(err, check.IsNil)
c.Assert(PathExist(dirLinkStr), check.Equals, true)

pathStr := filepath.Join(s.tmpDir, "TestSymLinkFile")
os.Create(pathStr)
linkStr := filepath.Join(s.tmpDir, "TestSymFileLinkName")

err = SymbolicLink(pathStr, linkStr)
c.Assert(err, check.IsNil)
c.Assert(PathExist(linkStr), check.Equals, true)

linkStr = filepath.Join(s.tmpDir, "TestSymLinkNameExist")
os.Create(linkStr)
err = Link(pathStr, linkStr)
c.Assert(err, check.IsNil)
c.Assert(PathExist(linkStr), check.Equals, true)

linkStr = filepath.Join(s.tmpDir, "testSymLinkNonExistDir")
os.Mkdir(linkStr, 0755)
err = Link(pathStr, linkStr)
c.Assert(err, check.NotNil)
}

func (s *FileUtilTestSuite) TestCopyFile(c *check.C) {
srcPath := filepath.Join(s.tmpDir, "TestCopyFileSrc")
dstPath := filepath.Join(s.tmpDir, "TestCopyFileDst")
Expand Down

0 comments on commit 17d7815

Please sign in to comment.