func key(expr string) flatpack.Key { parts := strings.Split(expr, ".") return flatpack.Key(parts) }
"strings" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/xeger/flatpack" ) func key(expr string) flatpack.Key { parts := strings.Split(expr, ".") return flatpack.Key(parts) } var _ = Describe("Key", func() { It("has a useful zero value", func() { Expect(flatpack.Key(nil).AsEnv()).To(Equal("")) Expect(flatpack.Key(nil).String()).To(Equal("")) Expect(flatpack.Key([]string{}).AsEnv()).To(Equal("")) Expect(flatpack.Key([]string{}).String()).To(Equal("")) }) Describe(".String()", func() { It("uses dot notation", func() { Expect(key("Dot.Separated").String()).To(Equal("Dot.Separated")) }) }) Describe(".AsEnv()", func() { It("separates pieces with underscore", func() { Expect(key("Dot.Separated").AsEnv()).To(Equal("DOT_SEPARATED")) Expect(key("Dot...Separated").AsEnv()).To(Equal("DOT_SEPARATED"))