fix the rpc diags tests

These weren't quite done, but got lost in the huge PR.
This commit is contained in:
James Bardin 2020-10-28 17:38:01 -04:00
parent 35dfac799e
commit 73474327a0
3 changed files with 26 additions and 12 deletions

View File

@ -12288,7 +12288,12 @@ resource "test_instance" "a" {
p := testProvider("test") p := testProvider("test")
p.PlanResourceChangeFn = testDiffFn 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{ p.GetSchemaReturn = &ProviderSchema{
ResourceTypes: map[string]*configschema.Block{ ResourceTypes: map[string]*configschema.Block{
"test_instance": { "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{ ctx := testContext2(t, &ContextOpts{
Config: m, Config: m,
Providers: map[addrs.Provider]providers.Factory{ Providers: map[addrs.Provider]providers.Factory{
@ -12319,6 +12320,10 @@ resource "test_instance" "a" {
t.Fatal(diags.Err()) t.Fatal(diags.Err())
} }
if len(diags) == 0 {
t.Fatal("expected warnings")
}
for _, d := range diags { for _, d := range diags {
des := d.Description().Summary des := d.Description().Summary
if !strings.Contains(des, "frobble") { if !strings.Contains(des, "frobble") {

View File

@ -6431,7 +6431,12 @@ resource "test_instance" "a" {
}) })
p := testProvider("test") 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{ p.GetSchemaReturn = &ProviderSchema{
ResourceTypes: map[string]*configschema.Block{ ResourceTypes: map[string]*configschema.Block{
"test_instance": { "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{ ctx := testContext2(t, &ContextOpts{
Config: m, Config: m,
Providers: map[addrs.Provider]providers.Factory{ Providers: map[addrs.Provider]providers.Factory{
@ -6457,10 +6458,14 @@ resource "test_instance" "a" {
t.Fatal(diags.Err()) t.Fatal(diags.Err())
} }
if len(diags) == 0 {
t.Fatal("expected warnings")
}
for _, d := range diags { for _, d := range diags {
des := d.Description().Summary des := d.Description().Summary
if !strings.Contains(des, "cats") { if !strings.Contains(des, "frobble") {
t.Fatalf(`expected cats, got %q`, des) t.Fatalf(`expected frobble, got %q`, des)
} }
} }
} }

View File

@ -1831,6 +1831,10 @@ resource "test_instance" "a" {
t.Fatal(diags.Err()) t.Fatal(diags.Err())
} }
if len(diags) == 0 {
t.Fatal("expected warnings")
}
for _, d := range diags { for _, d := range diags {
des := d.Description().Summary des := d.Description().Summary
if !strings.Contains(des, "frobble") { if !strings.Contains(des, "frobble") {