mirror of
https://github.com/hashicorp/terraform.git
synced 2026-06-09 08:58:34 -04:00
stacks: add test case
This commit is contained in:
parent
9f8ab0450c
commit
bf5037fa05
1 changed files with 40 additions and 0 deletions
|
|
@ -375,3 +375,43 @@ Terraform uses references to decide a suitable order for performing operations,
|
|||
t.Errorf("wrong diagnostics\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate_missing_provider_from_lockfile(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
cfg := loadMainBundleConfigForTest(t, filepath.Join("with-single-input", "input-from-component"))
|
||||
lock := depsfile.NewLocks()
|
||||
|
||||
diags := Validate(ctx, &ValidateRequest{
|
||||
Config: cfg,
|
||||
ProviderFactories: map[addrs.Provider]providers.Factory{
|
||||
// We support both hashicorp/testing and
|
||||
// terraform.io/builtin/testing as providers. This lets us
|
||||
// test the provider aliasing feature. Both providers
|
||||
// support the same set of resources and data sources.
|
||||
addrs.NewDefaultProvider("testing"): func() (providers.Interface, error) {
|
||||
return stacks_testing_provider.NewProvider(), nil
|
||||
},
|
||||
addrs.NewBuiltInProvider("testing"): func() (providers.Interface, error) {
|
||||
return stacks_testing_provider.NewProvider(), nil
|
||||
},
|
||||
},
|
||||
DependencyLocks: *lock,
|
||||
})
|
||||
|
||||
if len(diags) != 1 {
|
||||
t.Fatalf("expected exactly one diagnostic, got %d", len(diags))
|
||||
}
|
||||
|
||||
diag := diags[0]
|
||||
if diag.Severity() != tfdiags.Error {
|
||||
t.Fatalf("expected error diagnostic, got %s", diag.Severity())
|
||||
}
|
||||
|
||||
if diag.Description().Summary != "Provider missing from lockfile" {
|
||||
t.Fatalf("expected diagnostic summary 'Provider missing from lockfile', got %q", diag.Description().Summary)
|
||||
}
|
||||
|
||||
if diag.Description().Detail != "Provider \"registry.terraform.io/hashicorp/testing\" is not in the lockfile. This provider must be in the lockfile to be used in the configuration. Please run `tfstacks provider lock` to update the lockfile and run this operation again with an updated configuration." {
|
||||
t.Fatalf("expected diagnostic detail to be a specific message, got %q", diag.Description().Detail)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue