-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathorderComment_test.go
114 lines (98 loc) · 2.28 KB
/
orderComment_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
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_AddOrderComments(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 = "[email protected]"
str.FirstName = "Tester"
str.LastName = "Bill"
str.LocalDomain = "localhost25:8080"
str.Logo = "some logo"
str.OauthClientID = 29
str.OauthSecret = "this is secret"
str.RemoteDomain = "www.someCart25.com"
str.State = "GA"
str.StoreName = "testers25 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 odr sdbi.Order
odr.BillingAddress = "133 test st. Dallas, TX"
odr.BillingAddressID = 3
odr.CustomerID = 54
odr.CustomerName = "Bills Cars"
odr.Insurance = 0.0
odr.OrderDate = time.Now()
odr.OrderNumber = "S23433LC456"
odr.OrderType = "Standard"
odr.Pickup = false
odr.ShippingAddress = "133 test st. Dallas, TX"
odr.ShippingAddressID = 44
odr.ShippingHandling = 5.55
odr.Status = "Processing"
odr.StoreID = sid
odr.Subtotal = 141.05
odr.Taxes = 5.27
odr.Total = 146.32
odr.Username = "billybob"
odrsuc, oid := si.AddOrder(&odr)
if !odrsuc || oid == 0 {
t.Fail()
}
var oc sdbi.OrderComment
oc.Comment = "this is cool"
oc.Username = "billybob"
oc.OrderID = oid
ocsuc, ocid := si.AddOrderComments(&oc)
if !ocsuc || ocid == 0 {
t.Fail()
}
var oc2 sdbi.OrderComment
oc2.Comment = "this is way cooler"
oc2.Username = "marymary"
oc2.OrderID = oid
dbi.Close()
ocsuc2, ocid2 := si.AddOrderComments(&oc2)
if !ocsuc2 || ocid2 == 0 {
t.Fail()
}
dbi.Close()
oclist := si.GetOrderCommentList(oid)
fmt.Println("oclist: ", oclist)
if len(*oclist) != 2 {
t.Fail()
}
dssuc := si.DeleteStore(sid)
fmt.Println("delete store in suc: ", dssuc)
if !dssuc {
t.Fail()
}
dbi.Close()
}