Skip to content

Commit

Permalink
fix: improve support for nested value tags in json data (#31)
Browse files Browse the repository at this point in the history
* fix: improve support for nested value tags in json data

* fix: AT name
  • Loading branch information
mariolg authored Jul 1, 2021
1 parent 6b1d615 commit 4e2e3e3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions test/acceptance/features/mockhttp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strconv"
"strings"
"time"
"unicode"

"github.com/google/uuid"
)
Expand Down Expand Up @@ -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 == ']' {
Expand Down

0 comments on commit 4e2e3e3

Please sign in to comment.