2014-12-09 11:42:33 -05:00
|
|
|
package googlecompute
|
|
|
|
|
|
|
|
import (
|
2018-01-22 19:03:49 -05:00
|
|
|
"context"
|
2014-12-09 11:42:33 -05:00
|
|
|
"testing"
|
2018-01-22 20:21:10 -05:00
|
|
|
|
2020-11-17 19:31:03 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
2014-12-09 11:42:33 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStepCheckExistingImage_impl(t *testing.T) {
|
|
|
|
var _ multistep.Step = new(StepCheckExistingImage)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStepCheckExistingImage(t *testing.T) {
|
|
|
|
state := testState(t)
|
|
|
|
step := new(StepCheckExistingImage)
|
|
|
|
defer step.Cleanup(state)
|
|
|
|
|
|
|
|
state.Put("instance_name", "foo")
|
|
|
|
|
|
|
|
config := state.Get("config").(*Config)
|
|
|
|
driver := state.Get("driver").(*DriverMock)
|
|
|
|
driver.ImageExistsResult = true
|
|
|
|
|
|
|
|
// run the step
|
2018-01-22 19:03:49 -05:00
|
|
|
if action := step.Run(context.Background(), state); action != multistep.ActionHalt {
|
2014-12-09 11:42:33 -05:00
|
|
|
t.Fatalf("bad action: %#v", action)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify state
|
|
|
|
if driver.ImageExistsName != config.ImageName {
|
|
|
|
t.Fatalf("bad: %#v", driver.ImageExistsName)
|
|
|
|
}
|
|
|
|
}
|