Merge pull request #26743 from hashicorp/jbardin/fix-diags-tests

fix the rpc diags tests
This commit is contained in:
James Bardin 2020-10-28 17:45:22 -04:00 committed by GitHub
commit c7dd310988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 12 deletions

View File

@ -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") {

View File

@ -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)
}
}
}

View File

@ -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") {