github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/builder/googlecompute/step_teardown_instance_test.go (about) 1 package googlecompute 2 3 import ( 4 "github.com/mitchellh/multistep" 5 "testing" 6 ) 7 8 func TestStepTeardownInstance_impl(t *testing.T) { 9 var _ multistep.Step = new(StepTeardownInstance) 10 } 11 12 func TestStepTeardownInstance(t *testing.T) { 13 state := testState(t) 14 step := new(StepTeardownInstance) 15 defer step.Cleanup(state) 16 17 config := state.Get("config").(*Config) 18 driver := state.Get("driver").(*DriverMock) 19 20 // run the step 21 if action := step.Run(state); action != multistep.ActionContinue { 22 t.Fatalf("bad action: %#v", action) 23 } 24 25 if driver.DeleteInstanceName != config.InstanceName { 26 t.Fatal("should've deleted instance") 27 } 28 if driver.DeleteInstanceZone != config.Zone { 29 t.Fatalf("bad zone: %#v", driver.DeleteInstanceZone) 30 } 31 32 // cleanup 33 step.Cleanup(state) 34 35 if driver.DeleteDiskName != config.InstanceName { 36 t.Fatal("should've deleted disk") 37 } 38 if driver.DeleteDiskZone != config.Zone { 39 t.Fatalf("bad zone: %#v", driver.DeleteDiskZone) 40 } 41 }