diff --git a/internal/rpcapi/stacks_test.go b/internal/rpcapi/stacks_test.go index 27929800b4..712a015399 100644 --- a/internal/rpcapi/stacks_test.go +++ b/internal/rpcapi/stacks_test.go @@ -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 { diff --git a/internal/rpcapi/testdata/sourcebundle/empty/empty.tf b/internal/rpcapi/testdata/sourcebundle/empty/empty.tf new file mode 100644 index 0000000000..c651097a0f --- /dev/null +++ b/internal/rpcapi/testdata/sourcebundle/empty/empty.tf @@ -0,0 +1,10 @@ +terraform { + required_providers { + testing = { + source = "hashicorp/testing" + version = "0.1.0" + } + } +} + +# Empty by design diff --git a/internal/rpcapi/testdata/sourcebundle/empty/empty.tfcomponent.hcl b/internal/rpcapi/testdata/sourcebundle/empty/empty.tfcomponent.hcl new file mode 100644 index 0000000000..18c62cbcbf --- /dev/null +++ b/internal/rpcapi/testdata/sourcebundle/empty/empty.tfcomponent.hcl @@ -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 + } +} diff --git a/internal/rpcapi/testdata/sourcebundle/terraform-sources.json b/internal/rpcapi/testdata/sourcebundle/terraform-sources.json index 620896e6d5..6421282d51 100644 --- a/internal/rpcapi/testdata/sourcebundle/terraform-sources.json +++ b/internal/rpcapi/testdata/sourcebundle/terraform-sources.json @@ -40,6 +40,11 @@ "source": "git::https://example.com/simple.git", "local": "simple", "meta": {} + }, + { + "source": "git::https://example.com/empty.git", + "local": "empty", + "meta": {} } ] }