|
|
|
@ -7,6 +7,7 @@ import (
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/ioutils"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -30,7 +31,7 @@ func contains(t *testing.T, list []string, path string) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_copyFile_returnsError_whenSourceDoesNotExist(t *testing.T) {
|
|
|
|
|
tmpdir, _ := os.MkdirTemp("", "backup")
|
|
|
|
|
tmpdir, _ := ioutils.TempDir("", "backup")
|
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
|
|
|
|
|
|
err := copyFile("does-not-exist", tmpdir)
|
|
|
|
@ -38,7 +39,7 @@ func Test_copyFile_returnsError_whenSourceDoesNotExist(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_copyFile_shouldMakeAbackup(t *testing.T) {
|
|
|
|
|
tmpdir, _ := os.MkdirTemp("", "backup")
|
|
|
|
|
tmpdir, _ := ioutils.TempDir("", "backup")
|
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
|
|
|
|
|
|
content := []byte("content")
|
|
|
|
@ -52,7 +53,7 @@ func Test_copyFile_shouldMakeAbackup(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_copyDir_shouldCopyAllFilesAndDirectories(t *testing.T) {
|
|
|
|
|
destination, _ := os.MkdirTemp("", "destination")
|
|
|
|
|
destination, _ := ioutils.TempDir("", "destination")
|
|
|
|
|
defer os.RemoveAll(destination)
|
|
|
|
|
err := copyDir("./test_assets/copy_test", destination)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
@ -65,7 +66,7 @@ func Test_copyDir_shouldCopyAllFilesAndDirectories(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_backupPath_shouldSkipWhenNotExist(t *testing.T) {
|
|
|
|
|
tmpdir, _ := os.MkdirTemp("", "backup")
|
|
|
|
|
tmpdir, _ := ioutils.TempDir("", "backup")
|
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
|
|
|
|
|
|
err := copyPath("does-not-exists", tmpdir)
|
|
|
|
@ -75,7 +76,7 @@ func Test_backupPath_shouldSkipWhenNotExist(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_backupPath_shouldCopyFile(t *testing.T) {
|
|
|
|
|
tmpdir, _ := os.MkdirTemp("", "backup")
|
|
|
|
|
tmpdir, _ := ioutils.TempDir("", "backup")
|
|
|
|
|
defer os.RemoveAll(tmpdir)
|
|
|
|
|
|
|
|
|
|
content := []byte("content")
|
|
|
|
@ -91,7 +92,7 @@ func Test_backupPath_shouldCopyFile(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Test_backupPath_shouldCopyDir(t *testing.T) {
|
|
|
|
|
destination, _ := os.MkdirTemp("", "destination")
|
|
|
|
|
destination, _ := ioutils.TempDir("", "destination")
|
|
|
|
|
defer os.RemoveAll(destination)
|
|
|
|
|
err := copyPath("./test_assets/copy_test", destination)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|