properly cleanup and print correct error messages
Some Meta tests were not cleaning up their temp directories. The process test wasn't printing the correct arguments in the error messages.
This commit is contained in:
parent
0543574383
commit
0fdcf2c01e
|
@ -138,20 +138,12 @@ func TestMetaInputMode_defaultVars(t *testing.T) {
|
||||||
|
|
||||||
// Create a temporary directory for our cwd
|
// Create a temporary directory for our cwd
|
||||||
d := tempDir(t)
|
d := tempDir(t)
|
||||||
if err := os.MkdirAll(d, 0755); err != nil {
|
os.MkdirAll(d, 0755)
|
||||||
t.Fatalf("err: %s", err)
|
defer os.RemoveAll(d)
|
||||||
}
|
defer testChdir(t, d)()
|
||||||
cwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
if err := os.Chdir(d); err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
// Create the default vars file
|
// Create the default vars file
|
||||||
err = ioutil.WriteFile(
|
err := ioutil.WriteFile(
|
||||||
filepath.Join(d, DefaultVarsFilename),
|
filepath.Join(d, DefaultVarsFilename),
|
||||||
[]byte(""),
|
[]byte(""),
|
||||||
0644)
|
0644)
|
||||||
|
@ -326,21 +318,13 @@ func TestMeta_process(t *testing.T) {
|
||||||
|
|
||||||
// Create a temporary directory for our cwd
|
// Create a temporary directory for our cwd
|
||||||
d := tempDir(t)
|
d := tempDir(t)
|
||||||
if err := os.MkdirAll(d, 0755); err != nil {
|
os.MkdirAll(d, 0755)
|
||||||
t.Fatalf("err: %s", err)
|
defer os.RemoveAll(d)
|
||||||
}
|
defer testChdir(t, d)()
|
||||||
cwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
if err := os.Chdir(d); err != nil {
|
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
}
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
// Create two vars files
|
// Create two vars files
|
||||||
defaultVarsfile := "terraform.tfvars"
|
defaultVarsfile := "terraform.tfvars"
|
||||||
err = ioutil.WriteFile(
|
err := ioutil.WriteFile(
|
||||||
filepath.Join(d, defaultVarsfile),
|
filepath.Join(d, defaultVarsfile),
|
||||||
[]byte(""),
|
[]byte(""),
|
||||||
0644)
|
0644)
|
||||||
|
@ -388,18 +372,18 @@ func TestMeta_process(t *testing.T) {
|
||||||
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
||||||
}
|
}
|
||||||
if args[1] != defaultVarsfile {
|
if args[1] != defaultVarsfile {
|
||||||
t.Fatalf("expected %q, got %q", defaultVarsfile, args[3])
|
t.Fatalf("expected %q, got %q", defaultVarsfile, args[1])
|
||||||
}
|
}
|
||||||
if args[2] != "-var-file-default" {
|
if args[2] != "-var-file-default" {
|
||||||
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
t.Fatalf("expected %q, got %q", "-var-file-default", args[2])
|
||||||
}
|
}
|
||||||
if args[3] != fileFirstAlphabetical {
|
if args[3] != fileFirstAlphabetical {
|
||||||
t.Fatalf("expected %q, got %q", fileFirstAlphabetical, args[1])
|
t.Fatalf("expected %q, got %q", fileFirstAlphabetical, args[3])
|
||||||
}
|
}
|
||||||
if args[4] != "-var-file-default" {
|
if args[4] != "-var-file-default" {
|
||||||
t.Fatalf("expected %q, got %q", "-var-file-default", args[0])
|
t.Fatalf("expected %q, got %q", "-var-file-default", args[4])
|
||||||
}
|
}
|
||||||
if args[5] != fileLastAlphabetical {
|
if args[5] != fileLastAlphabetical {
|
||||||
t.Fatalf("expected %q, got %q", fileLastAlphabetical, args[3])
|
t.Fatalf("expected %q, got %q", fileLastAlphabetical, args[5])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue