Skip to content

Commit

Permalink
fixup! Subscriptions: Add batching to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Jul 8, 2024
1 parent c7df459 commit 4e398dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions exchanges/subscription/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func TestExpandTemplates(t *testing.T) {
_, err = List{{Channel: "error3"}}.ExpandTemplates(e)
assert.ErrorContains(t, err, "wrong number of args for String", "Should error correctly with execution error")

_, err = List{{Channel: "non-existent"}}.ExpandTemplates(e)
_, err = List{{Channel: "empty-content", Asset: asset.Spot, Pairs: currency.Pairs{btcusdtPair}}}.ExpandTemplates(e)
assert.ErrorIs(t, err, errNoTemplateContent, "Should error correctly when no content generated")
assert.ErrorContains(t, err, "non-existent", "Should error correctly when no content generated")
assert.ErrorContains(t, err, "empty-content", "Should error correctly when no content generated")

_, err = List{{Channel: "error4", Asset: asset.All}}.ExpandTemplates(e)
assert.ErrorIs(t, err, errAssetRecords, "Should error correctly when invalid number of asset entries")
Expand Down
26 changes: 15 additions & 11 deletions exchanges/subscription/testdata/errors.tmpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{{- if eq .S.Channel "error1" }}
{{/* An asset separator without specific asset*/}}
{{- .AssetSeparator }}
{{- .AssetSeparator }}
{{/* An asset separator without specific asset*/}}
{{- .AssetSeparator }}
{{- .AssetSeparator }}
{{- else if eq .S.Channel "error2" }}
{{/* Expand pairs but not assets, without specific asset */}}
{{- .PairSeparator -}}
{{/* Expand pairs but not assets, without specific asset */}}
{{- .PairSeparator -}}
{{- else if eq .S.Channel "error3" }}
{{/* Runtime error from executing */}}
{{ .S.String 42 }}
{{/* Runtime error from executing */}}
{{ .S.String 42 }}
{{- else if eq .S.Channel "error4" }}
{{/* Incorrect number of asset entries */}}
{{- .AssetSeparator }}
{{/* Incorrect number of asset entries */}}
{{- .AssetSeparator }}
{{- else if eq .S.Channel "error5" }}
{{/* Incorrect number of pair entries */}}
{{- .PairSeparator }}
{{/* Incorrect number of pair entries */}}
{{- .PairSeparator }}
{{- else if eq .S.Channel "empty-content" }}
{{/* Empty response for the pair */}}
{{- .PairSeparator }}
{{- .PairSeparator }}
{{- end -}}

0 comments on commit 4e398dc

Please sign in to comment.