-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_test.go
214 lines (199 loc) · 4.92 KB
/
setup_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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package menubotlib_test
import (
"database/sql"
mb "github.com/JeremyJalpha/MenuBotLib"
_ "modernc.org/sqlite"
)
const (
catalogueID string = "Pig"
//pricelistPreamble = "All fertilizer quoted per gram."
grdngSlctnPreamble = "Gardening:"
ktcnSlctnPreamble = "Kitchen:"
diySlctnPreamble = "DIY:"
tchSlctnPreamble = "Tech:"
edblsSlctnPreamble = "Edibles:"
crtCustomerOrderTbl = `
CREATE TABLE customerorder (
orderID INTEGER PRIMARY KEY,
cellnumber varchar(15) NOT NULL,
catalogueID varchar(30) NOT NULL,
orderitems varchar(255) NOT NULL,
orderTotal INTEGER DEFAULT 0,
ispaid BOOLEAN DEFAULT 0,
datetimedelivered DATETIME,
isclosed BOOLEAN DEFAULT 0
);`
crtCatalogueItemTbl = `
CREATE TABLE catalogueitem (
catalogueID varchar(255) NOT NULL,
catalogueitemID INTEGER NOT NULL,
"selection" varchar(255) NULL,
"item" varchar(255) NULL,
"options" varchar(255) NULL,
#Type #TypeEnum,
CONSTRAINT catalogueitem_pk PRIMARY KEY (catalogueID, catalogueitemID)
);`
)
func setupTestDBInstance() (*sql.DB, error) {
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
return nil, err
}
return db, nil
}
var GardeningSelection = mb.CatalogueSelection{
Preamble: grdngSlctnPreamble,
Items: []mb.CatalogueItem{
{
CatalogueID: catalogueID,
CatalogueItemID: 1,
Selection: grdngSlctnPreamble,
Item: "Denitrified fertilizer",
Options: []string{
"5g @ R110 p.g.",
"10g @ R90 p.g.",
},
#Type: mb.WeightItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 2,
Selection: grdngSlctnPreamble,
Item: "Dehydrogenated water",
Options: []string{
"5g @ R140 p.g.",
"10g @ R120 p.g.",
},
#Type: mb.WeightItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 3,
Selection: grdngSlctnPreamble,
Item: "Decarbonized soil",
Options: []string{
"5g @ R150 p.g.",
"10g @ R130 p.g.",
},
#Type: mb.WeightItem,
},
},
}
var KitchenSelection = mb.CatalogueSelection{
Preamble: ktcnSlctnPreamble,
Items: []mb.CatalogueItem{
{
CatalogueID: catalogueID,
CatalogueItemID: 4,
Item: "DIY ready cake mix",
Selection: ktcnSlctnPreamble,
Options: []string{
"5g @ R180 p.g.",
"10g @ R160 p.g.",
},
#Type: mb.WeightItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 5,
Selection: ktcnSlctnPreamble,
Item: "Sugarless Sugar",
Options: []string{
"5g @ R210 p.g.",
"10g @ R190 p.g.",
},
#Type: mb.WeightItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 6,
Selection: ktcnSlctnPreamble,
Item: "Burnt bread crumbs",
Options: []string{
"5g @ R250 p.g.",
"10g @ R230 p.g.",
},
#Type: mb.WeightItem,
},
},
}
var DIYSelection = mb.CatalogueSelection{
Preamble: diySlctnPreamble,
Items: []mb.CatalogueItem{
{
CatalogueID: catalogueID,
CatalogueItemID: 7,
Selection: diySlctnPreamble,
Item: "Bristleless Broom",
Options: []string{
"Vacuumless roomba version @ R650",
"Bristled handleless version @ R650",
"Floppy handled kinetic version @ R650",
},
#Type: mb.SingleItem,
},
},
}
var TechSelection = mb.CatalogueSelection{
Preamble: tchSlctnPreamble,
Items: []mb.CatalogueItem{
{
CatalogueID: catalogueID,
CatalogueItemID: 8,
Selection: tchSlctnPreamble,
Item: "Macless Apple @ R100 each",
Options: nil,
#Type: mb.SingleItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 9,
Selection: tchSlctnPreamble,
Item: "Unchargeable cellphone @ R150 each",
Options: nil,
#Type: mb.SingleItem,
},
},
}
var EdiblesSelection = mb.CatalogueSelection{
Preamble: edblsSlctnPreamble,
Items: []mb.CatalogueItem{
{
CatalogueID: catalogueID,
CatalogueItemID: 10,
Selection: edblsSlctnPreamble,
Item: "Fruit toffees - 400mg",
Options: []string{
"10-Pack @ R200",
},
#Type: mb.SingleItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 11,
Selection: edblsSlctnPreamble,
Item: "Sour space strips - 400mg",
Options: []string{
"10-Pack @ R180",
},
#Type: mb.SingleItem,
},
{
CatalogueID: catalogueID,
CatalogueItemID: 12,
Selection: edblsSlctnPreamble,
Item: "Space bud treats - 240mg",
Options: []string{
"3-Pack @ R200",
},
#Type: mb.SingleItem,
},
},
}
var selections = []mb.CatalogueSelection{
GardeningSelection,
KitchenSelection,
DIYSelection,
TechSelection,
EdiblesSelection,
}