|
|
|
|
@ -9,15 +9,17 @@ import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/backend"
|
|
|
|
|
"github.com/hashicorp/terraform/config/configschema"
|
|
|
|
|
"github.com/hashicorp/terraform/configs/configload"
|
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestLocal_planBasic(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
p := TestLocalProvider(t, b, "test")
|
|
|
|
|
p := TestLocalProvider(t, b, "test", planFixtureSchema())
|
|
|
|
|
|
|
|
|
|
op, configCleanup := testOperationPlan(t, "./test-fixtures/plan")
|
|
|
|
|
defer configCleanup()
|
|
|
|
|
@ -40,7 +42,7 @@ func TestLocal_planBasic(t *testing.T) {
|
|
|
|
|
func TestLocal_planInAutomation(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
TestLocalProvider(t, b, "test")
|
|
|
|
|
TestLocalProvider(t, b, "test", planFixtureSchema())
|
|
|
|
|
|
|
|
|
|
const msg = `You didn't specify an "-out" parameter`
|
|
|
|
|
|
|
|
|
|
@ -101,7 +103,7 @@ func TestLocal_planInAutomation(t *testing.T) {
|
|
|
|
|
func TestLocal_planNoConfig(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
TestLocalProvider(t, b, "test")
|
|
|
|
|
TestLocalProvider(t, b, "test", &terraform.ProviderSchema{})
|
|
|
|
|
|
|
|
|
|
b.CLI = cli.NewMockUi()
|
|
|
|
|
|
|
|
|
|
@ -127,7 +129,7 @@ func TestLocal_planNoConfig(t *testing.T) {
|
|
|
|
|
func TestLocal_planRefreshFalse(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
p := TestLocalProvider(t, b, "test")
|
|
|
|
|
p := TestLocalProvider(t, b, "test", &terraform.ProviderSchema{})
|
|
|
|
|
terraform.TestStateFile(t, b.StatePath, testPlanState())
|
|
|
|
|
|
|
|
|
|
op, configCleanup := testOperationPlan(t, "./test-fixtures/empty")
|
|
|
|
|
@ -154,7 +156,7 @@ func TestLocal_planRefreshFalse(t *testing.T) {
|
|
|
|
|
func TestLocal_planDestroy(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
p := TestLocalProvider(t, b, "test")
|
|
|
|
|
p := TestLocalProvider(t, b, "test", planFixtureSchema())
|
|
|
|
|
terraform.TestStateFile(t, b.StatePath, testPlanState())
|
|
|
|
|
|
|
|
|
|
outDir := testTempDir(t)
|
|
|
|
|
@ -197,7 +199,7 @@ func TestLocal_planDestroy(t *testing.T) {
|
|
|
|
|
func TestLocal_planOutPathNoChange(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
TestLocalProvider(t, b, "test")
|
|
|
|
|
TestLocalProvider(t, b, "test", planFixtureSchema())
|
|
|
|
|
terraform.TestStateFile(t, b.StatePath, testPlanState())
|
|
|
|
|
|
|
|
|
|
outDir := testTempDir(t)
|
|
|
|
|
@ -232,7 +234,7 @@ func TestLocal_planOutPathNoChange(t *testing.T) {
|
|
|
|
|
func TestLocal_planScaleOutNoDupeCount(t *testing.T) {
|
|
|
|
|
b, cleanup := TestLocal(t)
|
|
|
|
|
defer cleanup()
|
|
|
|
|
TestLocalProvider(t, b, "test")
|
|
|
|
|
TestLocalProvider(t, b, "test", planFixtureSchema())
|
|
|
|
|
state := &terraform.State{
|
|
|
|
|
Version: 2,
|
|
|
|
|
Modules: []*terraform.ModuleState{
|
|
|
|
|
@ -334,3 +336,29 @@ func testReadPlan(t *testing.T, path string) *terraform.Plan {
|
|
|
|
|
|
|
|
|
|
return p
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// planFixtureSchema returns a schema suitable for processing the
|
|
|
|
|
// configuration in test-fixtures/plan . This schema should be
|
|
|
|
|
// assigned to a mock provider named "test".
|
|
|
|
|
func planFixtureSchema() *terraform.ProviderSchema {
|
|
|
|
|
return &terraform.ProviderSchema{
|
|
|
|
|
ResourceTypes: map[string]*configschema.Block{
|
|
|
|
|
"test_instance": {
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"ami": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
BlockTypes: map[string]*configschema.NestedBlock{
|
|
|
|
|
"network_interface": {
|
|
|
|
|
Nesting: configschema.NestingList,
|
|
|
|
|
Block: configschema.Block{
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"device_index": {Type: cty.Number, Optional: true},
|
|
|
|
|
"description": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|