-
Notifications
You must be signed in to change notification settings - Fork 467
/
Copy pathfate_test.go
93 lines (85 loc) · 2 KB
/
fate_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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package fate_test
import (
"context"
"testing"
"github.com/godcong/chronos"
"github.com/babyname/fate"
"github.com/babyname/fate/config"
)
func init() {
// trait.NewZapFileSugar("fate.log")
}
func TestFate_RunMakeName(t *testing.T) {
born := chronos.New("2020/02/06 15:45").Solar().Time()
last := "张"
cfg := config.DefaultConfig()
cfg.BaguaFilter = true
cfg.ZodiacFilter = true
cfg.SupplyFilter = true
cfg.HardFilter = true
cfg.StrokeMin = 3
cfg.StrokeMax = 24
cfg.Regular = true
cfg.RunInit = false
cfg.FileOutput = config.FileOutput{
OutputMode: config.OutputModeLog,
Path: "name.log",
}
cfg.Database = config.Database{
Host: "localhost",
Port: "3306",
User: "root",
Pwd: "111111",
Name: "fate",
MaxIdleCon: 0,
MaxOpenCon: 0,
Driver: "mysql",
File: "",
Dsn: "",
ShowSQL: false,
ShowExecTime: false,
}
f := fate.NewFate(last, born, fate.ConfigOption(cfg), fate.SexOption(fate.SexGirl))
// f.SetDB(eng)
e := f.MakeName(context.Background())
if e != nil {
t.Fatal(e)
}
}
func TestFate_RunMakeNameWithLocalDatabase(t *testing.T) {
born := chronos.New("2020/02/06 15:45").Solar().Time()
last := "张"
cfg := config.DefaultConfig()
cfg.BaguaFilter = true
cfg.ZodiacFilter = true
cfg.SupplyFilter = true
cfg.HardFilter = true
cfg.StrokeMin = 3
cfg.StrokeMax = 24
cfg.Regular = true
cfg.RunInit = false
cfg.FileOutput = config.FileOutput{
OutputMode: config.OutputModelJSON,
Path: "name.log",
}
cfg.Database = config.Database{
Host: "localhost",
Port: "3306",
User: "root",
Pwd: "111111",
Name: "fate",
MaxIdleCon: 0,
MaxOpenCon: 0,
Driver: "sqlite3",
File: "",
Dsn: "",
ShowSQL: false,
ShowExecTime: false,
}
f := fate.NewFate(last, born, fate.ConfigOption(cfg), fate.SexOption(fate.SexGirl))
// f.SetDB(eng)
e := f.MakeName(context.Background())
if e != nil {
t.Fatal(e)
}
}