@@ -284,6 +284,15 @@ func Test_p4_pull(t *testing.T) {
284
284
true ,
285
285
[]string {"sync" , "//test_client/base_dir/..." },
286
286
},
287
+ {
288
+ "base directory is empty" ,
289
+ filepath .FromSlash ("/p4root" ),
290
+ "" ,
291
+ "test_client" ,
292
+ nil ,
293
+ true ,
294
+ nil ,
295
+ },
287
296
}
288
297
for _ , tt := range testFlags {
289
298
t .Run (tt .desc , func (t * testing.T ) {
@@ -443,6 +452,54 @@ func Test_p4_commit(t *testing.T) {
443
452
}
444
453
}
445
454
455
+ func Test_p4_submit (t * testing.T ) {
456
+ testFlags := []struct {
457
+ desc string
458
+ p4Changelist * changeList
459
+ p4SubmitError error
460
+ p4SubmitExpectedArgs []string
461
+ expectError bool
462
+ }{
463
+ {
464
+ "p4 submit command call succeeds" ,
465
+ & changeList {number : "1234567" },
466
+ nil , []string {"submit" , "-c" , "1234567" },
467
+ false ,
468
+ },
469
+ {
470
+ "p4 submit command call fails" ,
471
+ & changeList {number : "1234567" },
472
+ errors .New ("p4 submit error" ), []string {"submit" , "-c" , "1234567" },
473
+ true ,
474
+ },
475
+ {
476
+ "empty changelist" ,
477
+ nil ,
478
+ errors .New ("p4 submit error" ), nil ,
479
+ true ,
480
+ },
481
+ }
482
+ for _ , tt := range testFlags {
483
+ t .Run (tt .desc , func (t * testing.T ) {
484
+ var p4SubmitActualArgs []string
485
+ p , _ := newP4Impl (inMemoryDepotInit , "" , true )
486
+ p .traceP4Function = func (args ... string ) (err error ) {
487
+ // Stub for the call to "p4 submit -c <cl_number>"
488
+ p4SubmitActualArgs = args [4 :]
489
+ return tt .p4SubmitError
490
+ }
491
+
492
+ err := p .submitChangeList (tt .p4Changelist )
493
+ if tt .expectError {
494
+ assert .Error (t , err )
495
+ } else {
496
+ assert .NoError (t , err )
497
+ }
498
+ assert .Equal (t , tt .p4SubmitExpectedArgs , p4SubmitActualArgs )
499
+ })
500
+ }
501
+ }
502
+
446
503
func Test_convert_to_p4_client_path (t * testing.T ) {
447
504
testFlags := []struct {
448
505
desc string
@@ -496,7 +553,7 @@ func Test_convert_to_p4_client_path(t *testing.T) {
496
553
"Dir outside the root directory" ,
497
554
"D:\\ p4root" ,
498
555
"test_client" ,
499
- "D:\\ somewhereelse \\ sub_dir" ,
556
+ "D:\\ somewhere_else \\ sub_dir" ,
500
557
errors .New ("path is outside p4 root directory" ),
501
558
"" ,
502
559
},
0 commit comments