-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean_sql.go
73 lines (68 loc) · 2.01 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package x
import (
"testing"
"github.com/gobuffalo/pop/v5"
"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_oauth2_logout_request",
"hydra_oauth2_jti_blacklist",
"hydra_jwk",
"hydra_client",
// Migrations
"hydra_oauth2_authentication_consent_migration",
"hydra_client_migration",
"hydra_oauth2_migration",
"hydra_jwk_migration",
"schema_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())
}
func CleanSQLPop(t *testing.T, c *pop.Connection) {
t.Logf("Cleaning up database: %s", c.Dialect.Name())
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_oauth2_logout_request",
"hydra_oauth2_jti_blacklist",
"hydra_jwk",
"hydra_client",
// Migrations
"hydra_oauth2_authentication_consent_migration",
"hydra_client_migration",
"hydra_oauth2_migration",
"hydra_jwk_migration",
"schema_migration",
} {
if err := c.RawQuery("DROP TABLE IF EXISTS " + tb).Exec(); err != nil {
t.Logf(`Unable to clean up table "%s": %s`, tb, err)
}
}
t.Logf("Successfully cleaned up database: %s", c.Dialect.Name())
}