MCPcopy Index your code
hub / github.com/bitfield/script / TestWithEnv_UnsetsAllEnvVarsGivenEmptySlice

Function TestWithEnv_UnsetsAllEnvVarsGivenEmptySlice

script_test.go:1829–1848  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1827}
1828
1829func TestWithEnv_UnsetsAllEnvVarsGivenEmptySlice(t *testing.T) {
1830 t.Parallel()
1831 p := script.NewPipe().WithEnv([]string{"ENV1=test1"}).Exec("sh -c 'echo ENV1=$ENV1'")
1832 want := "ENV1=test1\n"
1833 got, err := p.String()
1834 if err != nil {
1835 t.Fatal(err)
1836 }
1837 if got != want {
1838 t.Fatalf("want %q, got %q", want, got)
1839 }
1840 got, err = p.Echo("").WithEnv([]string{}).Exec("sh -c 'echo ENV1=$ENV1'").String()
1841 if err != nil {
1842 t.Fatal(err)
1843 }
1844 want = "ENV1=\n"
1845 if got != want {
1846 t.Errorf("want %q, got %q", want, got)
1847 }
1848}
1849
1850func TestWithEnv_SetsGivenVariablesForSubsequentExec(t *testing.T) {
1851 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewPipeFunction · 0.92
ExecMethod · 0.80
WithEnvMethod · 0.80
StringMethod · 0.80
EchoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…