github.com/rothwerx/packer@v0.9.0/builder/parallels/common/step_upload_parallels_tools_test.go (about)

     1  package common
     2  
     3  import (
     4  	"github.com/mitchellh/multistep"
     5  	"github.com/mitchellh/packer/packer"
     6  	"testing"
     7  )
     8  
     9  func TestStepUploadParallelsTools_impl(t *testing.T) {
    10  	var _ multistep.Step = new(StepUploadParallelsTools)
    11  }
    12  
    13  func TestStepUploadParallelsTools(t *testing.T) {
    14  	state := testState(t)
    15  	state.Put("parallels_tools_path", "./step_upload_parallels_tools_test.go")
    16  	step := new(StepUploadParallelsTools)
    17  	step.ParallelsToolsMode = "upload"
    18  	step.ParallelsToolsGuestPath = "/tmp/prl-lin.iso"
    19  	step.ParallelsToolsFlavor = "lin"
    20  
    21  	comm := new(packer.MockCommunicator)
    22  	state.Put("communicator", comm)
    23  
    24  	// Test the run
    25  	if action := step.Run(state); action != multistep.ActionContinue {
    26  		t.Fatalf("bad action: %#v", action)
    27  	}
    28  	if _, ok := state.GetOk("error"); ok {
    29  		t.Fatal("should NOT have error")
    30  	}
    31  
    32  	// Verify
    33  	if comm.UploadPath != "/tmp/prl-lin.iso" {
    34  		t.Fatalf("bad: %#v", comm.UploadPath)
    35  	}
    36  }
    37  
    38  func TestStepUploadParallelsTools_interpolate(t *testing.T) {
    39  	state := testState(t)
    40  	state.Put("parallels_tools_path", "./step_upload_parallels_tools_test.go")
    41  	step := new(StepUploadParallelsTools)
    42  	step.ParallelsToolsMode = "upload"
    43  	step.ParallelsToolsGuestPath = "/tmp/prl-{{ .Flavor }}.iso"
    44  	step.ParallelsToolsFlavor = "win"
    45  
    46  	comm := new(packer.MockCommunicator)
    47  	state.Put("communicator", comm)
    48  
    49  	// Test the run
    50  	if action := step.Run(state); action != multistep.ActionContinue {
    51  		t.Fatalf("bad action: %#v", action)
    52  	}
    53  	if _, ok := state.GetOk("error"); ok {
    54  		t.Fatal("should NOT have error")
    55  	}
    56  
    57  	// Verify
    58  	if comm.UploadPath != "/tmp/prl-win.iso" {
    59  		t.Fatalf("bad: %#v", comm.UploadPath)
    60  	}
    61  }
    62  
    63  func TestStepUploadParallelsTools_attach(t *testing.T) {
    64  	state := testState(t)
    65  	state.Put("parallels_tools_path", "./step_upload_parallels_tools_test.go")
    66  	step := new(StepUploadParallelsTools)
    67  	step.ParallelsToolsMode = "attach"
    68  	step.ParallelsToolsGuestPath = "/tmp/prl-lin.iso"
    69  	step.ParallelsToolsFlavor = "lin"
    70  
    71  	comm := new(packer.MockCommunicator)
    72  	state.Put("communicator", comm)
    73  
    74  	// Test the run
    75  	if action := step.Run(state); action != multistep.ActionContinue {
    76  		t.Fatalf("bad action: %#v", action)
    77  	}
    78  	if _, ok := state.GetOk("error"); ok {
    79  		t.Fatal("should NOT have error")
    80  	}
    81  
    82  	// Verify
    83  	if comm.UploadCalled {
    84  		t.Fatal("bad")
    85  	}
    86  }