This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDI-1725:issue1234: RFC: Arbitrary namespace separator
- Loading branch information
1 parent
549cf59
commit f8a9910
Showing
5 changed files
with
173 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// +build small | ||
|
||
package core | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
. "github.com/smartystreets/goconvey/convey" | ||
) | ||
|
||
func TestMetricSeparator(t *testing.T) { | ||
tc := getTestCases() | ||
Convey("Test namespace separator", t, func() { | ||
for _, c := range tc { | ||
Convey("namespace "+c.input.String(), func() { | ||
firstChar := getFirstChar(c.input.String()) | ||
So(firstChar, ShouldEqual, c.expected) | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
// GetFirstChar returns the first character from the input string. | ||
func getFirstChar(s string) string { | ||
firstChar := "" | ||
for _, r := range s { | ||
firstChar = fmt.Sprintf("%c", r) | ||
break | ||
} | ||
return firstChar | ||
} | ||
|
||
type testCase struct { | ||
input Namespace | ||
expected string | ||
} | ||
|
||
// getTestCases tests the namespace and nsPriorityList. | ||
func getTestCases() []testCase { | ||
tcs := []testCase{ | ||
testCase{ | ||
input: NewNamespace("/hello", "/world"), | ||
expected: "|", | ||
}, | ||
testCase{ | ||
input: NewNamespace("/hello", "/world", "corporate-service|"), | ||
expected: "%", | ||
}, | ||
testCase{ | ||
input: NewNamespace("/hello", "/world", "|corporate-service%", "monday_to_friday"), | ||
expected: ":", | ||
}, | ||
testCase{ | ||
input: NewNamespace("/hello", "/world", "corporate-service/%|-_^><+=:;&", "monday_friday", "㊽ÄA小ヒ☍"), | ||
expected: "大", | ||
}, | ||
testCase{ | ||
input: NewNamespace("A小ヒ☍小㊽%:;", "/hello", "/world大|", "monday_friday", "corporate-service"), | ||
expected: "^", | ||
}, | ||
} | ||
return tcs | ||
} |
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,35 @@ | ||
{ | ||
"collect": { | ||
"metrics": { | ||
"㊽foo㊽bar": { | ||
"version": 1 | ||
}, | ||
"大foo大baz": {}, | ||
"/a0/b0": {}, | ||
"-a1-b1": {}, | ||
"_a2_b2": {}, | ||
"㊽a3㊽b3": {}, | ||
"Äa4Äb4": {}, | ||
"大a5大b5": {}, | ||
"小a6小b6": {}, | ||
"ᵹa7ᵹb7": {}, | ||
"☍a8☍b8": {}, | ||
"ヒa9ヒb9": {} | ||
}, | ||
"config": { | ||
"%foo%bar": { | ||
"password": "drowssap", | ||
"user": "root" | ||
} | ||
}, | ||
"tags": { | ||
"㊽foo㊽bar": { | ||
"tag1": "val1", | ||
"tag2": "val2" | ||
}, | ||
"大foo大baz": { | ||
"tag3": "val3" | ||
} | ||
} | ||
} | ||
} |
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