-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager_all_test.go
77 lines (65 loc) · 1.56 KB
/
manager_all_test.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
74
75
76
77
package ladon_test
import (
"fmt"
"log"
"os"
"sync"
"testing"
. "github.com/ory/ladon"
"github.com/ory/ladon/integration"
. "github.com/ory/ladon/manager/memory"
. "github.com/ory/ladon/manager/sql"
)
var managers = map[string]Manager{}
var migrators = map[string]ManagerMigrator{}
func TestMain(m *testing.M) {
var wg sync.WaitGroup
wg.Add(3)
connectMySQL(&wg)
connectPG(&wg)
connectMEM(&wg)
wg.Wait()
s := m.Run()
integration.KillAll()
os.Exit(s)
}
func connectMEM(wg *sync.WaitGroup) {
defer wg.Done()
managers["memory"] = NewMemoryManager()
}
func connectPG(wg *sync.WaitGroup) {
defer wg.Done()
var db = integration.ConnectToPostgres("ladon")
s := NewSQLManager(db, nil)
if _, err := s.CreateSchemas("", ""); err != nil {
log.Fatalf("Could not create postgres schema: %v", err)
}
managers["postgres"] = s
migrators["postgres"] = &SQLManagerMigrateFromMajor0Minor6ToMajor0Minor7{
DB: db,
SQLManager: s,
}
}
func connectMySQL(wg *sync.WaitGroup) {
defer wg.Done()
var db = integration.ConnectToMySQL()
s := NewSQLManager(db, nil)
if _, err := s.CreateSchemas("", ""); err != nil {
log.Fatalf("Could not create mysql schema: %v", err)
}
managers["mysql"] = s
migrators["mysql"] = &SQLManagerMigrateFromMajor0Minor6ToMajor0Minor7{
DB: db,
SQLManager: s,
}
}
func TestGetErrors(t *testing.T) {
for k, s := range managers {
t.Run("manager="+k, TestHelperGetErrors(s))
}
}
func TestCreateGetDelete(t *testing.T) {
for k, s := range managers {
t.Run(fmt.Sprintf("manager=%s", k), TestHelperCreateGetDelete(s))
}
}