github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/builder/googlecompute/step_check_existing_image_test.go (about)

     1  package googlecompute
     2  
     3  import (
     4  	"github.com/mitchellh/multistep"
     5  	"testing"
     6  )
     7  
     8  func TestStepCheckExistingImage_impl(t *testing.T) {
     9  	var _ multistep.Step = new(StepCheckExistingImage)
    10  }
    11  
    12  func TestStepCheckExistingImage(t *testing.T) {
    13  	state := testState(t)
    14  	step := new(StepCheckExistingImage)
    15  	defer step.Cleanup(state)
    16  
    17  	state.Put("instance_name", "foo")
    18  
    19  	config := state.Get("config").(*Config)
    20  	driver := state.Get("driver").(*DriverMock)
    21  	driver.ImageExistsResult = true
    22  
    23  	// run the step
    24  	if action := step.Run(state); action != multistep.ActionHalt {
    25  		t.Fatalf("bad action: %#v", action)
    26  	}
    27  
    28  	// Verify state
    29  	if driver.ImageExistsName != config.ImageName {
    30  		t.Fatalf("bad: %#v", driver.ImageExistsName)
    31  	}
    32  }