mirror of
https://github.com/hashicorp/packer.git
synced 2026-10-05 22:23:18 -04:00
adds tests to usb_driver and step_http_ip_discover
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepHTTPIPDiscover_Run(t *testing.T) {
|
||||
state := new(multistep.BasicStateBag)
|
||||
step := new(StepHTTPIPDiscover)
|
||||
|
||||
// without setting HTTPIP
|
||||
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")
|
||||
}
|
||||
_, ok := state.GetOk("http_ip")
|
||||
if !ok {
|
||||
t.Fatal("should have http_ip")
|
||||
}
|
||||
|
||||
// setting HTTPIP
|
||||
ip := "10.0.2.2"
|
||||
step = &StepHTTPIPDiscover{
|
||||
HTTPIP: ip,
|
||||
}
|
||||
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, ok := state.GetOk("http_ip")
|
||||
if !ok {
|
||||
t.Fatal("should have http_ip")
|
||||
}
|
||||
if httpIp != ip {
|
||||
t.Fatalf("bad: Http ip is %s but was supposed to be %s", httpIp, ip)
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,14 @@ package iso
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/packer/builder/vsphere/driver"
|
||||
"github.com/hashicorp/packer/common/bootcommand"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/template/interpolate"
|
||||
"golang.org/x/mobile/event/key"
|
||||
"time"
|
||||
)
|
||||
|
||||
type BootConfig struct {
|
||||
|
||||
Reference in New Issue
Block a user