-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_sql.go
36 lines (33 loc) · 950 Bytes
/
clean_sql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package x
import (
"testing"
"github.com/jmoiron/sqlx"
)
func CleanSQL(t *testing.T, db *sqlx.DB) {
t.Logf("Cleaning up database: %s", db.DriverName())
for _, tb := range []string{
"hydra_oauth2_access",
"hydra_oauth2_refresh",
"hydra_oauth2_code",
"hydra_oauth2_oidc",
"hydra_oauth2_pkce",
"hydra_oauth2_consent_request_handled",
"hydra_oauth2_consent_request",
"hydra_oauth2_authentication_request_handled",
"hydra_oauth2_authentication_request",
"hydra_oauth2_authentication_session",
"hydra_oauth2_obfuscated_authentication_session",
"hydra_jwk",
"hydra_client",
// Migrations
"hydra_oauth2_authentication_consent_migration",
"hydra_client_migration",
"hydra_oauth2_migration",
"hydra_jwk_migration",
} {
if _, err := db.Exec("DROP TABLE IF EXISTS " + tb); err != nil {
t.Logf(`Unable to clean up table "%s": %s`, tb, err)
}
}
t.Logf("Successfully cleaned up database: %s", db.DriverName())
}