Example #1
0
func makeTempDir(t *testing.T, prefix string, files map[string]string) string {
	// We produce tmp dirs within home to make integration tests work within
	// Mac OS and VirtualBox
	home, err := homedir.Dir()
	if err != nil {
		log.Fatal(err)
	}

	baseTmpDir := path.Join(home, ".rocker-integ-tmp")

	if err := os.MkdirAll(baseTmpDir, 0755); err != nil {
		log.Fatal(err)
	}

	tmpDir, err := ioutil.TempDir(baseTmpDir, prefix)
	if err != nil {
		t.Fatal(err)
	}
	if err := test.MakeFiles(tmpDir, files); err != nil {
		os.RemoveAll(tmpDir)
		t.Fatal(err)
	}
	if *verbosityLevel >= 2 {
		fmt.Printf("temp directory: %s\n", tmpDir)
		fmt.Printf("  with files: %# v\n", pretty.Formatter(files))
	}
	return tmpDir
}
Example #2
0
func makeTmpDir(t *testing.T, files map[string]string) string {
	tmpDir, err := ioutil.TempDir("", "rocker-copy-test")
	if err != nil {
		t.Fatal(err)
	}
	if err := test.MakeFiles(tmpDir, files); err != nil {
		os.RemoveAll(tmpDir)
		t.Fatal(err)
	}
	t.Logf("temp files: %# v", pretty.Formatter(files))
	return tmpDir
}
Example #3
0
func tplMkFiles(t *testing.T, files map[string]string) (string, func()) {
	tempDir, err := ioutil.TempDir("", "rocker-vars-test")
	if err != nil {
		t.Fatal(err)
	}

	if err = test.MakeFiles(tempDir, files); err != nil {
		os.RemoveAll(tempDir)
		t.Fatal(err)
	}

	return tempDir, func() {
		os.RemoveAll(tempDir)
	}
}