@@ -208,12 +208,12 @@ func Test__Push(t *testing.T) {
208
208
os .RemoveAll (tmpDir )
209
209
})
210
210
211
- t .Run ("push using input from a pipe" , func (t * testing.T ) {
211
+ t .Run ("push using input from a pipe using - " , func (t * testing.T ) {
212
212
if runtime .GOOS == "windows" {
213
213
t .Skip ()
214
214
}
215
215
216
- command := fmt .Sprintf ("echo -n \" hello from pipe \" | %s push job - -d from-pipe .txt -v" , getBinaryPath (rootFolder ))
216
+ command := fmt .Sprintf ("echo -n \" hello from dash \" | %s push job - -d from-dash .txt -v" , getBinaryPath (rootFolder ))
217
217
tmpScript , err := createTempScript (command )
218
218
if ! assert .Nil (t , err ) {
219
219
return
@@ -224,14 +224,71 @@ func Test__Push(t *testing.T) {
224
224
assert .Contains (t , output , "Detected stdin, saving it to a temporary file..." )
225
225
assert .Contains (t , output , "Successfully pushed artifact for current job" )
226
226
227
- output , err = executeCommand ("pull" , rootFolder , []string {"from-pipe .txt" })
227
+ output , err = executeCommand ("pull" , rootFolder , []string {"from-dash .txt" })
228
228
assert .Nil (t , err )
229
229
assert .Contains (t , output , "Successfully pulled artifact for current job" )
230
230
231
- fileContents , _ := ioutil .ReadFile ("from-pipe .txt" )
232
- assert .Equal (t , "hello from pipe " , string (fileContents ))
231
+ fileContents , _ := ioutil .ReadFile ("from-dash .txt" )
232
+ assert .Equal (t , "hello from dash " , string (fileContents ))
233
233
234
- os .Remove ("from-pipe.txt" )
234
+ os .Remove ("from-dash.txt" )
235
+ os .Remove (tmpScript )
236
+ })
237
+
238
+ t .Run ("push using input from a pipe using /dev/stdin" , func (t * testing.T ) {
239
+ if runtime .GOOS == "windows" {
240
+ t .Skip ()
241
+ }
242
+
243
+ command := fmt .Sprintf ("echo -n \" hello from /dev/stdin\" | %s push job /dev/stdin -d from-dev-stdin.txt -v" , getBinaryPath (rootFolder ))
244
+ tmpScript , err := createTempScript (command )
245
+ if ! assert .Nil (t , err ) {
246
+ return
247
+ }
248
+
249
+ output , err := executeTempScript (tmpScript )
250
+ assert .Nil (t , err )
251
+ assert .Contains (t , output , "Detected stdin, saving it to a temporary file..." )
252
+ assert .Contains (t , output , "Successfully pushed artifact for current job" )
253
+
254
+ output , err = executeCommand ("pull" , rootFolder , []string {"from-dev-stdin.txt" })
255
+ assert .Nil (t , err )
256
+ assert .Contains (t , output , "Successfully pulled artifact for current job" )
257
+
258
+ fileContents , _ := ioutil .ReadFile ("from-dev-stdin.txt" )
259
+ assert .Equal (t , "hello from /dev/stdin" , string (fileContents ))
260
+
261
+ os .Remove ("from-dev-stdin.txt" )
262
+ os .Remove (tmpScript )
263
+ })
264
+
265
+ t .Run ("input coming from pipe but file is used" , func (t * testing.T ) {
266
+ if runtime .GOOS == "windows" {
267
+ t .Skip ()
268
+ }
269
+
270
+ tmpFile , _ := ioutil .TempFile ("" , "*" )
271
+ tmpFile .Write ([]byte ("hello from file" ))
272
+
273
+ command := fmt .Sprintf ("echo -n \" hello from pipe\" | %s push job %s -d not-from-pipe.txt -v" , getBinaryPath (rootFolder ), tmpFile .Name ())
274
+ tmpScript , err := createTempScript (command )
275
+ if ! assert .Nil (t , err ) {
276
+ return
277
+ }
278
+
279
+ output , err := executeTempScript (tmpScript )
280
+ assert .Nil (t , err )
281
+ assert .NotContains (t , output , "Detected stdin, saving it to a temporary file..." )
282
+ assert .Contains (t , output , "Successfully pushed artifact for current job" )
283
+
284
+ output , err = executeCommand ("pull" , rootFolder , []string {"not-from-pipe.txt" })
285
+ assert .Nil (t , err )
286
+ assert .Contains (t , output , "Successfully pulled artifact for current job" )
287
+
288
+ fileContents , _ := ioutil .ReadFile ("not-from-pipe.txt" )
289
+ assert .Equal (t , "hello from file" , string (fileContents ))
290
+
291
+ os .Remove ("not-from-pipe.txt" )
235
292
os .Remove (tmpScript )
236
293
})
237
294
0 commit comments