command: cleanup test function names

This commit is contained in:
Armon Dadgar 2014-10-09 14:45:08 -07:00 committed by Mitchell Hashimoto
parent 7ba0c003f2
commit 09d7fb7c27
4 changed files with 19 additions and 13 deletions

View File

@ -186,12 +186,18 @@ func testCwd(t *testing.T) (string, string) {
if err != nil { if err != nil {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
os.Chdir(tmp) if err := os.Chdir(tmp); err != nil {
t.Fatalf("err: %v", err)
}
return tmp, cwd return tmp, cwd
} }
// fixDir is used to as a defer to testDir // testFixCwd is used to as a defer to testDir
func fixDir(tmp, cwd string) { func testFixCwd(t *testing.T, tmp, cwd string) {
os.Chdir(cwd) if err := os.Chdir(cwd); err != nil {
os.RemoveAll(tmp) t.Fatalf("err: %v", err)
}
if err := os.RemoveAll(tmp); err != nil {
t.Fatalf("err: %v", err)
}
} }

View File

@ -147,7 +147,7 @@ func TestInit_dstInSrc(t *testing.T) {
func TestInit_remoteState(t *testing.T) { func TestInit_remoteState(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
s := terraform.NewState() s := terraform.NewState()
conf, srv := testRemoteState(t, s, 200) conf, srv := testRemoteState(t, s, 200)

View File

@ -17,7 +17,7 @@ import (
func TestPull_noRemote(t *testing.T) { func TestPull_noRemote(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PullCommand{ c := &PullCommand{
@ -35,7 +35,7 @@ func TestPull_noRemote(t *testing.T) {
func TestPull_cliRemote(t *testing.T) { func TestPull_cliRemote(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
s := terraform.NewState() s := terraform.NewState()
conf, srv := testRemoteState(t, s, 200) conf, srv := testRemoteState(t, s, 200)
@ -63,7 +63,7 @@ func TestPull_cliRemote(t *testing.T) {
func TestPull_local(t *testing.T) { func TestPull_local(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
s := terraform.NewState() s := terraform.NewState()
s.Serial = 10 s.Serial = 10

View File

@ -13,7 +13,7 @@ import (
func TestPush_noRemote(t *testing.T) { func TestPush_noRemote(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PushCommand{ c := &PushCommand{
@ -31,7 +31,7 @@ func TestPush_noRemote(t *testing.T) {
func TestPush_cliRemote_noState(t *testing.T) { func TestPush_cliRemote_noState(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
s := terraform.NewState() s := terraform.NewState()
conf, srv := testRemoteState(t, s, 200) conf, srv := testRemoteState(t, s, 200)
@ -54,7 +54,7 @@ func TestPush_cliRemote_noState(t *testing.T) {
func TestPush_cliRemote_withState(t *testing.T) { func TestPush_cliRemote_withState(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
s := terraform.NewState() s := terraform.NewState()
conf, srv := testRemoteState(t, s, 200) conf, srv := testRemoteState(t, s, 200)
@ -98,7 +98,7 @@ func TestPush_cliRemote_withState(t *testing.T) {
func TestPush_local(t *testing.T) { func TestPush_local(t *testing.T) {
tmp, cwd := testCwd(t) tmp, cwd := testCwd(t)
defer fixDir(tmp, cwd) defer testFixCwd(t, tmp, cwd)
s := terraform.NewState() s := terraform.NewState()
s.Serial = 5 s.Serial = 5