Remove tmp files created by provisioner/puppet-server tests

pull/6200/head
DanHam 8 years ago
parent fd07cfd2b1
commit 70ccb8adff
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E

@ -8,15 +8,17 @@ import (
"github.com/hashicorp/packer/packer"
)
func testConfig() map[string]interface{} {
func testConfig() (config map[string]interface{}, tf *os.File) {
tf, err := ioutil.TempFile("", "packer")
if err != nil {
panic(err)
}
return map[string]interface{}{
config = map[string]interface{}{
"puppet_server": tf.Name(),
}
return config, tf
}
func TestProvisioner_Impl(t *testing.T) {
@ -28,7 +30,9 @@ func TestProvisioner_Impl(t *testing.T) {
}
func TestProvisionerPrepare_puppetBinDir(t *testing.T) {
config := testConfig()
config, tempfile := testConfig()
defer os.Remove(tempfile.Name())
defer tempfile.Close()
delete(config, "puppet_bin_dir")
p := new(Provisioner)
@ -53,7 +57,9 @@ func TestProvisionerPrepare_puppetBinDir(t *testing.T) {
}
func TestProvisionerPrepare_clientPrivateKeyPath(t *testing.T) {
config := testConfig()
config, tempfile := testConfig()
defer os.Remove(tempfile.Name())
defer tempfile.Close()
delete(config, "client_private_key_path")
p := new(Provisioner)
@ -86,7 +92,9 @@ func TestProvisionerPrepare_clientPrivateKeyPath(t *testing.T) {
}
func TestProvisionerPrepare_clientCertPath(t *testing.T) {
config := testConfig()
config, tempfile := testConfig()
defer os.Remove(tempfile.Name())
defer tempfile.Close()
delete(config, "client_cert_path")
p := new(Provisioner)
@ -119,7 +127,9 @@ func TestProvisionerPrepare_clientCertPath(t *testing.T) {
}
func TestProvisionerPrepare_executeCommand(t *testing.T) {
config := testConfig()
config, tempfile := testConfig()
defer os.Remove(tempfile.Name())
defer tempfile.Close()
delete(config, "execute_command")
p := new(Provisioner)
@ -130,7 +140,9 @@ func TestProvisionerPrepare_executeCommand(t *testing.T) {
}
func TestProvisionerPrepare_facterFacts(t *testing.T) {
config := testConfig()
config, tempfile := testConfig()
defer os.Remove(tempfile.Name())
defer tempfile.Close()
delete(config, "facter")
p := new(Provisioner)
@ -185,7 +197,9 @@ func TestProvisionerPrepare_facterFacts(t *testing.T) {
}
func TestProvisionerPrepare_stagingDir(t *testing.T) {
config := testConfig()
config, tempfile := testConfig()
defer os.Remove(tempfile.Name())
defer tempfile.Close()
delete(config, "staging_dir")
p := new(Provisioner)

Loading…
Cancel
Save