27 lines
616 B
Go
27 lines
616 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
|
)
|
|
|
|
func TestStepHTTPIPDiscover_Run(t *testing.T) {
|
|
state := new(multistep.BasicStateBag)
|
|
step := new(StepHTTPIPDiscover)
|
|
hostIp := "10.0.2.2"
|
|
|
|
// Test the run
|
|
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
|
t.Fatalf("bad action: %#v", action)
|
|
}
|
|
if _, ok := state.GetOk("error"); ok {
|
|
t.Fatal("should NOT have error")
|
|
}
|
|
httpIp := state.Get("http_ip").(string)
|
|
if httpIp != hostIp {
|
|
t.Fatalf("bad: Http ip is %s but was supposed to be %s", httpIp, hostIp)
|
|
}
|
|
}
|