mirror of
https://github.com/hashicorp/terraform.git
synced 2026-06-09 08:58:34 -04:00
Check GetResourceIdentitySchemas diagnostics and return early (#36999)
This commit is contained in:
parent
88da854f34
commit
421fe3580f
4 changed files with 78 additions and 0 deletions
|
|
@ -142,6 +142,11 @@ func (p *GRPCProvider) GetProviderSchema() providers.GetProviderSchemaResponse {
|
|||
}
|
||||
}
|
||||
|
||||
resp.Diagnostics = resp.Diagnostics.Append(convert.ProtoToDiagnostics(identResp.Diagnostics))
|
||||
if resp.Diagnostics.HasErrors() {
|
||||
return resp
|
||||
}
|
||||
|
||||
resp.Provider = convert.ProtoToProviderSchema(protoResp.Provider, nil)
|
||||
if protoResp.ProviderMeta == nil {
|
||||
logger.Debug("No provider meta schema returned")
|
||||
|
|
|
|||
|
|
@ -272,6 +272,40 @@ func TestGRPCProvider_GetSchema_IdentityUnimplemented(t *testing.T) {
|
|||
checkDiags(t, resp.Diagnostics)
|
||||
}
|
||||
|
||||
func TestGRPCProvider_GetSchema_IdentityErrorDiagnostic(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
client := mockproto.NewMockProviderClient(ctrl)
|
||||
|
||||
client.EXPECT().GetSchema(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(providerProtoSchema(), nil)
|
||||
|
||||
client.EXPECT().GetResourceIdentitySchemas(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(&proto.GetResourceIdentitySchemas_Response{
|
||||
Diagnostics: []*proto.Diagnostic{
|
||||
{
|
||||
Severity: proto.Diagnostic_ERROR,
|
||||
Summary: "error summary",
|
||||
Detail: "error detail",
|
||||
},
|
||||
},
|
||||
IdentitySchemas: map[string]*proto.ResourceIdentitySchema{},
|
||||
}, nil)
|
||||
|
||||
p := &GRPCProvider{
|
||||
client: client,
|
||||
}
|
||||
|
||||
resp := p.GetProviderSchema()
|
||||
|
||||
checkDiagsHasError(t, resp.Diagnostics)
|
||||
}
|
||||
|
||||
func TestGRPCProvider_GetResourceIdentitySchemas(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
client := mockproto.NewMockProviderClient(ctrl)
|
||||
|
|
|
|||
|
|
@ -142,6 +142,11 @@ func (p *GRPCProvider) GetProviderSchema() providers.GetProviderSchemaResponse {
|
|||
}
|
||||
}
|
||||
|
||||
resp.Diagnostics = resp.Diagnostics.Append(convert.ProtoToDiagnostics(identResp.Diagnostics))
|
||||
if resp.Diagnostics.HasErrors() {
|
||||
return resp
|
||||
}
|
||||
|
||||
resp.Provider = convert.ProtoToProviderSchema(protoResp.Provider, nil)
|
||||
if protoResp.ProviderMeta == nil {
|
||||
logger.Debug("No provider meta schema returned")
|
||||
|
|
|
|||
|
|
@ -279,6 +279,40 @@ func TestGRPCProvider_GetSchema_IdentityUnimplemented(t *testing.T) {
|
|||
checkDiags(t, resp.Diagnostics)
|
||||
}
|
||||
|
||||
func TestGRPCProvider_GetSchema_IdentityErrorDiagnostic(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
client := mockproto.NewMockProviderClient(ctrl)
|
||||
|
||||
client.EXPECT().GetProviderSchema(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(providerProtoSchema(), nil)
|
||||
|
||||
client.EXPECT().GetResourceIdentitySchemas(
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
gomock.Any(),
|
||||
).Return(&proto.GetResourceIdentitySchemas_Response{
|
||||
Diagnostics: []*proto.Diagnostic{
|
||||
{
|
||||
Severity: proto.Diagnostic_ERROR,
|
||||
Summary: "error summary",
|
||||
Detail: "error detail",
|
||||
},
|
||||
},
|
||||
IdentitySchemas: map[string]*proto.ResourceIdentitySchema{},
|
||||
}, nil)
|
||||
|
||||
p := &GRPCProvider{
|
||||
client: client,
|
||||
}
|
||||
|
||||
resp := p.GetProviderSchema()
|
||||
|
||||
checkDiagsHasError(t, resp.Diagnostics)
|
||||
}
|
||||
|
||||
func TestGRPCProvider_GetResourceIdentitySchemas(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
client := mockproto.NewMockProviderClient(ctrl)
|
||||
|
|
|
|||
Loading…
Reference in a new issue