48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
|
package utils
|
||
|
|
||
|
// https://pkg.go.dev/github.com/stretchr/testify/assert#Nilf
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"path/filepath"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestCopyFileExist(t *testing.T){
|
||
|
src := filepath.Join(TEST_SRC_DIR, "fichier1")
|
||
|
dest := filepath.Join(TEST_DEST_DIR, "fichier1")
|
||
|
|
||
|
err := CopyFile(src, dest)
|
||
|
|
||
|
assert.Nilf(t, err, "error message %s", src)
|
||
|
assert.FileExists(t, dest, "CopyFile error")
|
||
|
}
|
||
|
|
||
|
func TestCopyErrSrcFileNotExist(t *testing.T) {
|
||
|
src := filepath.Join(TEST_SRC_DIR, "inconnu")
|
||
|
dest := filepath.Join(TEST_DEST_DIR, "inconnu")
|
||
|
|
||
|
err := CopyFile(src, dest)
|
||
|
|
||
|
assert.NotNilf(t, err, "CopyFile error %s", src)
|
||
|
}
|
||
|
|
||
|
func TestCopyFileErrCreate(t *testing.T){
|
||
|
src := filepath.Join(TEST_SRC_DIR, "fichier1")
|
||
|
dest := filepath.Join("/INCONNU", "fichier1")
|
||
|
|
||
|
err := CopyFile(src, dest)
|
||
|
|
||
|
assert.NotNilf(t, err, "error message %s", src)
|
||
|
assert.NoFileExists(t, dest, "CopyFile error")
|
||
|
}
|
||
|
|
||
|
func TestCopyErrSrcWrite(t *testing.T) {
|
||
|
src := "/"
|
||
|
dest := filepath.Join(TEST_DEST_DIR, "inconnu")
|
||
|
|
||
|
err := CopyFile(src, dest)
|
||
|
|
||
|
assert.NotNilf(t, err, "CopyFile error %s", src)
|
||
|
}
|