Add ability to skip automatic auth method creation (#306)

This is useful if you, for instance, want Terraform to be 100%
responsible for creation of resources (outside of the static ones that
cannot be removed or modified, like u_anon). This will mean using the
recovery mechanism for initial setup, but that isn't an issue once TF
supports that :-)
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-26 23:27:46 -04:00
1 parent 490be8a7e4
commit b53812a5c1
6 files changed
+111 -56

No files matched your search

+9 -1
View File
@@ -180,6 +180,10 @@ type TestControllerOpts struct {
// DefaultPassword is the password used when creating the default account.
DefaultPassword string
// DisableAuthMethodCreation can be set true to disable creating an auth
// method automatically.
DisableAuthMethodCreation bool
// DisableDatabaseCreation can be set true to disable creating a dev
// database
DisableDatabaseCreation bool
@@ -302,7 +306,11 @@ func NewTestController(t *testing.T, opts *TestControllerOpts) *TestController {
t.Fatal(err)
}
} else if !opts.DisableDatabaseCreation {
if err := tc.b.CreateDevDatabase("postgres"); err != nil {
var createOpts []base.Option
if opts.DisableAuthMethodCreation {
createOpts = append(createOpts, base.WithSkipAuthMethodCreation())
}
if err := tc.b.CreateDevDatabase("postgres", createOpts...); err != nil {
t.Fatal(err)
}
}