command: remove unused test
This commit is contained in:
parent
0224a12a00
commit
d1b930d5b5
|
@ -1,72 +1,10 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/mitchellh/colorstring"
|
||||
)
|
||||
|
||||
func TestUiHookPostApply_emptyState(t *testing.T) {
|
||||
colorize := &colorstring.Colorize{
|
||||
Colors: colorstring.DefaultColors,
|
||||
Disable: true,
|
||||
Reset: true,
|
||||
}
|
||||
|
||||
ir := bytes.NewReader([]byte{})
|
||||
errBuf := bytes.NewBuffer([]byte{})
|
||||
outBuf := bytes.NewBuffer([]byte{})
|
||||
ui := cli.MockUi{
|
||||
InputReader: ir,
|
||||
ErrorWriter: errBuf,
|
||||
OutputWriter: outBuf,
|
||||
}
|
||||
h := &UiHook{
|
||||
Colorize: colorize,
|
||||
Ui: &ui,
|
||||
}
|
||||
h.init()
|
||||
h.resources = map[string]uiResourceState{
|
||||
"data.google_compute_zones.available": uiResourceState{
|
||||
Op: uiResourceDestroy,
|
||||
Start: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
mock := &terraform.MockInstanceInfo{
|
||||
terraform.InstanceInfo{
|
||||
Id: "data.google_compute_zones.available",
|
||||
ModulePath: []string{"root"},
|
||||
Type: "google_compute_zones",
|
||||
},
|
||||
}
|
||||
n := mock.WithUniqueExtra("destroy")
|
||||
action, err := h.PostApply(n, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if action != terraform.HookActionContinue {
|
||||
t.Fatalf("Expected hook to continue, given: %#v", action)
|
||||
}
|
||||
|
||||
expectedOutput := ""
|
||||
output := outBuf.String()
|
||||
if output != expectedOutput {
|
||||
t.Fatalf("Output didn't match.\nExpected: %q\nGiven: %q", expectedOutput, output)
|
||||
}
|
||||
|
||||
expectedErrOutput := ""
|
||||
errOutput := errBuf.String()
|
||||
if errOutput != expectedErrOutput {
|
||||
t.Fatalf("Error output didn't match.\nExpected: %q\nGiven: %q", expectedErrOutput, errOutput)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateId(t *testing.T) {
|
||||
testCases := []struct {
|
||||
Input string
|
||||
|
|
|
@ -72,19 +72,6 @@ type InstanceInfo struct {
|
|||
uniqueExtra string
|
||||
}
|
||||
|
||||
type MockInstanceInfo struct {
|
||||
InstanceInfo
|
||||
}
|
||||
|
||||
func (m *MockInstanceInfo) WithUniqueExtra(extra string) *InstanceInfo {
|
||||
return &InstanceInfo{
|
||||
Id: m.Id,
|
||||
ModulePath: m.ModulePath,
|
||||
Type: m.Type,
|
||||
uniqueExtra: extra,
|
||||
}
|
||||
}
|
||||
|
||||
// HumanId is a unique Id that is human-friendly and useful for UI elements.
|
||||
func (i *InstanceInfo) HumanId() string {
|
||||
if i == nil {
|
||||
|
|
Loading…
Reference in New Issue