Skip to content

Commit b8e7790

Browse files
committed
remove redundant plan test
1 parent afaa122 commit b8e7790

File tree

2 files changed

+5
-75
lines changed

2 files changed

+5
-75
lines changed

internal/terraform/context_apply2_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,11 +4072,6 @@ func TestContext2Apply_excludeListResources(t *testing.T) {
40724072
t.Fatalf("unexpected diagnostics: %s", diags.ErrWithWarnings())
40734073
}
40744074

4075-
_, diags = ctx.Apply(plan, mod, nil)
4076-
if diags.HasErrors() {
4077-
t.Fatal("expected error")
4078-
}
4079-
40804075
// Check that the plan does not include the list resource
40814076
if len(plan.Changes.Resources) != 1 {
40824077
t.Fatalf("expected 1 resource in the plan, got %d", len(plan.Changes.Resources))
@@ -4086,4 +4081,9 @@ func TestContext2Apply_excludeListResources(t *testing.T) {
40864081
if listExecuted {
40874082
t.Fatal("expected list resource to not be executed, but it was")
40884083
}
4084+
4085+
_, diags = ctx.Apply(plan, mod, nil)
4086+
if diags.HasErrors() {
4087+
t.Fatal("expected error")
4088+
}
40894089
}

internal/terraform/context_plan2_test.go

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/hashicorp/terraform/internal/addrs"
2424
"github.com/hashicorp/terraform/internal/checks"
2525
"github.com/hashicorp/terraform/internal/configs/configschema"
26-
"github.com/hashicorp/terraform/internal/grpcwrap"
2726
"github.com/hashicorp/terraform/internal/lang/marks"
2827
"github.com/hashicorp/terraform/internal/plans"
2928
"github.com/hashicorp/terraform/internal/providers"
@@ -6980,72 +6979,3 @@ func TestContext2Plan_resourceNamedList(t *testing.T) {
69806979
})
69816980
}
69826981
}
6983-
6984-
func TestContext2Plan_excludeListResources(t *testing.T) {
6985-
mod := testModuleInline(t, map[string]string{
6986-
"main.tf": `
6987-
terraform {
6988-
required_providers {
6989-
test = {
6990-
source = "hashicorp/test"
6991-
version = "1.0.0"
6992-
}
6993-
}
6994-
}
6995-
6996-
resource "test_resource" "test1" {
6997-
provider = test
6998-
instance_type = "t2.micro"
6999-
}
7000-
`,
7001-
"main.tfquery.hcl": `
7002-
list "test_resource" "test2" {
7003-
provider = test
7004-
}
7005-
`,
7006-
})
7007-
7008-
providerAddr := addrs.NewDefaultProvider("test")
7009-
provider := testProvider("test")
7010-
provider.ConfigureProvider(providers.ConfigureProviderRequest{})
7011-
provider.GetProviderSchemaResponse = getTestProviderResponse()
7012-
var listExecuted bool
7013-
provider.ListResourceFn = func(request providers.ListResourceRequest) providers.ListResourceResponse {
7014-
listExecuted = true
7015-
return providers.ListResourceResponse{
7016-
Result: cty.ObjectVal(map[string]cty.Value{
7017-
"data": cty.EmptyTupleVal,
7018-
"config": request.Config,
7019-
}),
7020-
}
7021-
}
7022-
7023-
// Create a mock gRPC provider
7024-
grpcProvider, close := grpcwrap.NewGRPCProvider(t, provider)
7025-
defer close()
7026-
7027-
ctx, diags := NewContext(&ContextOpts{
7028-
Providers: map[addrs.Provider]providers.Factory{
7029-
providerAddr: testProviderFuncFixed(grpcProvider),
7030-
},
7031-
})
7032-
tfdiags.AssertNoDiagnostics(t, diags)
7033-
7034-
plan, diags := ctx.Plan(mod, states.NewState(), &PlanOpts{
7035-
Mode: plans.NormalMode,
7036-
SetVariables: testInputValuesUnset(mod.Module.Variables),
7037-
})
7038-
if diags.HasErrors() {
7039-
t.Fatalf("unexpected diagnostics: %s", diags.ErrWithWarnings())
7040-
}
7041-
7042-
// Check that the plan does not include the list resource
7043-
if len(plan.Changes.Resources) != 1 {
7044-
t.Fatalf("expected 1 resource in the plan, got %d", len(plan.Changes.Resources))
7045-
}
7046-
7047-
// Check that the list resource was not executed
7048-
if listExecuted {
7049-
t.Fatal("expected list resource to not be executed, but it was")
7050-
}
7051-
}

0 commit comments

Comments
 (0)