-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzoneZip_test.go
169 lines (141 loc) · 3.18 KB
/
zoneZip_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
166
167
168
169
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_ZoneZip(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 = "localhost17:8080"
str.Logo = "some logo"
str.OauthClientID = 21
str.OauthSecret = "this is secret"
str.RemoteDomain = "www.someCart17.com"
str.State = "GA"
str.StoreName = "testers17 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 ins sdbi.Insurance
ins.Cost = 4.95
ins.MinOrderAmount = 50.00
ins.MaxOrderAmount = 500.00
ins.StoreID = sid
inssuc, insid := si.AddInsurance(&ins)
if !inssuc || insid == 0 {
t.Fail()
}
var rgn sdbi.Region
rgn.Name = "USA"
rgn.RegionCode = "US"
rgn.StoreID = sid
rgnsuc, rgnid := si.AddRegion(&rgn)
if !rgnsuc || rgnid == 0 {
t.Fail()
}
var srgn sdbi.SubRegion
srgn.Name = "Georgia"
srgn.SubRegionCode = "G"
srgn.RegionID = rgnid
srgnsuc, srgnid := si.AddSubRegion(&srgn)
if !srgnsuc || srgnid == 0 {
t.Fail()
}
var sc sdbi.ShippingCarrier
sc.Carrier = "UPS"
sc.Type = "GROUND"
sc.StoreID = sid
scsuc, scid := si.AddShippingCarrier(&sc)
if !scsuc || scid == 0 {
t.Fail()
}
var sm sdbi.ShippingMethod
sm.Cost = 12.95
sm.Handling = 2.50
sm.InsuranceID = insid
sm.MaxOrderAmount = 1000.00
sm.MaxWeight = 100
sm.MinOrderAmount = 1.00
sm.Name = "USP Ground"
sm.RegionID = rgnid
sm.ShippingCarrierID = scid
sm.StoreID = sid
smsuc, smid := si.AddShippingMethod(&sm)
if !smsuc || smid == 0 {
t.Fail()
}
var isr sdbi.IncludedSubRegion
isr.RegionID = rgnid
isr.ShippingMethodID = smid
isr.SubRegionID = srgnid
isrsuc, isrid := si.AddIncludedSubRegion(&isr)
if !isrsuc || isrid == 0 {
t.Fail()
}
var esr sdbi.ExcludedSubRegion
esr.RegionID = rgnid
esr.ShippingMethodID = smid
esr.SubRegionID = srgnid
esrsuc, esrid := si.AddExcludedSubRegion(&esr)
if !esrsuc || esrid == 0 {
t.Fail()
}
var zip sdbi.ZoneZip
zip.ZipCode = "30066"
zip.ExcludedSubRegionID = esrid
zip.IncludedSubRegionID = isrid
dbi.Close()
zipsuc, zipid := si.AddZoneZip(&zip)
if !zipsuc || zipid == 0 {
t.Fail()
}
dbi.Close()
exziplist := si.GetZoneZipListByExclusion(esrid)
fmt.Println("exziplist: ", exziplist)
if len(*exziplist) != 1 {
t.Fail()
}
dbi.Close()
inziplist := si.GetZoneZipListByInclusion(isrid)
fmt.Println("inziplist: ", inziplist)
if len(*inziplist) != 1 {
t.Fail()
}
dbi.Close()
dlzipsuc := si.DeleteZoneZip(zipid)
if !dlzipsuc {
t.Fail()
}
dssuc := si.DeleteStore(sid)
fmt.Println("delete store in customer suc: ", dssuc)
if !dssuc {
t.Fail()
}
dbi.Close()
}