-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplugin_test.go
88 lines (74 loc) · 1.63 KB
/
plugin_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
package six910mysql
import (
"fmt"
"testing"
lg "github.com/Ulbora/Level_Logger"
db "github.com/Ulbora/dbinterface"
mdb "github.com/Ulbora/dbinterface_mysql"
sdbi "github.com/Ulbora/six910-database-interface"
)
func TestSix910Mysql_AddPlugin(t *testing.T) {
var mydb mdb.MyDB
mydb.Host = "localhost:3306"
mydb.User = "admin"
mydb.Password = "admin"
mydb.Database = "six910"
var dbi db.Database = &mydb
var sdb Six910Mysql
var l lg.Logger
l.LogLevel = lg.AllLevel
sdb.Log = &l
sdb.DB = dbi
dbi.Connect()
si := sdb.GetNew()
var pi sdbi.Plugins
pi.ActivateURL = "test"
pi.Category = "catalog"
pi.ContactPhone = "123-789-4555"
pi.Developer = "Ulbora Labs LLC"
pi.DeveloperAddress = "atlanta, GA"
pi.Enabled = true
pi.Fee = 0
pi.IsPGW = false
pi.OauthRedirectURL = "/redirect"
pi.PluginName = "Catalog Easy"
dbi.Close()
pisuc, piid := si.AddPlugin(&pi)
if !pisuc || piid == 0 {
t.Fail()
}
pi.ID = piid
pi.ActivateURL = "test2"
pi.Category = "catalog2"
pi.ContactPhone = "123-789-4552"
pi.Developer = "Ulbora Labs LLC2"
pi.DeveloperAddress = "atlanta, GA2"
pi.Enabled = false
pi.Fee = 100.00
pi.IsPGW = true
pi.OauthRedirectURL = "/redirec2t"
pi.PluginName = "Catalog Easy2"
dbi.Close()
upisuc := si.UpdatePlugin(&pi)
if !upisuc {
t.Fail()
}
dbi.Close()
fpi := si.GetPlugin(piid)
fmt.Println("fpi: ", fpi)
if fpi.DeveloperAddress != pi.DeveloperAddress {
t.Fail()
}
dbi.Close()
fpilist := si.GetPluginList(0, 10)
fmt.Println("fpilist:", fpilist)
fmt.Println("fpilist len:", len(*fpilist))
if len(*fpilist) == 0 {
t.Fail()
}
dbi.Close()
dlpi := si.DeletePlugin(piid)
if !dlpi {
t.Fail()
}
}