packer-cn/builder/qemu/step_http_ip_discover_test.go
Wilken Rivera 9ec8b67392
Add golangci-lint to project (#8686)
* Add golangci-lint as linting tool

* Disable failing staticchecks to start; GitHub issue to handle coming soon

* Run `goimports -w` to repair all source files that have improperly
formatted imports

* makefile: Add ci-lint target to run on travis

This change adds a new make target for running golangci-lint on newly
added Go files only. This target is expected to run during Packer ci builds.

* .github/contributing: Add code linting instructions

* travis: Update job configuration to run parallel builds
2020-02-14 11:42:29 -05:00

31 lines
710 B
Go

package qemu
import (
"context"
"testing"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
)
func TestStepHTTPIPDiscover_Run(t *testing.T) {
state := new(multistep.BasicStateBag)
step := new(stepHTTPIPDiscover)
hostIp := "10.0.2.2"
previousHttpIp := common.GetHTTPIP()
// 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 := common.GetHTTPIP()
if httpIp != hostIp {
t.Fatalf("bad: Http ip is %s but was supposed to be %s", httpIp, hostIp)
}
common.SetHTTPIP(previousHttpIp)
}