Remove tmp files created by provisioner/powershell tests
This commit is contained in:
parent
70ccb8adff
commit
b738f41efa
|
@ -5,7 +5,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
//"log"
|
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -30,6 +29,7 @@ func TestProvisionerPrepare_extractScript(t *testing.T) {
|
||||||
p := new(Provisioner)
|
p := new(Provisioner)
|
||||||
_ = p.Prepare(config)
|
_ = p.Prepare(config)
|
||||||
file, err := extractScript(p)
|
file, err := extractScript(p)
|
||||||
|
defer os.Remove(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Should not be error: %s", err)
|
t.Fatalf("Should not be error: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,7 @@ func TestProvisionerPrepare_Script(t *testing.T) {
|
||||||
t.Fatalf("error tempfile: %s", err)
|
t.Fatalf("error tempfile: %s", err)
|
||||||
}
|
}
|
||||||
defer os.Remove(tf.Name())
|
defer os.Remove(tf.Name())
|
||||||
|
defer tf.Close()
|
||||||
|
|
||||||
config["script"] = tf.Name()
|
config["script"] = tf.Name()
|
||||||
p = new(Provisioner)
|
p = new(Provisioner)
|
||||||
|
@ -203,6 +204,7 @@ func TestProvisionerPrepare_ScriptAndInline(t *testing.T) {
|
||||||
t.Fatalf("error tempfile: %s", err)
|
t.Fatalf("error tempfile: %s", err)
|
||||||
}
|
}
|
||||||
defer os.Remove(tf.Name())
|
defer os.Remove(tf.Name())
|
||||||
|
defer tf.Close()
|
||||||
|
|
||||||
config["inline"] = []interface{}{"foo"}
|
config["inline"] = []interface{}{"foo"}
|
||||||
config["script"] = tf.Name()
|
config["script"] = tf.Name()
|
||||||
|
@ -222,6 +224,7 @@ func TestProvisionerPrepare_ScriptAndScripts(t *testing.T) {
|
||||||
t.Fatalf("error tempfile: %s", err)
|
t.Fatalf("error tempfile: %s", err)
|
||||||
}
|
}
|
||||||
defer os.Remove(tf.Name())
|
defer os.Remove(tf.Name())
|
||||||
|
defer tf.Close()
|
||||||
|
|
||||||
config["inline"] = []interface{}{"foo"}
|
config["inline"] = []interface{}{"foo"}
|
||||||
config["scripts"] = []string{tf.Name()}
|
config["scripts"] = []string{tf.Name()}
|
||||||
|
@ -248,6 +251,7 @@ func TestProvisionerPrepare_Scripts(t *testing.T) {
|
||||||
t.Fatalf("error tempfile: %s", err)
|
t.Fatalf("error tempfile: %s", err)
|
||||||
}
|
}
|
||||||
defer os.Remove(tf.Name())
|
defer os.Remove(tf.Name())
|
||||||
|
defer tf.Close()
|
||||||
|
|
||||||
config["scripts"] = []string{tf.Name()}
|
config["scripts"] = []string{tf.Name()}
|
||||||
p = new(Provisioner)
|
p = new(Provisioner)
|
||||||
|
@ -444,6 +448,8 @@ func TestProvisionerProvision_Inline(t *testing.T) {
|
||||||
func TestProvisionerProvision_Scripts(t *testing.T) {
|
func TestProvisionerProvision_Scripts(t *testing.T) {
|
||||||
tempFile, _ := ioutil.TempFile("", "packer")
|
tempFile, _ := ioutil.TempFile("", "packer")
|
||||||
defer os.Remove(tempFile.Name())
|
defer os.Remove(tempFile.Name())
|
||||||
|
defer tempFile.Close()
|
||||||
|
|
||||||
config := testConfig()
|
config := testConfig()
|
||||||
delete(config, "inline")
|
delete(config, "inline")
|
||||||
config["scripts"] = []string{tempFile.Name()}
|
config["scripts"] = []string{tempFile.Name()}
|
||||||
|
@ -473,6 +479,8 @@ func TestProvisionerProvision_ScriptsWithEnvVars(t *testing.T) {
|
||||||
config := testConfig()
|
config := testConfig()
|
||||||
ui := testUi()
|
ui := testUi()
|
||||||
defer os.Remove(tempFile.Name())
|
defer os.Remove(tempFile.Name())
|
||||||
|
defer tempFile.Close()
|
||||||
|
|
||||||
delete(config, "inline")
|
delete(config, "inline")
|
||||||
|
|
||||||
config["scripts"] = []string{tempFile.Name()}
|
config["scripts"] = []string{tempFile.Name()}
|
||||||
|
|
Loading…
Reference in New Issue