MCPcopy
hub / github.com/ory/keto / createDB

Function createDB

internal/x/dbx/dsn_testutils.go:85–107  ·  view source on GitHub ↗
(t testing.TB, url string, dbName string)

Source from the content-addressed store, hash-verified

83}
84
85func createDB(t testing.TB, url string, dbName string) (err error) {
86 var conn *pop.Connection
87
88 if conn, err = openAndPing(url); err != nil {
89 return fmt.Errorf("failed to connect to %q: %w", url, err)
90 }
91
92 if err := conn.RawQuery("CREATE DATABASE " + dbName).Exec(); err != nil {
93 return fmt.Errorf("failed to create db %q in %q: %w", dbName, url, err)
94 }
95
96 t.Cleanup(func() {
97 if err := conn.RawQuery("DROP DATABASE " + dbName).Exec(); err != nil {
98 t.Logf("could not drop database %q in %q: %v", dbName, url, err)
99 }
100 if err := conn.Close(); err != nil {
101 t.Logf("could not close connection for %q in %q: %v", dbName, url, err)
102 }
103 })
104
105 return
106
107}
108
109func GetDSNs(t testing.TB, debugSqliteOnDisk bool) []*DsnT {
110 dsns := allSqlite(t, debugSqliteOnDisk)

Callers 3

RunMySQLFunction · 0.85
RunPostgresFunction · 0.85
RunCockroachFunction · 0.85

Calls 5

openAndPingFunction · 0.85
ExecMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.45
LogfMethod · 0.45

Tested by

no test coverage detected