github.com/sneal/packer@v0.5.2/builder/vmware/common/step_compact_disk_test.go (about)

     1  package common
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/mitchellh/multistep"
     7  )
     8  
     9  func TestStepCompactDisk_impl(t *testing.T) {
    10  	var _ multistep.Step = new(StepCompactDisk)
    11  }
    12  
    13  func TestStepCompactDisk(t *testing.T) {
    14  	state := testState(t)
    15  	step := new(StepCompactDisk)
    16  
    17  	state.Put("full_disk_path", "foo")
    18  
    19  	driver := state.Get("driver").(*DriverMock)
    20  
    21  	// Test the run
    22  	if action := step.Run(state); action != multistep.ActionContinue {
    23  		t.Fatalf("bad action: %#v", action)
    24  	}
    25  	if _, ok := state.GetOk("error"); ok {
    26  		t.Fatal("should NOT have error")
    27  	}
    28  
    29  	// Test the driver
    30  	if !driver.CompactDiskCalled {
    31  		t.Fatal("should've called")
    32  	}
    33  	if driver.CompactDiskPath != "foo" {
    34  		t.Fatal("should call with right path")
    35  	}
    36  }
    37  
    38  func TestStepCompactDisk_skip(t *testing.T) {
    39  	state := testState(t)
    40  	step := new(StepCompactDisk)
    41  	step.Skip = true
    42  
    43  	state.Put("full_disk_path", "foo")
    44  
    45  	driver := state.Get("driver").(*DriverMock)
    46  
    47  	// Test the run
    48  	if action := step.Run(state); action != multistep.ActionContinue {
    49  		t.Fatalf("bad action: %#v", action)
    50  	}
    51  	if _, ok := state.GetOk("error"); ok {
    52  		t.Fatal("should NOT have error")
    53  	}
    54  
    55  	// Test the driver
    56  	if driver.CompactDiskCalled {
    57  		t.Fatal("should not have called")
    58  	}
    59  }