command: Update apply_test.go for new provider types
This only makes it compile. It does not yet ensure that the tests pass.
This commit is contained in:
parent
d9051be66d
commit
65341b0973
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/hashicorp/terraform/addrs"
|
"github.com/hashicorp/terraform/addrs"
|
||||||
"github.com/hashicorp/terraform/configs/configschema"
|
"github.com/hashicorp/terraform/configs/configschema"
|
||||||
"github.com/hashicorp/terraform/plans"
|
"github.com/hashicorp/terraform/plans"
|
||||||
|
"github.com/hashicorp/terraform/providers"
|
||||||
"github.com/hashicorp/terraform/state"
|
"github.com/hashicorp/terraform/state"
|
||||||
"github.com/hashicorp/terraform/states"
|
"github.com/hashicorp/terraform/states"
|
||||||
"github.com/hashicorp/terraform/states/statemgr"
|
"github.com/hashicorp/terraform/states/statemgr"
|
||||||
|
@ -399,9 +400,13 @@ func TestApply_input(t *testing.T) {
|
||||||
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.InputCalled {
|
expected := strings.TrimSpace(`
|
||||||
t.Fatal("input should be called")
|
<no state>
|
||||||
}
|
Outputs:
|
||||||
|
|
||||||
|
result = foo
|
||||||
|
`)
|
||||||
|
testStateOutput(t, statePath, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When only a partial set of the variables are set, Terraform
|
// When only a partial set of the variables are set, Terraform
|
||||||
|
@ -517,10 +522,6 @@ func TestApply_plan(t *testing.T) {
|
||||||
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.InputCalled {
|
|
||||||
t.Fatalf("input should not be called for plans")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := os.Stat(statePath); err != nil {
|
if _, err := os.Stat(statePath); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -638,10 +639,6 @@ func TestApply_plan_remoteState(t *testing.T) {
|
||||||
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.InputCalled {
|
|
||||||
t.Fatalf("input should not be called for plans")
|
|
||||||
}
|
|
||||||
|
|
||||||
// State file should be not be installed
|
// State file should be not be installed
|
||||||
if _, err := os.Stat(filepath.Join(tmp, DefaultStateFilename)); err == nil {
|
if _, err := os.Stat(filepath.Join(tmp, DefaultStateFilename)); err == nil {
|
||||||
data, _ := ioutil.ReadFile(DefaultStateFilename)
|
data, _ := ioutil.ReadFile(DefaultStateFilename)
|
||||||
|
@ -744,7 +741,7 @@ func TestApply_planNoModuleFiles(t *testing.T) {
|
||||||
planFile,
|
planFile,
|
||||||
}
|
}
|
||||||
apply.Run(args)
|
apply.Run(args)
|
||||||
if p.ValidateCalled {
|
if p.ValidateProviderConfigCalled {
|
||||||
t.Fatal("Validate should not be called with a plan")
|
t.Fatal("Validate should not be called with a plan")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -784,8 +781,8 @@ func TestApply_refresh(t *testing.T) {
|
||||||
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.RefreshCalled {
|
if !p.ReadResourceCalled {
|
||||||
t.Fatal("should call refresh")
|
t.Fatal("should call ReadResource")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(statePath); err != nil {
|
if _, err := os.Stat(statePath); err != nil {
|
||||||
|
@ -911,12 +908,10 @@ func TestApply_state(t *testing.T) {
|
||||||
statePath := testStateFile(t, originalState)
|
statePath := testStateFile(t, originalState)
|
||||||
|
|
||||||
p := testProvider()
|
p := testProvider()
|
||||||
p.DiffReturn = &terraform.InstanceDiff{
|
p.PlanResourceChangeResponse = providers.PlanResourceChangeResponse{
|
||||||
Attributes: map[string]*terraform.ResourceAttrDiff{
|
PlannedState: cty.ObjectVal(map[string]cty.Value{
|
||||||
"ami": &terraform.ResourceAttrDiff{
|
"ami": cty.StringVal("bar"),
|
||||||
New: "bar",
|
}),
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui := new(cli.MockUi)
|
ui := new(cli.MockUi)
|
||||||
|
@ -938,16 +933,20 @@ func TestApply_state(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the provider was called with the existing state
|
// Verify that the provider was called with the existing state
|
||||||
actual := strings.TrimSpace(p.DiffState.String())
|
actual := p.PlanResourceChangeRequest.PriorState
|
||||||
expected := strings.TrimSpace(testApplyStateDiffStr)
|
expected := cty.ObjectVal(map[string]cty.Value{
|
||||||
if actual != expected {
|
"id": cty.StringVal("bar"),
|
||||||
t.Fatalf("bad:\n\n%s", actual)
|
})
|
||||||
|
if !expected.RawEquals(actual) {
|
||||||
|
t.Fatalf("wrong prior state during plan\ngot: %#v\nwant: %#v", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
actual = strings.TrimSpace(p.ApplyState.String())
|
actual = p.ApplyResourceChangeRequest.PriorState
|
||||||
expected = strings.TrimSpace(testApplyStateStr)
|
expected = cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"id": cty.StringVal("bar"),
|
||||||
|
})
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("bad:\n\n%s", actual)
|
t.Fatalf("wrong prior state during apply\ngot: %#v\nwant: %#v", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify a new state exists
|
// Verify a new state exists
|
||||||
|
@ -1227,12 +1226,10 @@ func TestApply_backup(t *testing.T) {
|
||||||
backupPath := testTempFile(t)
|
backupPath := testTempFile(t)
|
||||||
|
|
||||||
p := testProvider()
|
p := testProvider()
|
||||||
p.DiffReturn = &terraform.InstanceDiff{
|
p.PlanResourceChangeResponse = providers.PlanResourceChangeResponse{
|
||||||
Attributes: map[string]*terraform.ResourceAttrDiff{
|
PlannedState: cty.ObjectVal(map[string]cty.Value{
|
||||||
"ami": &terraform.ResourceAttrDiff{
|
"ami": cty.StringVal("bar"),
|
||||||
New: "bar",
|
}),
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui := new(cli.MockUi)
|
ui := new(cli.MockUi)
|
||||||
|
@ -1278,12 +1275,10 @@ func TestApply_disableBackup(t *testing.T) {
|
||||||
statePath := testStateFile(t, originalState)
|
statePath := testStateFile(t, originalState)
|
||||||
|
|
||||||
p := testProvider()
|
p := testProvider()
|
||||||
p.DiffReturn = &terraform.InstanceDiff{
|
p.PlanResourceChangeResponse = providers.PlanResourceChangeResponse{
|
||||||
Attributes: map[string]*terraform.ResourceAttrDiff{
|
PlannedState: cty.ObjectVal(map[string]cty.Value{
|
||||||
"ami": &terraform.ResourceAttrDiff{
|
"ami": cty.StringVal("bar"),
|
||||||
New: "bar",
|
}),
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui := new(cli.MockUi)
|
ui := new(cli.MockUi)
|
||||||
|
@ -1306,16 +1301,20 @@ func TestApply_disableBackup(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the provider was called with the existing state
|
// Verify that the provider was called with the existing state
|
||||||
actual := strings.TrimSpace(p.DiffState.String())
|
actual := p.PlanResourceChangeRequest.PriorState
|
||||||
expected := strings.TrimSpace(testApplyDisableBackupStr)
|
expected := cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"id": cty.StringVal("bar"),
|
||||||
|
})
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("bad:\n\n%s", actual)
|
t.Fatalf("wrong prior state during plan\ngot: %#v\nwant: %#v", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
actual = strings.TrimSpace(p.ApplyState.String())
|
actual = p.ApplyResourceChangeRequest.PriorState
|
||||||
expected = strings.TrimSpace(testApplyDisableBackupStateStr)
|
expected = cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"id": cty.StringVal("bar"),
|
||||||
|
})
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
t.Fatalf("bad:\n\n%s", actual)
|
t.Fatalf("wrong prior state during apply\ngot: %#v\nwant: %#v", actual, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify a new state exists
|
// Verify a new state exists
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
variable "foo" {}
|
variable "foo" {}
|
||||||
|
|
||||||
resource "test_instance" "foo" {}
|
output "result" {
|
||||||
|
value = var.foo
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue