@@ -20,8 +20,6 @@ func testPexec(t *testing.T, context spec.G, it spec.S) {
20
20
var (
21
21
Expect = NewWithT (t ).Expect
22
22
23
- fakeCLI string
24
- existingPath string
25
23
tmpDir string
26
24
stdout , stderr * bytes.Buffer
27
25
@@ -39,18 +37,10 @@ func testPexec(t *testing.T, context spec.G, it spec.S) {
39
37
stdout = bytes .NewBuffer (nil )
40
38
stderr = bytes .NewBuffer (nil )
41
39
42
- executable = pexec .NewExecutable ("some-executable" )
43
-
44
- fakeCLI , err = gexec .Build ("github.com/paketo-buildpacks/packit/fakes/some-executable" )
45
- Expect (err ).NotTo (HaveOccurred ())
46
-
47
- existingPath = os .Getenv ("PATH" )
48
- os .Setenv ("PATH" , filepath .Dir (fakeCLI ))
40
+ executable = pexec .NewExecutable (filepath .Base (fakeCLI ))
49
41
})
50
42
51
43
it .After (func () {
52
- os .Setenv ("PATH" , existingPath )
53
- gexec .CleanupBuildArtifacts ()
54
44
Expect (os .RemoveAll (tmpDir )).To (Succeed ())
55
45
})
56
46
@@ -119,12 +109,12 @@ func testPexec(t *testing.T, context spec.G, it spec.S) {
119
109
context ("failure cases" , func () {
120
110
context ("when the executable cannot be found on the path" , func () {
121
111
it .Before (func () {
122
- Expect ( os . Unsetenv ( "PATH" )). To ( Succeed () )
112
+ executable = pexec . NewExecutable ( "unknown-executable" )
123
113
})
124
114
125
115
it ("returns an error" , func () {
126
116
err := executable .Execute (pexec.Execution {})
127
- Expect (err ).To (MatchError ("exec: \" some -executable\" : executable file not found in $PATH" ))
117
+ Expect (err ).To (MatchError ("exec: \" unknown -executable\" : executable file not found in $PATH" ))
128
118
})
129
119
})
130
120
0 commit comments