@@ -106,55 +106,37 @@ func Test_ApplyTemplate_EachBlockWithCsvTemplatingFunctionAndLargeInteger(t *tes
106
106
func Test_ShouldCreateTemplatingDataPathsFromRequest (t * testing.T ) {
107
107
RegisterTestingT (t )
108
108
109
- actual := templating .NewTemplator ().NewTemplatingData (
110
- & models.RequestDetails {
111
- Scheme : "http" ,
112
- Destination : "test.com" ,
113
- Path : "/foo/bar" ,
114
- },
115
- & models.Literals {},
116
- & models.Variables {},
117
- make (map [string ]string ),
118
- & journal.Journal {},
119
- )
109
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
110
+ Scheme : "http" ,
111
+ Destination : "test.com" ,
112
+ Path : "/foo/bar" ,
113
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
120
114
121
115
Expect (actual .Request .Path ).To (ConsistOf ("foo" , "bar" ))
122
116
}
123
117
124
118
func Test_ShouldCreateTemplatingDataPathsFromRequestWithNoPaths (t * testing.T ) {
125
119
RegisterTestingT (t )
126
120
127
- actual := templating .NewTemplator ().NewTemplatingData (
128
- & models.RequestDetails {
129
- Scheme : "http" ,
130
- Destination : "test.com" ,
131
- },
132
- & models.Literals {},
133
- & models.Variables {},
134
- make (map [string ]string ),
135
- & journal.Journal {},
136
- )
121
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
122
+ Scheme : "http" ,
123
+ Destination : "test.com" ,
124
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
137
125
138
126
Expect (actual .Request .Path ).To (BeEmpty ())
139
127
}
140
128
141
129
func Test_ShouldCreateTemplatingDataQueryParamsFromRequest (t * testing.T ) {
142
130
RegisterTestingT (t )
143
131
144
- actual := templating .NewTemplator ().NewTemplatingData (
145
- & models.RequestDetails {
146
- Scheme : "http" ,
147
- Destination : "test.com" ,
148
- Query : map [string ][]string {
149
- "cheese" : {"1" , "3" },
150
- "ham" : {"2" },
151
- },
132
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
133
+ Scheme : "http" ,
134
+ Destination : "test.com" ,
135
+ Query : map [string ][]string {
136
+ "cheese" : {"1" , "3" },
137
+ "ham" : {"2" },
152
138
},
153
- & models.Literals {},
154
- & models.Variables {},
155
- make (map [string ]string ),
156
- & journal.Journal {},
157
- )
139
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
158
140
159
141
Expect (actual .Request .QueryParam ).To (HaveKeyWithValue ("cheese" , []string {"1" , "3" }))
160
142
Expect (actual .Request .QueryParam ).To (HaveKeyWithValue ("ham" , []string {"2" }))
@@ -164,54 +146,36 @@ func Test_ShouldCreateTemplatingDataQueryParamsFromRequest(t *testing.T) {
164
146
func Test_ShouldCreateTemplatingDataQueryParamsFromRequestWithNoQueryParams (t * testing.T ) {
165
147
RegisterTestingT (t )
166
148
167
- actual := templating .NewTemplator ().NewTemplatingData (
168
- & models.RequestDetails {
169
- Scheme : "http" ,
170
- Destination : "test.com" ,
171
- },
172
- & models.Literals {},
173
- & models.Variables {},
174
- make (map [string ]string ),
175
- & journal.Journal {},
176
- )
149
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
150
+ Scheme : "http" ,
151
+ Destination : "test.com" ,
152
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
177
153
178
154
Expect (actual .Request .QueryParam ).To (BeEmpty ())
179
155
}
180
156
181
157
func Test_ShouldCreateTemplatingDataHttpScheme (t * testing.T ) {
182
158
RegisterTestingT (t )
183
159
184
- actual := templating .NewTemplator ().NewTemplatingData (
185
- & models.RequestDetails {
186
- Scheme : "http" ,
187
- Destination : "test.com" ,
188
- },
189
- & models.Literals {},
190
- & models.Variables {},
191
- make (map [string ]string ),
192
- & journal.Journal {},
193
- )
160
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
161
+ Scheme : "http" ,
162
+ Destination : "test.com" ,
163
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
194
164
195
165
Expect (actual .Request .Scheme ).To (Equal ("http" ))
196
166
}
197
167
198
168
func Test_ShouldCreateTemplatingDataHeaderFromRequest (t * testing.T ) {
199
169
RegisterTestingT (t )
200
170
201
- actual := templating .NewTemplator ().NewTemplatingData (
202
- & models.RequestDetails {
203
- Scheme : "http" ,
204
- Destination : "test.com" ,
205
- Headers : map [string ][]string {
206
- "cheese" : {"1" , "3" },
207
- "ham" : {"2" },
208
- },
171
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
172
+ Scheme : "http" ,
173
+ Destination : "test.com" ,
174
+ Headers : map [string ][]string {
175
+ "cheese" : {"1" , "3" },
176
+ "ham" : {"2" },
209
177
},
210
- & models.Literals {},
211
- & models.Variables {},
212
- make (map [string ]string ),
213
- & journal.Journal {},
214
- )
178
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
215
179
216
180
Expect (actual .Request .Header ).To (HaveKeyWithValue ("cheese" , []string {"1" , "3" }))
217
181
Expect (actual .Request .Header ).To (HaveKeyWithValue ("ham" , []string {"2" }))
@@ -221,16 +185,10 @@ func Test_ShouldCreateTemplatingDataHeaderFromRequest(t *testing.T) {
221
185
func Test_ShouldCreateTemplatingDataHeaderFromRequestWithNoHeader (t * testing.T ) {
222
186
RegisterTestingT (t )
223
187
224
- actual := templating .NewTemplator ().NewTemplatingData (
225
- & models.RequestDetails {
226
- Scheme : "http" ,
227
- Destination : "test.com" ,
228
- },
229
- & models.Literals {},
230
- & models.Variables {},
231
- make (map [string ]string ),
232
- & journal.Journal {},
233
- )
188
+ actual := templating .NewTemplator ().NewTemplatingData (& models.RequestDetails {
189
+ Scheme : "http" ,
190
+ Destination : "test.com" ,
191
+ }, nil , & models.Literals {}, & models.Variables {}, make (map [string ]string ), & journal.Journal {})
234
192
235
193
Expect (actual .Request .Header ).To (BeEmpty ())
236
194
}
@@ -554,16 +512,10 @@ func Test_VarSetToNilInCaseOfInvalidArgsPassed(t *testing.T) {
554
512
},
555
513
}
556
514
557
- actual := templator .NewTemplatingData (
558
- & models.RequestDetails {
559
- Scheme : "http" ,
560
- Destination : "test.com" ,
561
- },
562
- & models.Literals {},
563
- vars ,
564
- make (map [string ]string ),
565
- & journal.Journal {},
566
- )
515
+ actual := templator .NewTemplatingData (& models.RequestDetails {
516
+ Scheme : "http" ,
517
+ Destination : "test.com" ,
518
+ }, nil , & models.Literals {}, vars , make (map [string ]string ), & journal.Journal {})
567
519
568
520
Expect (actual .Vars ["varOne" ]).To (BeNil ())
569
521
@@ -581,15 +533,9 @@ func Test_VarSetToProperValueInCaseOfRequestDetailsPassedAsArgument(t *testing.T
581
533
},
582
534
}
583
535
584
- actual := templator .NewTemplatingData (
585
- & models.RequestDetails {
586
- Path : "/part1/foo,bar" ,
587
- },
588
- & models.Literals {},
589
- vars ,
590
- make (map [string ]string ),
591
- & journal.Journal {},
592
- )
536
+ actual := templator .NewTemplatingData (& models.RequestDetails {
537
+ Path : "/part1/foo,bar" ,
538
+ }, nil , & models.Literals {}, vars , make (map [string ]string ), & journal.Journal {})
593
539
594
540
Expect (actual .Vars ["splitRequestPath" ]).ToNot (BeNil ())
595
541
Expect (len (actual .Vars ["splitRequestPath" ].([]string ))).To (Equal (2 ))
@@ -690,13 +636,13 @@ func Test_ApplyTemplate_Arithmetic_Ops_With_Each_Block(t *testing.T) {
690
636
691
637
template , _ := templator .ParseTemplate (responseBody )
692
638
state := make (map [string ]string )
693
- result , err := templator .RenderTemplate (template , requestDetails , & models.Literals {}, & models.Variables {}, state , & journal.Journal {})
639
+ result , err := templator .RenderTemplate (template , requestDetails , nil , & models.Literals {}, & models.Variables {}, state , & journal.Journal {})
694
640
695
641
Expect (err ).To (BeNil ())
696
642
Expect (result ).To (Equal (` 3.5 9 total: 12.50` ))
697
643
698
644
// Running the second time should produce the same result because each execution has its own context data.
699
- result , err = templator .RenderTemplate (template , requestDetails , & models.Literals {}, & models.Variables {}, state , & journal.Journal {})
645
+ result , err = templator .RenderTemplate (template , requestDetails , nil , & models.Literals {}, & models.Variables {}, state , & journal.Journal {})
700
646
Expect (err ).To (BeNil ())
701
647
Expect (result ).To (Equal (` 3.5 9 total: 12.50` ))
702
648
}
@@ -743,5 +689,5 @@ func ApplyTemplate(requestDetails *models.RequestDetails, state map[string]strin
743
689
744
690
template , err := templator .ParseTemplate (responseBody )
745
691
Expect (err ).To (BeNil ())
746
- return templator .RenderTemplate (template , requestDetails , & models.Literals {}, & models.Variables {}, state , & journal.Journal {})
692
+ return templator .RenderTemplate (template , requestDetails , nil , & models.Literals {}, & models.Variables {}, state , & journal.Journal {})
747
693
}
0 commit comments