Skip to content

Commit 50d4032

Browse files
committed
use temp folder for before/after
1 parent 413d0a7 commit 50d4032

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/integration/driver_install_or_update_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,26 @@ func TestKVMDriverInstallOrUpdate(t *testing.T) {
6969

7070
_, err = os.Stat(filepath.Join(path, "docker-machine-driver-kvm2"))
7171
if err != nil {
72-
t.Fatalf("Expected driver to exist. test: %s, got: %v", tc.name, err)
72+
t.Fatalf("Expected test data driver to exist. test: %s, got: %v", tc.name, err)
73+
}
74+
75+
// copy test data driver into the temp download dir so we can point PATH to it for before/after install
76+
src := filepath.Join(path, "docker-machine-driver-kvm2")
77+
dst := filepath.Join(tempDLDir, "docker-machine-driver-kvm2")
78+
if err = CopyFile(src, dst, false); err != nil {
79+
t.Fatalf("Failed to copy test data driver to temp dir. test: %s, got: %v", tc.name, err)
7380
}
7481

82+
// point to the copied driver for the rest of the test
83+
path = tempDLDir
84+
7585
// change permission to allow driver to be executable
7686
err = os.Chmod(filepath.Join(path, "docker-machine-driver-kvm2"), 0700)
7787
if err != nil {
7888
t.Fatalf("Expected not expected when changing driver permission. test: %s, got: %v", tc.name, err)
7989
}
8090

81-
os.Setenv("PATH", fmt.Sprintf("%s:%s:%s", tempDLDir, path, originalPath))
91+
os.Setenv("PATH", fmt.Sprintf("%s:%s", path, originalPath))
8292

8393
// NOTE: This should be a real version, as it impacts the downloaded URL
8494
newerVersion, err := semver.Make("1.37.0")

0 commit comments

Comments
 (0)