@@ -17,6 +17,7 @@ limitations under the License.
17
17
package entrypoint
18
18
19
19
import (
20
+ "context"
20
21
"encoding/json"
21
22
"errors"
22
23
"io/ioutil"
@@ -93,6 +94,43 @@ func TestEntrypointerFailures(t *testing.T) {
93
94
if c .postFile == "" && fpw .wrote != nil {
94
95
t .Errorf ("Wrote post file when not required" )
95
96
}
97
+
98
+ if c .waiter == nil {
99
+ fileContents , err := ioutil .ReadFile ("termination" )
100
+ if err == nil {
101
+ var entries []v1alpha1.PipelineResourceResult
102
+ if err := json .Unmarshal ([]byte (fileContents ), & entries ); err == nil {
103
+ index := make (map [string ]v1alpha1.PipelineResourceResult , len (entries ))
104
+ for _ , item := range entries {
105
+ index [item .Key ] = item
106
+ }
107
+ if _ , ok := index ["StartedAt" ]; ! ok {
108
+ t .Error ("Didn't find the StartedAt entry" )
109
+ }
110
+ if reason , ok := index ["Reason" ]; ok {
111
+ if reason .Value != "Unknown" {
112
+ t .Error ("Reason should be Unknown" )
113
+ }
114
+ } else {
115
+ t .Error ("Didn't find the Reason entry" )
116
+ }
117
+
118
+ if message , ok := index ["Message" ]; ok {
119
+ if message .Value != "runner failed" {
120
+ t .Error ("Message should be runner failed" )
121
+ }
122
+ } else {
123
+ t .Error ("Didn't find the Message entry " )
124
+ }
125
+ }
126
+ } else if ! os .IsNotExist (err ) {
127
+ t .Error ("Wanted termination file written, got nil" )
128
+ }
129
+ if err := os .Remove ("termination" ); err != nil {
130
+ t .Errorf ("Could not remove termination path: %s" , err )
131
+ }
132
+ }
133
+
96
134
})
97
135
}
98
136
}
@@ -213,7 +251,7 @@ func (f *fakeWaiter) Wait(file string, _ bool) error {
213
251
214
252
type fakeRunner struct { args * []string }
215
253
216
- func (f * fakeRunner ) Run (args ... string ) error {
254
+ func (f * fakeRunner ) Run (ctx context. Context , args ... string ) error {
217
255
f .args = & args
218
256
return nil
219
257
}
@@ -231,7 +269,7 @@ func (f *fakeErrorWaiter) Wait(file string, expectContent bool) error {
231
269
232
270
type fakeErrorRunner struct { args * []string }
233
271
234
- func (f * fakeErrorRunner ) Run (args ... string ) error {
272
+ func (f * fakeErrorRunner ) Run (ctx context. Context , args ... string ) error {
235
273
f .args = & args
236
274
return errors .New ("runner failed" )
237
275
}
0 commit comments