The new flow: 1) Provision the instance 2) Tear down the instance, but keep the boot disk 3) Create an image from the disk 4) Tear down the disk The step to update gcloud is no longer needed, since gceimagebundle isn't used anymore. Fixes #1507 and addresses https://github.com/mitchellh/packer/issues/1447#issuecomment-61610235.
42 lines
955 B
Go
42 lines
955 B
Go
package googlecompute
|
|
|
|
import (
|
|
"github.com/mitchellh/multistep"
|
|
"testing"
|
|
)
|
|
|
|
func TestStepTeardownInstance_impl(t *testing.T) {
|
|
var _ multistep.Step = new(StepTeardownInstance)
|
|
}
|
|
|
|
func TestStepTeardownInstance(t *testing.T) {
|
|
state := testState(t)
|
|
step := new(StepTeardownInstance)
|
|
defer step.Cleanup(state)
|
|
|
|
config := state.Get("config").(*Config)
|
|
driver := state.Get("driver").(*DriverMock)
|
|
|
|
// run the step
|
|
if action := step.Run(state); action != multistep.ActionContinue {
|
|
t.Fatalf("bad action: %#v", action)
|
|
}
|
|
|
|
if driver.DeleteInstanceName != config.InstanceName {
|
|
t.Fatal("should've deleted instance")
|
|
}
|
|
if driver.DeleteInstanceZone != config.Zone {
|
|
t.Fatal("bad zone: %#v", driver.DeleteInstanceZone)
|
|
}
|
|
|
|
// cleanup
|
|
step.Cleanup(state)
|
|
|
|
if driver.DeleteDiskName != config.InstanceName {
|
|
t.Fatal("should've deleted disk")
|
|
}
|
|
if driver.DeleteDiskZone != config.Zone {
|
|
t.Fatal("bad zone: %#v", driver.DeleteDiskZone)
|
|
}
|
|
}
|