@@ -323,7 +323,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
323
323
err := inv .Run ()
324
324
require .NoError (t , err )
325
325
326
+ ctx := testutil .Context (t , testutil .WaitLong )
326
327
inv , root = clitest .New (t , "update" , "my-workspace" , "--always-prompt" )
328
+ inv = inv .WithContext (ctx )
327
329
clitest .SetupConfig (t , member , root )
328
330
doneChan := make (chan struct {})
329
331
pty := ptytest .New (t ).Attach (inv )
@@ -333,18 +335,16 @@ func TestUpdateValidateRichParameters(t *testing.T) {
333
335
assert .NoError (t , err )
334
336
}()
335
337
336
- matches := []string {
337
- stringParameterName , "$$" ,
338
- "does not match" , "" ,
339
- "Enter a value" , "abc" ,
340
- }
341
- for i := 0 ; i < len (matches ); i += 2 {
342
- match := matches [i ]
343
- value := matches [i + 1 ]
344
- pty .ExpectMatch (match )
345
- pty .WriteLine (value )
346
- }
347
- <- doneChan
338
+ pty .ExpectMatch (stringParameterName )
339
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
340
+ pty .WriteLine ("$$" )
341
+ pty .ExpectMatch ("does not match" )
342
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
343
+ pty .WriteLine ("" )
344
+ pty .ExpectMatch ("does not match" )
345
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
346
+ pty .WriteLine ("abc" )
347
+ _ = testutil .RequireRecvCtx (ctx , t , doneChan )
348
348
})
349
349
350
350
t .Run ("ValidateNumber" , func (t * testing.T ) {
@@ -369,7 +369,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
369
369
err := inv .Run ()
370
370
require .NoError (t , err )
371
371
372
+ ctx := testutil .Context (t , testutil .WaitLong )
372
373
inv , root = clitest .New (t , "update" , "my-workspace" , "--always-prompt" )
374
+ inv .WithContext (ctx )
373
375
clitest .SetupConfig (t , member , root )
374
376
doneChan := make (chan struct {})
375
377
pty := ptytest .New (t ).Attach (inv )
@@ -379,21 +381,30 @@ func TestUpdateValidateRichParameters(t *testing.T) {
379
381
assert .NoError (t , err )
380
382
}()
381
383
382
- matches := []string {
383
- numberParameterName , "12" ,
384
- "is more than the maximum" , "" ,
385
- "Enter a value" , "8" ,
386
- }
387
- for i := 0 ; i < len (matches ); i += 2 {
388
- match := matches [i ]
389
- value := matches [i + 1 ]
390
- pty .ExpectMatch (match )
391
-
392
- if value != "" {
393
- pty .WriteLine (value )
394
- }
395
- }
396
- <- doneChan
384
+ //matches := []string{
385
+ // numberParameterName, "12",
386
+ // "is more than the maximum", "",
387
+ // "Enter a value", "8",
388
+ //}
389
+ //for i := 0; i < len(matches); i += 2 {
390
+ // match := matches[i]
391
+ // value := matches[i+1]
392
+ // pty.ExpectMatch(match)
393
+ //
394
+ // if value != "" {
395
+ // pty.WriteLine(value)
396
+ // }
397
+ //}
398
+ pty .ExpectMatch (numberParameterName )
399
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
400
+ pty .WriteLine ("12" )
401
+ pty .ExpectMatch ("is more than the maximum" )
402
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
403
+ pty .WriteLine ("" )
404
+ pty .ExpectMatch ("is not a number" )
405
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
406
+ pty .WriteLine ("8" )
407
+ _ = testutil .RequireRecvCtx (ctx , t , doneChan )
397
408
})
398
409
399
410
t .Run ("ValidateBool" , func (t * testing.T ) {
@@ -418,7 +429,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
418
429
err := inv .Run ()
419
430
require .NoError (t , err )
420
431
432
+ ctx := testutil .Context (t , testutil .WaitLong )
421
433
inv , root = clitest .New (t , "update" , "my-workspace" , "--always-prompt" )
434
+ inv = inv .WithContext (ctx )
422
435
clitest .SetupConfig (t , member , root )
423
436
doneChan := make (chan struct {})
424
437
pty := ptytest .New (t ).Attach (inv )
@@ -428,18 +441,16 @@ func TestUpdateValidateRichParameters(t *testing.T) {
428
441
assert .NoError (t , err )
429
442
}()
430
443
431
- matches := []string {
432
- boolParameterName , "cat" ,
433
- "boolean value can be either" , "" ,
434
- "Enter a value" , "false" ,
435
- }
436
- for i := 0 ; i < len (matches ); i += 2 {
437
- match := matches [i ]
438
- value := matches [i + 1 ]
439
- pty .ExpectMatch (match )
440
- pty .WriteLine (value )
441
- }
442
- <- doneChan
444
+ pty .ExpectMatch (boolParameterName )
445
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
446
+ pty .WriteLine ("cat" )
447
+ pty .ExpectMatch ("boolean value can be either \" true\" or \" false\" " )
448
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
449
+ pty .WriteLine ("" )
450
+ pty .ExpectMatch ("boolean value can be either \" true\" or \" false\" " )
451
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
452
+ pty .WriteLine ("false" )
453
+ _ = testutil .RequireRecvCtx (ctx , t , doneChan )
443
454
})
444
455
445
456
t .Run ("RequiredParameterAdded" , func (t * testing.T ) {
@@ -485,7 +496,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
485
496
require .NoError (t , err )
486
497
487
498
// Update the workspace
499
+ ctx := testutil .Context (t , testutil .WaitLong )
488
500
inv , root = clitest .New (t , "update" , "my-workspace" )
501
+ inv .WithContext (ctx )
489
502
clitest .SetupConfig (t , member , root )
490
503
doneChan := make (chan struct {})
491
504
pty := ptytest .New (t ).Attach (inv )
@@ -508,7 +521,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
508
521
pty .WriteLine (value )
509
522
}
510
523
}
511
- <- doneChan
524
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
512
525
})
513
526
514
527
t .Run ("OptionalParameterAdded" , func (t * testing.T ) {
@@ -555,7 +568,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
555
568
require .NoError (t , err )
556
569
557
570
// Update the workspace
571
+ ctx := testutil .Context (t , testutil .WaitLong )
558
572
inv , root = clitest .New (t , "update" , "my-workspace" )
573
+ inv .WithContext (ctx )
559
574
clitest .SetupConfig (t , member , root )
560
575
doneChan := make (chan struct {})
561
576
pty := ptytest .New (t ).Attach (inv )
@@ -566,7 +581,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
566
581
}()
567
582
568
583
pty .ExpectMatch ("Planning workspace..." )
569
- <- doneChan
584
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
570
585
})
571
586
572
587
t .Run ("ParameterOptionChanged" , func (t * testing.T ) {
@@ -612,7 +627,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
612
627
require .NoError (t , err )
613
628
614
629
// Update the workspace
630
+ ctx := testutil .Context (t , testutil .WaitLong )
615
631
inv , root = clitest .New (t , "update" , "my-workspace" )
632
+ inv .WithContext (ctx )
616
633
clitest .SetupConfig (t , member , root )
617
634
doneChan := make (chan struct {})
618
635
pty := ptytest .New (t ).Attach (inv )
@@ -636,7 +653,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
636
653
}
637
654
}
638
655
639
- <- doneChan
656
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
640
657
})
641
658
642
659
t .Run ("ParameterOptionDisappeared" , func (t * testing.T ) {
@@ -683,7 +700,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
683
700
require .NoError (t , err )
684
701
685
702
// Update the workspace
703
+ ctx := testutil .Context (t , testutil .WaitLong )
686
704
inv , root = clitest .New (t , "update" , "my-workspace" )
705
+ inv .WithContext (ctx )
687
706
clitest .SetupConfig (t , member , root )
688
707
doneChan := make (chan struct {})
689
708
pty := ptytest .New (t ).Attach (inv )
@@ -707,7 +726,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
707
726
}
708
727
}
709
728
710
- <- doneChan
729
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
711
730
})
712
731
713
732
t .Run ("ParameterOptionFailsMonotonicValidation" , func (t * testing.T ) {
@@ -739,7 +758,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
739
758
require .NoError (t , err )
740
759
741
760
// Update the workspace
761
+ ctx := testutil .Context (t , testutil .WaitLong )
742
762
inv , root = clitest .New (t , "update" , "my-workspace" , "--always-prompt=true" )
763
+ inv .WithContext (ctx )
743
764
clitest .SetupConfig (t , member , root )
744
765
745
766
doneChan := make (chan struct {})
@@ -762,7 +783,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
762
783
pty .ExpectMatch (match )
763
784
}
764
785
765
- <- doneChan
786
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
766
787
})
767
788
768
789
t .Run ("ImmutableRequiredParameterExists_MutableRequiredParameterAdded" , func (t * testing.T ) {
@@ -804,7 +825,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
804
825
require .NoError (t , err )
805
826
806
827
// Update the workspace
828
+ ctx := testutil .Context (t , testutil .WaitLong )
807
829
inv , root = clitest .New (t , "update" , "my-workspace" )
830
+ inv .WithContext (ctx )
808
831
clitest .SetupConfig (t , member , root )
809
832
doneChan := make (chan struct {})
810
833
pty := ptytest .New (t ).Attach (inv )
@@ -828,7 +851,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
828
851
}
829
852
}
830
853
831
- <- doneChan
854
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
832
855
})
833
856
834
857
t .Run ("MutableRequiredParameterExists_ImmutableRequiredParameterAdded" , func (t * testing.T ) {
@@ -874,7 +897,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
874
897
require .NoError (t , err )
875
898
876
899
// Update the workspace
900
+ ctx := testutil .Context (t , testutil .WaitLong )
877
901
inv , root = clitest .New (t , "update" , "my-workspace" )
902
+ inv .WithContext (ctx )
878
903
clitest .SetupConfig (t , member , root )
879
904
doneChan := make (chan struct {})
880
905
pty := ptytest .New (t ).Attach (inv )
@@ -898,6 +923,6 @@ func TestUpdateValidateRichParameters(t *testing.T) {
898
923
}
899
924
}
900
925
901
- <- doneChan
926
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
902
927
})
903
928
}
0 commit comments