update terraform with PrepareProviderConfig

Change the call sites and update the MockProvider. No core behavior is
changed yet.
This commit is contained in:
James Bardin 2018-10-17 21:29:15 -04:00
parent 3bdd3b2a6e
commit 155f899249
3 changed files with 15 additions and 15 deletions

View File

@ -603,7 +603,7 @@ func TestContext2Validate_providerConfig_bad(t *testing.T) {
),
})
p.ValidateProviderConfigResponse = providers.ValidateProviderConfigResponse{
p.PrepareProviderConfigResponse = providers.PrepareProviderConfigResponse{
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
}
@ -641,7 +641,7 @@ func TestContext2Validate_providerConfig_badEmpty(t *testing.T) {
),
})
p.ValidateProviderConfigResponse = providers.ValidateProviderConfigResponse{
p.PrepareProviderConfigResponse = providers.PrepareProviderConfigResponse{
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
}
@ -709,7 +709,7 @@ func TestContext2Validate_provisionerConfig_bad(t *testing.T) {
},
})
p.ValidateProviderConfigResponse = providers.ValidateProviderConfigResponse{
p.PrepareProviderConfigResponse = providers.PrepareProviderConfigResponse{
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
}

View File

@ -98,11 +98,11 @@ func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error) {
return nil, diags.NonFatalErr()
}
req := providers.ValidateProviderConfigRequest{
req := providers.PrepareProviderConfigRequest{
Config: configVal,
}
validateResp := provider.ValidateProviderConfig(req)
validateResp := provider.PrepareProviderConfig(req)
diags = diags.Append(validateResp.Diagnostics)
return nil, diags.NonFatalErr()

View File

@ -26,10 +26,10 @@ type MockProvider struct {
GetSchemaCalled bool
GetSchemaReturn *ProviderSchema // This is using ProviderSchema directly rather than providers.GetSchemaResponse for compatibility with old tests
ValidateProviderConfigCalled bool
ValidateProviderConfigResponse providers.ValidateProviderConfigResponse
ValidateProviderConfigRequest providers.ValidateProviderConfigRequest
ValidateProviderConfigFn func(providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse
PrepareProviderConfigCalled bool
PrepareProviderConfigResponse providers.PrepareProviderConfigResponse
PrepareProviderConfigRequest providers.PrepareProviderConfigRequest
PrepareProviderConfigFn func(providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse
ValidateResourceTypeConfigCalled bool
ValidateResourceTypeConfigTypeName string
@ -133,16 +133,16 @@ func (p *MockProvider) getSchema() providers.GetSchemaResponse {
return ret
}
func (p *MockProvider) ValidateProviderConfig(r providers.ValidateProviderConfigRequest) providers.ValidateProviderConfigResponse {
func (p *MockProvider) PrepareProviderConfig(r providers.PrepareProviderConfigRequest) providers.PrepareProviderConfigResponse {
p.Lock()
defer p.Unlock()
p.ValidateProviderConfigCalled = true
p.ValidateProviderConfigRequest = r
if p.ValidateProviderConfigFn != nil {
return p.ValidateProviderConfigFn(r)
p.PrepareProviderConfigCalled = true
p.PrepareProviderConfigRequest = r
if p.PrepareProviderConfigFn != nil {
return p.PrepareProviderConfigFn(r)
}
return p.ValidateProviderConfigResponse
return p.PrepareProviderConfigResponse
}
func (p *MockProvider) ValidateResourceTypeConfig(r providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {