refact(cmd): Encapsulate some functionality on Command and Server

This commit extracts 3 separate pieces of functionality into their own
function/method:

- Extracts the database opening with the intention to have a function
  that performs all that functionality but returns the created database
  object rather than setting it to the Server structure.
- Extracts database validation logic, to provide a common code path for
  upcoming functionality.
- Expose schema manager on the Command struct as well as providing
  common functions to acquire shared lock/close.
This commit is contained in:
Hugo Vieira committed 2022-09-12 17:55:32 +01:00
1 parent 621f8a9ff2
commit 8ab9ffbcac
6 files changed
+117 -51

No files matched your search

+1 -1
View File
@@ -664,7 +664,7 @@ func TestControllerConfig(t testing.TB, ctx context.Context, tc *TestController,
if _, err := schema.MigrateStore(ctx, "postgres", tc.b.DatabaseUrl); err != nil {
t.Fatal(err)
}
if err := tc.b.ConnectToDatabase(tc.ctx, "postgres"); err != nil {
if err := tc.b.OpenAndSetServerDatabase(tc.ctx, "postgres"); err != nil {
t.Fatal(err)
}
if !opts.DisableKmsKeyCreation {