MCPcopy
hub / github.com/bitfield/script / TestWithEnv_SetsGivenVariablesForSubsequentExec

Function TestWithEnv_SetsGivenVariablesForSubsequentExec

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

Source from the content-addressed store, hash-verified

1848}
1849
1850func TestWithEnv_SetsGivenVariablesForSubsequentExec(t *testing.T) {
1851 t.Parallel()
1852 env := []string{"ENV1=test1", "ENV2=test2"}
1853 got, err := script.NewPipe().WithEnv(env).Exec("sh -c 'echo ENV1=$ENV1 ENV2=$ENV2'").String()
1854 if err != nil {
1855 t.Fatal(err)
1856 }
1857 want := "ENV1=test1 ENV2=test2\n"
1858 if got != want {
1859 t.Errorf("want %q, got %q", want, got)
1860 }
1861}
1862
1863func TestErrorReturnsErrorSetByPreviousPipeStage(t *testing.T) {
1864 t.Parallel()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…