-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_test.go
More file actions
49 lines (37 loc) · 872 Bytes
/
auth_test.go
File metadata and controls
49 lines (37 loc) · 872 Bytes
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
package auth
import (
"context"
"database/sql"
"os"
_ "github.com/mattn/go-sqlite3"
"github.com/yaitoo/sqle"
"github.com/yaitoo/sqle/migrate"
)
func createAuthTest(file string) *Auth {
os.Remove(file)
db, _ := sql.Open("sqlite3", "file:"+file+"?cache=shared&mode=rwc")
// db, _ := sql.Open("sqlite3", "file::memory:")
dbTest := sqle.Open(db)
// dbTest.SetMaxOpenConns(1)
authTest := New(dbTest,
WithPrefix("test_"),
WithJWT("jwt"),
WithAES("aes"),
WithTOTP("Yaitoo", "Test"),
WithDHT("auth:email", "auth:mobile"))
dbTest.NewDHT("auth:email", 0)
dbTest.NewDHT("auth:mobile", 0)
m, err := authTest.CreateMigrator(migrate.WithSuffix(".sqlite"))
if err != nil {
panic(err)
}
err = m.Init(context.Background())
if err != nil {
panic(err)
}
err = m.Migrate(context.Background())
if err != nil {
panic(err)
}
return authTest
}