diff options
Diffstat (limited to 'vendor/github.com/go-ini/ini/key_test.go')
-rw-r--r-- | vendor/github.com/go-ini/ini/key_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/github.com/go-ini/ini/key_test.go b/vendor/github.com/go-ini/ini/key_test.go index 588efd429..a13ad95fa 100644 --- a/vendor/github.com/go-ini/ini/key_test.go +++ b/vendor/github.com/go-ini/ini/key_test.go @@ -15,6 +15,7 @@ package ini_test import ( + "bytes" "fmt" "strings" "testing" @@ -478,3 +479,45 @@ func TestKey_SetValue(t *testing.T) { So(k.Value(), ShouldEqual, "ini.v1") }) } + +func TestKey_NestedValues(t *testing.T) { + Convey("Read and write nested values", t, func() { + f, err := ini.LoadSources(ini.LoadOptions{ + AllowNestedValues: true, + }, []byte(` +aws_access_key_id = foo +aws_secret_access_key = bar +region = us-west-2 +s3 = + max_concurrent_requests=10 + max_queue_size=1000`)) + So(err, ShouldBeNil) + So(f, ShouldNotBeNil) + + So(f.Section("").Key("s3").NestedValues(), ShouldResemble, []string{"max_concurrent_requests=10", "max_queue_size=1000"}) + + var buf bytes.Buffer + _, err = f.WriteTo(&buf) + So(err, ShouldBeNil) + So(buf.String(), ShouldEqual, `aws_access_key_id = foo +aws_secret_access_key = bar +region = us-west-2 +s3 = + max_concurrent_requests=10 + max_queue_size=1000 + +`) + }) +} + +func TestRecursiveValues(t *testing.T) { + Convey("Recursive values should not reflect on same key", t, func() { + f, err := ini.Load([]byte(` +NAME = ini +[package] +NAME = %(NAME)s`)) + So(err, ShouldBeNil) + So(f, ShouldNotBeNil) + So(f.Section("package").Key("NAME").String(), ShouldEqual, "ini") + }) +} |