update diagnostic message

pull/34683/head
James Bardin 2 years ago
parent bac2f892c6
commit 336145c384

@ -571,7 +571,7 @@ func checkForUnknownFunctionDiags(diags hcl.Diagnostics) hcl.Diagnostics {
// no other functions exist for this provider, so hint that the user may
// need to include it in the configuration.
d.Detail = fmt.Sprintf(`There is no function named "%s%s". The provider %q may need to be added to the required_providers block within the module configuration.`, namespace, name, namespaceParts[1])
d.Detail = fmt.Sprintf(`There is no function named "%s%s". Ensure that provider name %q is declared in this module's required_providers block, and that this provider offers a function named %q.`, namespace, name, namespaceParts[1], name)
}
return diags

@ -256,7 +256,7 @@ func TestContext2Validate_providerFunctionDiagnostics(t *testing.T) {
output "first" {
value = provider::test::echo("input")
}`}),
`The provider "test" may need to be added to the required_providers block within the module configuration.`,
`Ensure that provider name "test" is declared in this module's required_providers block, and that this provider offers a function named "echo"`,
},
{
"invalid namespace",

@ -2631,7 +2631,7 @@ output "result" {
if !diags.HasErrors() {
t.Fatal("unexpected success")
}
if got, want := diags.Err().Error(), "Call to unknown function: There is no function named \"cout_e\" in namespace provider::test::."; !strings.Contains(got, want) {
if got, want := diags.Err().Error(), `Unknown provider function: The function "cout_e" is not available from the provider "test"`; !strings.Contains(got, want) {
t.Errorf("wrong error message\nwant substring: %s\ngot: %s", want, got)
}
@ -2666,7 +2666,7 @@ output "result" {
if !diags.HasErrors() {
t.Fatal("unexpected success")
}
if got, want := diags.Err().Error(), "Call to unknown function: There are no functions in namespace \"provider::toast::\"."; !strings.Contains(got, want) {
if got, want := diags.Err().Error(), `Unknown provider function: There is no function named "provider::toast::count_e`; !strings.Contains(got, want) {
t.Errorf("wrong error message\nwant substring: %s\ngot: %s", want, got)
}
})
@ -2870,7 +2870,7 @@ output "result" {
}
// Module author must declare a provider requirement in order to
// import a provider's functions.
if got, want := diags.Err().Error(), "Call to unknown function: There are no functions in namespace \"provider::test::\"."; !strings.Contains(got, want) {
if got, want := diags.Err().Error(), `Unknown provider function: There is no function named "provider::test::count_e"`; !strings.Contains(got, want) {
t.Errorf("wrong error message\nwant substring: %s\ngot: %s", want, got)
}
})

Loading…
Cancel
Save