44 "encoding/json"
55 "errors"
66 "io"
7- "os"
87
98 boshlog "github.com/cloudfoundry/bosh-utils/logger"
109 fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"
@@ -63,9 +62,7 @@ var _ = Describe("CpiCmdRunner", func() {
6362 Expect (actualCmd .Env ).To (Equal (map [string ]string {
6463 "BOSH_PACKAGES_DIR" : cpi .PackagesDir ,
6564 "BOSH_JOBS_DIR" : cpi .JobsDir ,
66- "PATH" : "/usr/local/bin:/usr/bin:/bin:/sbin" ,
6765 }))
68- Expect (actualCmd .UseIsolatedEnv ).To (BeTrue ())
6966 bytes , err := io .ReadAll (actualCmd .Stdin )
7067 Expect (err ).NotTo (HaveOccurred ())
7168 Expect (string (bytes )).To (Equal (
@@ -89,41 +86,6 @@ var _ = Describe("CpiCmdRunner", func() {
8986 apiVersion = 2
9087 })
9188
92- AfterEach (func () {
93- os .Unsetenv ("BOSH_CPI_USE_ISOLATED_ENV" )
94- })
95- It ("creates correct command with UseIsolatedEnv false if BOSH_CPI_USE_ISOLATED_ENV is set" , func () {
96- os .Setenv ("BOSH_CPI_USE_ISOLATED_ENV" , "false" )
97- cmdOutput := CmdOutput {}
98- outputBytes , err := json .Marshal (cmdOutput )
99- Expect (err ).NotTo (HaveOccurred ())
100-
101- result := fakesys.FakeCmdResult {
102- Stdout : string (outputBytes ),
103- ExitStatus : 0 ,
104- }
105- cmdRunner .AddCmdResult ("/jobs/cpi/bin/cpi" , result )
106- _ , err = cpiCmdRunner .Run (context , "fake-method" , apiVersion , "fake-argument-1" , "fake-argument-2" )
107- Expect (err ).NotTo (HaveOccurred ())
108- actualCmd := cmdRunner .RunComplexCommands [0 ]
109- Expect (actualCmd .UseIsolatedEnv ).To (BeFalse ())
110-
111- })
112- It ("throws helpful error if the value of BOSH_CPI_USE_ISOLATED_ENV cannot be parsed into a bool" , func () {
113- os .Setenv ("BOSH_CPI_USE_ISOLATED_ENV" , "falasdse" )
114- cmdOutput := CmdOutput {}
115- outputBytes , err := json .Marshal (cmdOutput )
116- Expect (err ).NotTo (HaveOccurred ())
117-
118- result := fakesys.FakeCmdResult {
119- Stdout : string (outputBytes ),
120- ExitStatus : 0 ,
121- }
122- cmdRunner .AddCmdResult ("/jobs/cpi/bin/cpi" , result )
123- _ , err = cpiCmdRunner .Run (context , "fake-method" , apiVersion , "fake-argument-1" , "fake-argument-2" )
124- Expect (err ).To (HaveOccurred ())
125- Expect (MatchRegexp ("BOSH_CPI_USE_ISOLATED_ENV cannot be parsed" , err ))
126- })
12789 It ("creates correct command with stemcell api_version in context" , func () {
12890 cmdOutput := CmdOutput {}
12991 outputBytes , err := json .Marshal (cmdOutput )
@@ -145,9 +107,7 @@ var _ = Describe("CpiCmdRunner", func() {
145107 Expect (actualCmd .Env ).To (Equal (map [string ]string {
146108 "BOSH_PACKAGES_DIR" : cpi .PackagesDir ,
147109 "BOSH_JOBS_DIR" : cpi .JobsDir ,
148- "PATH" : "/usr/local/bin:/usr/bin:/bin:/sbin" ,
149110 }))
150- Expect (actualCmd .UseIsolatedEnv ).To (BeTrue ())
151111 bytes , err := io .ReadAll (actualCmd .Stdin )
152112 Expect (err ).NotTo (HaveOccurred ())
153113 Expect (string (bytes )).To (Equal (
0 commit comments