From 170a6015ed5659e5cf9ecfc33ad28d4a6549a77b Mon Sep 17 00:00:00 2001 From: carlory Date: Tue, 19 Sep 2017 10:32:44 +0800 Subject: [PATCH] add test code for ToToml --- pkg/chartutil/files_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/chartutil/files_test.go b/pkg/chartutil/files_test.go index 731c82e6f..0d02a9050 100644 --- a/pkg/chartutil/files_test.go +++ b/pkg/chartutil/files_test.go @@ -112,13 +112,12 @@ func TestToYaml(t *testing.T) { } func TestToToml(t *testing.T) { - expect := "foo = \"bar\"\n" v := struct { Foo string `toml:"foo"` }{ Foo: "bar", } - + expect := "foo = \"bar\"\n" if got := ToToml(v); got != expect { t.Errorf("Expected %q, got %q", expect, got) } @@ -129,11 +128,17 @@ func TestToToml(t *testing.T) { "sail": "white", }, } - got := ToToml(dict) expect = "[mast]\n sail = \"white\"\n" - if got != expect { + if got := ToToml(dict); got != expect { t.Errorf("Expected:\n%s\nGot\n%s\n", expect, got) } + + // (error) map no string key + invalid := map[int]string{1: ""} + expect = "" + if got := ToToml(invalid); got != expect { + t.Errorf("Expected empty string, got %s", got) + } } func TestFromYaml(t *testing.T) {