github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/builder/googlecompute/step_wait_startup_script_test.go (about) 1 package googlecompute 2 3 import ( 4 "github.com/mitchellh/multistep" 5 "github.com/stretchr/testify/assert" 6 "testing" 7 ) 8 9 func TestStepWaitStartupScript(t *testing.T) { 10 state := testState(t) 11 step := new(StepWaitStartupScript) 12 c := state.Get("config").(*Config) 13 d := state.Get("driver").(*DriverMock) 14 15 testZone := "test-zone" 16 testInstanceName := "test-instance-name" 17 18 c.Zone = testZone 19 state.Put("instance_name", testInstanceName) 20 21 // This step stops when it gets Done back from the metadata. 22 d.GetInstanceMetadataResult = StartupScriptStatusDone 23 24 // Run the step. 25 assert.Equal(t, step.Run(state), multistep.ActionContinue, "Step should have passed and continued.") 26 27 // Check that GetInstanceMetadata was called properly. 28 assert.Equal(t, d.GetInstanceMetadataZone, testZone, "Incorrect zone passed to GetInstanceMetadata.") 29 assert.Equal(t, d.GetInstanceMetadataName, testInstanceName, "Incorrect instance name passed to GetInstanceMetadata.") 30 }