-
Notifications
You must be signed in to change notification settings - Fork 2
/
storePlugin_test.go
165 lines (143 loc) · 3.26 KB
/
storePlugin_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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package six910mysql
import (
"fmt"
"testing"
"time"
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_AddStorePlugin(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"
pisuc, piid := si.AddPlugin(&pi)
if !pisuc || piid == 0 {
t.Fail()
}
var str sdbi.Store
str.City = "test vill"
str.Company = "test com"
str.Currency = "USD"
str.Email = "[email protected]"
str.FirstName = "Tester"
str.LastName = "Bill"
str.LocalDomain = "localhost18:8080"
str.Logo = "some logo"
str.OauthClientID = 22
str.OauthSecret = "this is secret"
str.RemoteDomain = "www.someCart18.com"
str.State = "GA"
str.StoreName = "testers18 fantastic store"
str.StoreSlogan = "we test for less"
str.Zip = "30036"
str.Enabled = false
suc, sid := si.AddStore(&str)
if !suc || sid == 0 {
t.Fail()
}
var spi sdbi.StorePlugins
spi.APIKey = "123"
spi.ActivateURL = "/test"
spi.Active = false
spi.Category = "inventory"
spi.IframeURL = "/iframe"
spi.IsPGW = true
spi.MenuIconURL = "/menu"
spi.MenuTitle = "somemenu"
spi.OauthClientID = 334
spi.OauthRedirectURL = "/redirect"
spi.OauthSecret = "123456kjh"
spi.PluginID = piid
spi.PluginName = "the great plugin"
spi.StoreID = sid
dbi.Close()
spisuc, spiid := si.AddStorePlugin(&spi)
if !spisuc || spiid == 0 {
t.Fail()
}
dbi.Close()
fspi1 := si.GetStorePlugin(spiid)
fmt.Println("fspi1: ", fspi1)
if fspi1.IframeURL != spi.IframeURL {
t.Fail()
}
spi.ID = spiid
spi.APIKey = "1235"
spi.ActivateURL = "/test5"
spi.Active = true
spi.IframeURL = "/iframe5"
spi.MenuIconURL = "/menu5"
spi.MenuTitle = "somemenu5"
spi.OauthClientID = 3345
spi.OauthRedirectURL = "/redirect5"
spi.OauthSecret = "123456kjh5"
dbi.Close()
uspisuc := si.UpdateStorePlugin(&spi)
if !uspisuc {
t.Fail()
}
spi.APIKey = "12357"
spi.ActivateURL = "/test57"
spi.Active = true
spi.IframeURL = "/iframe57"
spi.MenuIconURL = "/menu57"
spi.MenuTitle = "somemenu57"
spi.OauthClientID = 33457
spi.OauthRedirectURL = "/redirect57"
spi.OauthSecret = "123456kjh57"
spi.RekeyDate = time.Now()
spi.RekeyTryCount = 1
uspisuc2 := si.UpdateStorePlugin(&spi)
if !uspisuc2 {
t.Fail()
}
fspi := si.GetStorePlugin(spiid)
fmt.Println("fspi: ", fspi)
if fspi.IframeURL != spi.IframeURL {
t.Fail()
}
dbi.Close()
fspilist := si.GetStorePluginList(sid)
fmt.Println("fspilist: ", fspilist)
if len(*fspilist) != 1 {
t.Fail()
}
dbi.Close()
dlspisuc := si.DeleteStorePlugin(spiid)
if !dlspisuc {
t.Fail()
}
dlpi := si.DeletePlugin(piid)
if !dlpi {
t.Fail()
}
dssuc := si.DeleteStore(sid)
fmt.Println("delete store in customer suc: ", dssuc)
if !dssuc {
t.Fail()
}
dbi.Close()
}