Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Add library function for copying directory #59

Merged
merged 7 commits into from
Jun 20, 2022

Conversation

MonicaisHer
Copy link
Contributor

@MonicaisHer MonicaisHer commented Jun 17, 2022

resolves #57

@MonicaisHer MonicaisHer force-pushed the EDGEX-453-add-copyDir-func branch from cb9d9f5 to 785c725 Compare June 17, 2022 14:18
@MonicaisHer MonicaisHer force-pushed the EDGEX-453-add-copyDir-func branch from 785c725 to 5c24ded Compare June 17, 2022 14:18
Copy link
Member

@farshidtz farshidtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new functions. There are some issues in tests which we should address later on.

Comment on lines +151 to +174
func TestCopyFile(t *testing.T) {
tmpdir := t.TempDir()
tmpfile, _ := os.CreateTemp(tmpdir, "tmpSrcFile")
srcPath := tmpfile.Name()

tmpdir = t.TempDir()
tmpfile, _ = os.CreateTemp(tmpdir, "tmpDstFile")
dstPath := tmpfile.Name()

require.NoError(t, CopyFile(srcPath, dstPath), "Error copying file.")
}

func TestCopyDir(t *testing.T) {
tmpdir := t.TempDir()
tmpSrcDir, _ := os.MkdirTemp(tmpdir, "tmpSrcDir")
os.CreateTemp(tmpSrcDir, "tmpSrcFile1")
os.CreateTemp(tmpSrcDir, "tmpSrcFile2")
os.CreateTemp(tmpSrcDir, "tmpSrcFile3")

tmpdir = t.TempDir()
tmpDstDir, _ := os.MkdirTemp(tmpdir, "tmpDstDir")

require.NoError(t, CopyDir(tmpSrcDir, tmpDstDir), "Error copying directory.")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests should have better coverage for permissions. Also, all errors during the mocking are ignored.

@farshidtz farshidtz merged commit 91ceddd into canonical:main Jun 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add function to copy a directory
2 participants