summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pelletier/go-toml/keysparsing_test.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-03-24 23:31:34 -0700
committerenahum <nahumhbl@gmail.com>2017-03-25 03:31:34 -0300
commit54d3d47daf9190275bbdaf8703b84969a4593451 (patch)
tree05899b296d0186c1a0da8a540bc486e34ad8eec9 /vendor/github.com/pelletier/go-toml/keysparsing_test.go
parent7460302dec7796e01c98264e84bece8169cb6ed9 (diff)
downloadchat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.gz
chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.bz2
chat-54d3d47daf9190275bbdaf8703b84969a4593451.zip
PLT-6076 Adding viper libs for config file changes (#5871)
* Adding viper libs for config file changes * Removing the old fsnotify lib * updating some missing libs
Diffstat (limited to 'vendor/github.com/pelletier/go-toml/keysparsing_test.go')
-rw-r--r--vendor/github.com/pelletier/go-toml/keysparsing_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/vendor/github.com/pelletier/go-toml/keysparsing_test.go b/vendor/github.com/pelletier/go-toml/keysparsing_test.go
new file mode 100644
index 000000000..1a9ecccaa
--- /dev/null
+++ b/vendor/github.com/pelletier/go-toml/keysparsing_test.go
@@ -0,0 +1,56 @@
+package toml
+
+import (
+ "fmt"
+ "testing"
+)
+
+func testResult(t *testing.T, key string, expected []string) {
+ parsed, err := parseKey(key)
+ t.Logf("key=%s expected=%s parsed=%s", key, expected, parsed)
+ if err != nil {
+ t.Fatal("Unexpected error:", err)
+ }
+ if len(expected) != len(parsed) {
+ t.Fatal("Expected length", len(expected), "but", len(parsed), "parsed")
+ }
+ for index, expectedKey := range expected {
+ if expectedKey != parsed[index] {
+ t.Fatal("Expected", expectedKey, "at index", index, "but found", parsed[index])
+ }
+ }
+}
+
+func testError(t *testing.T, key string, expectedError string) {
+ _, err := parseKey(key)
+ if fmt.Sprintf("%s", err) != expectedError {
+ t.Fatalf("Expected error \"%s\", but got \"%s\".", expectedError, err)
+ }
+}
+
+func TestBareKeyBasic(t *testing.T) {
+ testResult(t, "test", []string{"test"})
+}
+
+func TestBareKeyDotted(t *testing.T) {
+ testResult(t, "this.is.a.key", []string{"this", "is", "a", "key"})
+}
+
+func TestDottedKeyBasic(t *testing.T) {
+ testResult(t, "\"a.dotted.key\"", []string{"a.dotted.key"})
+}
+
+func TestBaseKeyPound(t *testing.T) {
+ testError(t, "hello#world", "invalid bare character: #")
+}
+
+func TestQuotedKeys(t *testing.T) {
+ testResult(t, `hello."foo".bar`, []string{"hello", "foo", "bar"})
+ testResult(t, `"hello!"`, []string{"hello!"})
+}
+
+func TestEmptyKey(t *testing.T) {
+ testError(t, "", "empty key")
+ testError(t, " ", "empty key")
+ testResult(t, `""`, []string{""})
+}