From 4e2e3e308b7b08c96177311a8d2eb396076d0ec2 Mon Sep 17 00:00:00 2001 From: Mario Lopez Gallego Date: Thu, 1 Jul 2021 22:42:26 +0200 Subject: [PATCH] fix: improve support for nested value tags in json data (#31) * fix: improve support for nested value tags in json data * fix: AT name --- test/acceptance/features/mockhttp.feature | 27 +++++++++++++++++++++++ value.go | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/test/acceptance/features/mockhttp.feature b/test/acceptance/features/mockhttp.feature index d95ec581..b8f5c88b 100644 --- a/test/acceptance/features/mockhttp.feature +++ b/test/acceptance/features/mockhttp.feature @@ -93,6 +93,33 @@ Feature: HTTP Mock server And the HTTP response body must have the JSON properties | value | test mock response | + @mockhttp + Scenario: Mock request with full configuration and complex tag nesting + Given I store "[UUID]" in context "id" + And I mock the HTTP request at "[CONF:httpMockUrl]" with the JSON + """ + { + "request": { + "method": "POST", + "path": "/test/[CTXT:id]" + }, + "response": { + "status": 201, + "headers": { + "Content-Type": ["application/json"] + }, + "body": "{ \"values\": [ { \"type\": \"blacklist\", \"path\": \"/[CTXT:id]-[CTXT:id]\" } ] }" + } + } + """ + Given the HTTP endpoint "[CONF:httpMockUrl]/test/[CTXT:id]" + When I send a HTTP "POST" request + Then the HTTP status code must be "201" + And the HTTP request headers + | Content-Type | application/json | + And the HTTP response body must have the JSON properties + | values.0.path | /[CTXT:id]-[CTXT:id] | + @mockhttp Scenario: Mock request with timeout Given I store "[UUID]" in context "id" diff --git a/value.go b/value.go index 91cb3a38..a0f0b0c1 100755 --- a/value.go +++ b/value.go @@ -23,6 +23,7 @@ import ( "strconv" "strings" "time" + "unicode" "github.com/google/uuid" ) @@ -213,7 +214,7 @@ func NewComposedTag(s string) Tag { func (t ComposedTag) findSeparators() (separators []separator) { for i, c := range t.s { - if c == '[' { + if c == '[' && unicode.IsUpper(rune(t.s[i+1])) { sep := separator{opener: true, pos: i} separators = append(separators, sep) } else if c == ']' {