MCPcopy Index your code
hub / github.com/coder/coder / testSQLDB

Function testSQLDB

coderd/database/migrations/migrate_test.go:97–115  ·  view source on GitHub ↗
(t testing.TB)

Source from the content-addressed store, hash-verified

95}
96
97func testSQLDB(t testing.TB) *sql.DB {
98 t.Helper()
99
100 connection, err := dbtestutil.Open(t)
101 require.NoError(t, err)
102
103 db, err := sql.Open("postgres", connection)
104 require.NoError(t, err)
105 t.Cleanup(func() { _ = db.Close() })
106
107 // dbtestutil.Open automatically runs migrations, but we want to actually test
108 // migration behavior in this package.
109 _, err = db.Exec(`DROP SCHEMA public CASCADE`)
110 require.NoError(t, err)
111 _, err = db.Exec(`CREATE SCHEMA public`)
112 require.NoError(t, err)
113
114 return db
115}
116
117// paralleltest linter doesn't correctly handle table-driven tests (https://github.com/kunwardeep/paralleltest/issues/8)
118// nolint:paralleltest

Calls 6

OpenFunction · 0.92
HelperMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
ExecMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected