fix tests; clean up ip file after build

This commit is contained in:
Megan Marsh 2019-04-04 16:57:42 -07:00
parent e9d5a1d272
commit 04b57b3e32
2 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/Telmate/proxmox-api-go/proxmox" "github.com/Telmate/proxmox-api-go/proxmox"
"github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/bootcommand" "github.com/hashicorp/packer/common/bootcommand"
commonhelper "github.com/hashicorp/packer/helper/common"
"github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
@ -96,7 +97,9 @@ func (s *stepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag)
return multistep.ActionContinue return multistep.ActionContinue
} }
func (*stepTypeBootCommand) Cleanup(multistep.StateBag) {} func (*stepTypeBootCommand) Cleanup(multistep.StateBag) {
commonhelper.RemoveSharedStateFile("ip", "")
}
func hostIP() (string, error) { func hostIP() (string, error) {
addrs, err := net.InterfaceAddrs() addrs, err := net.InterfaceAddrs()

View File

@ -115,6 +115,8 @@ func TestTypeBootCommand(t *testing.T) {
c.builderConfig.ctx, c.builderConfig.ctx,
} }
action := step.Run(context.TODO(), state) action := step.Run(context.TODO(), state)
step.Cleanup(state)
if action != c.expectedAction { if action != c.expectedAction {
t.Errorf("Expected action to be %v, got %v", c.expectedAction, action) t.Errorf("Expected action to be %v, got %v", c.expectedAction, action)
} }