package wand /* import ( "fmt" "strings" "testing" ) func TestEnv(t *testing.T) { type f struct{ One, SecondVar string } ff := func(f f) string { return f.One + f.SecondVar } type i struct{ One, SecondVar int } fi := func(i i) string { return fmt.Sprintf("%d;%d", i.One, i.SecondVar) } type m struct{ One, SecondVar []string } fm := func(m m) string { return strings.Join([]string{strings.Join(m.One, ","), strings.Join(m.SecondVar, ",")}, ";") } t.Run("none match app prefix", testExec(t, ff, "SOME_VAR=foo;SOME_OTHER=bar", "baz", "", "")) t.Run("common environment var casing", testExec(t, ff, "FOO_ONE=bar;FOO_SECOND_VAR=baz", "foo", "", "barbaz")) t.Run("camel casing", testExec(t, ff, "fooOne=bar;fooSecondVar=baz", "foo", "", "barbaz")) t.Run("empty env var", testExec(t, ff, "fooOne=bar;fooSecondVar=", "foo", "", "bar")) t.Run("multipart app name", testExec(t, ff, "fooBarOne=baz;FOO_BAR_SECOND_VAR=qux", "foo-bar", "", "bazqux")) t.Run("invalid env var", testExec(t, ff, "fooOne=bar;fooSecondVar=baz;fooQux", "foo", "", "barbaz")) t.Run("eq in value", testExec(t, ff, "fooOne=bar=baz", "foo", "", "bar=baz")) t.Run("keeps original name", testExec(t, fi, "FOO_ONE=bar", "foo", "FOO_ONE", "")) t.Run("keeps original name, last wins on conflict", testExec(t, fi, "FOO_ONE=bar;fooOne=baz", "foo", "fooOne", "")) t.Run("multiple values", func(t *testing.T) { t.Run("2", testExec(t, fm, "fooOne=bar:baz", "foo", "", "bar,baz;")) t.Run("3", testExec(t, fm, "fooOne=bar:baz:qux", "foo", "", "bar,baz,qux;")) t.Run("with empty", testExec(t, fm, "fooOne=bar:baz::qux:", "foo", "", "bar,baz,,qux,;")) t.Run("escape", testExec(t, fm, "fooOne=bar\\:baz", "foo", "", "bar:baz;")) t.Run("escape char", testExec(t, fm, "fooOne=bar\\\\:baz", "foo", "", "bar\\,baz;")) t.Run("escape char last", testExec(t, fm, "fooOne=bar\\", "foo", "", "bar;")) }) } */