-
Notifications
You must be signed in to change notification settings - Fork 2
/
region_test.go
101 lines (85 loc) · 1.83 KB
/
region_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
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_AddRegion(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 str sdbi.Store
str.City = "test vill"
str.Company = "test com"
str.Currency = "USD"
str.Email = "tester@tester.com"
str.FirstName = "Tester"
str.LastName = "Bill"
str.LocalDomain = "localhost9:8080"
str.Logo = "some logo"
str.OauthClientID = 14
str.OauthSecret = "this is secret"
str.RemoteDomain = "www.someCart9.com"
str.State = "GA"
str.StoreName = "testers8 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 rgn sdbi.Region
rgn.Name = "USA"
rgn.RegionCode = "US"
rgn.StoreID = sid
dbi.Close()
rgnsuc, rgnid := si.AddRegion(&rgn)
if !rgnsuc || rgnid == 0 {
t.Fail()
}
rgn.ID = rgnid
rgn.Name = "United States of America"
rgn.RegionCode = "USA"
dbi.Close()
urgnsuc := si.UpdateRegion(&rgn)
if !urgnsuc {
t.Fail()
}
dbi.Close()
frgn := si.GetRegion(rgnid)
fmt.Println("frgn", frgn)
if frgn.RegionCode != rgn.RegionCode {
t.Fail()
}
dbi.Close()
frgnList := si.GetRegionList(sid)
fmt.Println("frgnList", frgnList)
if len(*frgnList) != 1 {
t.Fail()
}
dbi.Close()
dlsuc := si.DeleteRegion(rgnid)
if !dlsuc {
t.Fail()
}
dssuc := si.DeleteStore(sid)
fmt.Println("delete store in customer suc: ", dssuc)
if !dssuc {
t.Fail()
}
dbi.Close()
}