Skip to content

Commit

Permalink
Add test for looking up large int in a csv within a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tommysitu committed Mar 9, 2024
1 parent 8eadce7 commit 3b27e96
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core/templating/templating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ func Test_ApplyTemplate_EachBlockWithCsvTemplatingFunction(t *testing.T) {
Expect(template).To(Equal(`55 | 56 | `))
}

func Test_ApplyTemplate_EachBlockWithCsvTemplatingFunctionAndLargeInteger(t *testing.T) {
RegisterTestingT(t)

template, err := ApplyTemplate(&models.RequestDetails{
Body: `{"ids": [1, 5553686208582]}`,
}, make(map[string]string), `{{#each (Request.Body 'jsonpath' '$.ids') }}{{csv 'test-csv2' 'Id' this 'Marks'}} | {{/each}}`)

Expect(err).To(BeNil())
Expect(template).To(Equal(`55 | 66 | `))
}

func Test_ShouldCreateTemplatingDataPathsFromRequest(t *testing.T) {
RegisterTestingT(t)

Expand Down Expand Up @@ -555,7 +566,7 @@ func toInterfaceSlice(arguments []string) []interface{} {
func ApplyTemplate(requestDetails *models.RequestDetails, state map[string]string, responseBody string) (string, error) {
templator := templating.NewTemplator()
dataSource1, _ := templating.NewCsvDataSource("test-csv1", "id,name,marks\n1,Test1,55\n2,Test2,56\n*,Dummy,ABSENT")
dataSource2, _ := templating.NewCsvDataSource("test-csv2", "id,name,marks\n1,Test1,55\n2,Test2,56\n")
dataSource2, _ := templating.NewCsvDataSource("test-csv2", "id,name,marks\n1,Test1,55\n2,Test2,56\n5553686208582,Test3,66\n")
templator.TemplateHelper.TemplateDataSource.SetDataSource("test-csv1", dataSource1)
templator.TemplateHelper.TemplateDataSource.SetDataSource("test-csv2", dataSource2)

Expand Down

0 comments on commit 3b27e96

Please sign in to comment.