60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
|
package common
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/mitchellh/multistep"
|
||
|
)
|
||
|
|
||
|
func TestStepCompactDisk_impl(t *testing.T) {
|
||
|
var _ multistep.Step = new(StepCompactDisk)
|
||
|
}
|
||
|
|
||
|
func TestStepCompactDisk(t *testing.T) {
|
||
|
state := testState(t)
|
||
|
step := new(StepCompactDisk)
|
||
|
|
||
|
state.Put("full_disk_path", "foo")
|
||
|
|
||
|
driver := state.Get("driver").(*DriverMock)
|
||
|
|
||
|
// Test the run
|
||
|
if action := step.Run(state); action != multistep.ActionContinue {
|
||
|
t.Fatalf("bad action: %#v", action)
|
||
|
}
|
||
|
if _, ok := state.GetOk("error"); ok {
|
||
|
t.Fatal("should NOT have error")
|
||
|
}
|
||
|
|
||
|
// Test the driver
|
||
|
if !driver.CompactDiskCalled {
|
||
|
t.Fatal("should've called")
|
||
|
}
|
||
|
if driver.CompactDiskPath != "foo" {
|
||
|
t.Fatal("should call with right path")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestStepCompactDisk_skip(t *testing.T) {
|
||
|
state := testState(t)
|
||
|
step := new(StepCompactDisk)
|
||
|
step.Skip = true
|
||
|
|
||
|
state.Put("full_disk_path", "foo")
|
||
|
|
||
|
driver := state.Get("driver").(*DriverMock)
|
||
|
|
||
|
// Test the run
|
||
|
if action := step.Run(state); action != multistep.ActionContinue {
|
||
|
t.Fatalf("bad action: %#v", action)
|
||
|
}
|
||
|
if _, ok := state.GetOk("error"); ok {
|
||
|
t.Fatal("should NOT have error")
|
||
|
}
|
||
|
|
||
|
// Test the driver
|
||
|
if driver.CompactDiskCalled {
|
||
|
t.Fatal("should not have called")
|
||
|
}
|
||
|
}
|