mirror of
https://github.com/hashicorp/terraform.git
synced 2026-02-03 20:50:59 -05:00
stacks: ensure an empty plan produces a planned status
This commit is contained in:
parent
dce80d4465
commit
c24699eab7
4 changed files with 95 additions and 0 deletions
|
|
@ -983,6 +983,70 @@ func TestStackChangeProgress(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"no-op plan": {
|
||||
mode: stacks.PlanMode_NORMAL,
|
||||
source: "git::https://example.com/simple.git",
|
||||
store: stacks_testing_provider.NewResourceStoreBuilder().
|
||||
AddResource("resource", cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("resource"),
|
||||
"value": cty.NullVal(cty.String),
|
||||
})).
|
||||
Build(),
|
||||
state: []stackstate.AppliedChange{
|
||||
&stackstate.AppliedChangeComponentInstance{
|
||||
ComponentAddr: mustAbsComponent(t, "component.self"),
|
||||
ComponentInstanceAddr: mustAbsComponentInstance(t, "component.self"),
|
||||
},
|
||||
&stackstate.AppliedChangeResourceInstanceObject{
|
||||
ResourceInstanceObjectAddr: mustAbsResourceInstanceObject(t, "component.self.testing_resource.resource"),
|
||||
NewStateSrc: &states.ResourceInstanceObjectSrc{
|
||||
AttrsJSON: mustMarshalJSONAttrs(map[string]interface{}{
|
||||
"id": "resource",
|
||||
"value": nil,
|
||||
}),
|
||||
Status: states.ObjectReady,
|
||||
},
|
||||
ProviderConfigAddr: mustDefaultRootProvider("testing"),
|
||||
Schema: stacks_testing_provider.TestingResourceSchema,
|
||||
},
|
||||
},
|
||||
want: []*stacks.StackChangeProgress{
|
||||
{
|
||||
Event: &stacks.StackChangeProgress_ComponentInstanceStatus_{
|
||||
ComponentInstanceStatus: &stacks.StackChangeProgress_ComponentInstanceStatus{
|
||||
Addr: &stacks.ComponentInstanceInStackAddr{
|
||||
ComponentAddr: "component.self",
|
||||
ComponentInstanceAddr: "component.self",
|
||||
},
|
||||
Status: stacks.StackChangeProgress_ComponentInstanceStatus_PLANNED,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"empty plan": {
|
||||
mode: stacks.PlanMode_NORMAL,
|
||||
source: "git::https://example.com/empty.git",
|
||||
state: []stackstate.AppliedChange{
|
||||
&stackstate.AppliedChangeComponentInstance{
|
||||
ComponentAddr: mustAbsComponent(t, "component.self"),
|
||||
ComponentInstanceAddr: mustAbsComponentInstance(t, "component.self"),
|
||||
},
|
||||
},
|
||||
want: []*stacks.StackChangeProgress{
|
||||
{
|
||||
Event: &stacks.StackChangeProgress_ComponentInstanceStatus_{
|
||||
ComponentInstanceStatus: &stacks.StackChangeProgress_ComponentInstanceStatus{
|
||||
Addr: &stacks.ComponentInstanceInStackAddr{
|
||||
ComponentAddr: "component.self",
|
||||
ComponentInstanceAddr: "component.self",
|
||||
},
|
||||
Status: stacks.StackChangeProgress_ComponentInstanceStatus_PLANNED,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range tcs {
|
||||
|
|
|
|||
10
internal/rpcapi/testdata/sourcebundle/empty/empty.tf
vendored
Normal file
10
internal/rpcapi/testdata/sourcebundle/empty/empty.tf
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
testing = {
|
||||
source = "hashicorp/testing"
|
||||
version = "0.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Empty by design
|
||||
16
internal/rpcapi/testdata/sourcebundle/empty/empty.tfcomponent.hcl
vendored
Normal file
16
internal/rpcapi/testdata/sourcebundle/empty/empty.tfcomponent.hcl
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
required_providers {
|
||||
testing = {
|
||||
source = "hashicorp/testing"
|
||||
version = "0.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
provider "testing" "default" {}
|
||||
|
||||
component "self" {
|
||||
source = "./"
|
||||
|
||||
providers = {
|
||||
testing = provider.testing.default
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,11 @@
|
|||
"source": "git::https://example.com/simple.git",
|
||||
"local": "simple",
|
||||
"meta": {}
|
||||
},
|
||||
{
|
||||
"source": "git::https://example.com/empty.git",
|
||||
"local": "empty",
|
||||
"meta": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue