-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(consul,service_tags): Support escaped comma (#401)
* feat(service_tags): Support escaped comma * test(bridge): Adds test for escaped comma in tags + fix types_test.go tests
- Loading branch information
Showing
4 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package bridge | ||
|
||
import ( | ||
"sort" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestEscapedComma(t *testing.T) { | ||
cases := []struct { | ||
Tag string | ||
Expected []string | ||
}{ | ||
{ | ||
Tag: "", | ||
Expected: []string{}, | ||
}, | ||
{ | ||
Tag: "foobar", | ||
Expected: []string{"foobar"}, | ||
}, | ||
{ | ||
Tag: "foo,bar", | ||
Expected: []string{"foo", "bar"}, | ||
}, | ||
{ | ||
Tag: "foo\\,bar", | ||
Expected: []string{"foo,bar"}, | ||
}, | ||
{ | ||
Tag: "foo,bar\\,baz", | ||
Expected: []string{"foo", "bar,baz"}, | ||
}, | ||
{ | ||
Tag: "\\,foobar\\,", | ||
Expected: []string{",foobar,"}, | ||
}, | ||
{ | ||
Tag: ",,,,foo,,,bar,,,", | ||
Expected: []string{"foo", "bar"}, | ||
}, | ||
{ | ||
Tag: ",,,,", | ||
Expected: []string{}, | ||
}, | ||
{ | ||
Tag: ",,\\,,", | ||
Expected: []string{","}, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
results := recParseEscapedComma(c.Tag) | ||
sort.Strings(c.Expected) | ||
sort.Strings(results) | ||
assert.EqualValues(t, c.Expected, results) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters