diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 1a2c4720a..efa3d7d49 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -12288,7 +12288,12 @@ resource "test_instance" "a" { p := testProvider("test") p.PlanResourceChangeFn = testDiffFn - p.ApplyResourceChangeFn = testApplyFn + p.ApplyResourceChangeFn = func(req providers.ApplyResourceChangeRequest) (resp providers.ApplyResourceChangeResponse) { + resp = testApplyFn(req) + resp.Diagnostics = resp.Diagnostics.Append(tfdiags.SimpleWarning("don't frobble")) + return resp + } + p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "test_instance": { @@ -12299,10 +12304,6 @@ resource "test_instance" "a" { }, } - p.ValidateResourceTypeConfigResponse = providers.ValidateResourceTypeConfigResponse{ - Diagnostics: tfdiags.Diagnostics(nil).Append(tfdiags.SimpleWarning("don't frobble")), - } - ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -12319,6 +12320,10 @@ resource "test_instance" "a" { t.Fatal(diags.Err()) } + if len(diags) == 0 { + t.Fatal("expected warnings") + } + for _, d := range diags { des := d.Description().Summary if !strings.Contains(des, "frobble") { diff --git a/terraform/context_plan_test.go b/terraform/context_plan_test.go index 33d0c091a..be7fda7ef 100644 --- a/terraform/context_plan_test.go +++ b/terraform/context_plan_test.go @@ -6431,7 +6431,12 @@ resource "test_instance" "a" { }) p := testProvider("test") - p.PlanResourceChangeFn = testDiffFn + p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse { + resp := testDiffFn(req) + resp.Diagnostics = resp.Diagnostics.Append(tfdiags.SimpleWarning("don't frobble")) + return resp + } + p.GetSchemaReturn = &ProviderSchema{ ResourceTypes: map[string]*configschema.Block{ "test_instance": { @@ -6442,10 +6447,6 @@ resource "test_instance" "a" { }, } - p.ValidateResourceTypeConfigResponse = providers.ValidateResourceTypeConfigResponse{ - Diagnostics: tfdiags.Diagnostics(nil).Append(tfdiags.SimpleWarning("don't herd cats")), - } - ctx := testContext2(t, &ContextOpts{ Config: m, Providers: map[addrs.Provider]providers.Factory{ @@ -6457,10 +6458,14 @@ resource "test_instance" "a" { t.Fatal(diags.Err()) } + if len(diags) == 0 { + t.Fatal("expected warnings") + } + for _, d := range diags { des := d.Description().Summary - if !strings.Contains(des, "cats") { - t.Fatalf(`expected cats, got %q`, des) + if !strings.Contains(des, "frobble") { + t.Fatalf(`expected frobble, got %q`, des) } } } diff --git a/terraform/context_validate_test.go b/terraform/context_validate_test.go index 4f5f45a9f..e35803464 100644 --- a/terraform/context_validate_test.go +++ b/terraform/context_validate_test.go @@ -1831,6 +1831,10 @@ resource "test_instance" "a" { t.Fatal(diags.Err()) } + if len(diags) == 0 { + t.Fatal("expected warnings") + } + for _, d := range diags { des := d.Description().Summary if !strings.Contains(des, "frobble") {