|
| 1 | +package defaults_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "os" |
| 5 | + |
| 6 | + . "github.com/onsi/ginkgo" |
| 7 | + . "github.com/onsi/gomega" |
| 8 | + |
| 9 | + . "github.com/solo-io/wasm/tools/wasme/cli/pkg/defaults" |
| 10 | +) |
| 11 | + |
| 12 | +var _ = Describe("Env Proxy Args Passthrough", func() { |
| 13 | + It("should not pass through any extra env vars if none are set", func() { |
| 14 | + result := GetProxyEnvArgs() |
| 15 | + Expect(result).To(HaveLen(0), "shouldn't generate extra args") |
| 16 | + }) |
| 17 | + |
| 18 | + It("should pass a single env var when set", func() { |
| 19 | + os.Setenv("http_proxy", "http://example.com") |
| 20 | + result := GetProxyEnvArgs() |
| 21 | + Expect(result).To(HaveLen(2)) |
| 22 | + Expect(result[0]).To(Equal("-e")) |
| 23 | + Expect(result[1]).To(Equal("http_proxy=http://example.com")) |
| 24 | + }) |
| 25 | + |
| 26 | + It("should pass multiple env vars when set", func() { |
| 27 | + os.Setenv("http_proxy", "http://example.com") |
| 28 | + os.Setenv("https_proxy", "https://example.com") |
| 29 | + os.Setenv("no_proxy", "https://example.com/foo") |
| 30 | + os.Setenv("GOPROXY", "https://example.com/bar") |
| 31 | + result := GetProxyEnvArgs() |
| 32 | + Expect(result).To(HaveLen(8)) |
| 33 | + Expect(result[0]).To(Equal("-e")) |
| 34 | + Expect(result[1]).To(Equal("http_proxy=http://example.com")) |
| 35 | + Expect(result[2]).To(Equal("-e")) |
| 36 | + Expect(result[3]).To(Equal("https_proxy=https://example.com")) |
| 37 | + Expect(result[4]).To(Equal("-e")) |
| 38 | + Expect(result[5]).To(Equal("no_proxy=https://example.com/foo")) |
| 39 | + Expect(result[6]).To(Equal("-e")) |
| 40 | + Expect(result[7]).To(Equal("GOPROXY=https://example.com/bar")) |
| 41 | + }) |
| 42 | +}) |
0 commit comments