@@ -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,16 @@ 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
+ pty .ExpectMatch (numberParameterName )
385
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
386
+ pty .WriteLine ("12" )
387
+ pty .ExpectMatch ("is more than the maximum" )
388
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
389
+ pty .WriteLine ("" )
390
+ pty .ExpectMatch ("is not a number" )
391
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
392
+ pty .WriteLine ("8" )
393
+ _ = testutil .RequireRecvCtx (ctx , t , doneChan )
397
394
})
398
395
399
396
t .Run ("ValidateBool" , func (t * testing.T ) {
@@ -418,7 +415,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
418
415
err := inv .Run ()
419
416
require .NoError (t , err )
420
417
418
+ ctx := testutil .Context (t , testutil .WaitLong )
421
419
inv , root = clitest .New (t , "update" , "my-workspace" , "--always-prompt" )
420
+ inv = inv .WithContext (ctx )
422
421
clitest .SetupConfig (t , member , root )
423
422
doneChan := make (chan struct {})
424
423
pty := ptytest .New (t ).Attach (inv )
@@ -428,18 +427,16 @@ func TestUpdateValidateRichParameters(t *testing.T) {
428
427
assert .NoError (t , err )
429
428
}()
430
429
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
430
+ pty .ExpectMatch (boolParameterName )
431
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
432
+ pty .WriteLine ("cat" )
433
+ pty .ExpectMatch ("boolean value can be either \" true\" or \" false\" " )
434
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
435
+ pty .WriteLine ("" )
436
+ pty .ExpectMatch ("boolean value can be either \" true\" or \" false\" " )
437
+ pty .ExpectMatch ("> Enter a value (default: \" \" ): " )
438
+ pty .WriteLine ("false" )
439
+ _ = testutil .RequireRecvCtx (ctx , t , doneChan )
443
440
})
444
441
445
442
t .Run ("RequiredParameterAdded" , func (t * testing.T ) {
@@ -485,7 +482,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
485
482
require .NoError (t , err )
486
483
487
484
// Update the workspace
485
+ ctx := testutil .Context (t , testutil .WaitLong )
488
486
inv , root = clitest .New (t , "update" , "my-workspace" )
487
+ inv .WithContext (ctx )
489
488
clitest .SetupConfig (t , member , root )
490
489
doneChan := make (chan struct {})
491
490
pty := ptytest .New (t ).Attach (inv )
@@ -508,7 +507,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
508
507
pty .WriteLine (value )
509
508
}
510
509
}
511
- <- doneChan
510
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
512
511
})
513
512
514
513
t .Run ("OptionalParameterAdded" , func (t * testing.T ) {
@@ -555,7 +554,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
555
554
require .NoError (t , err )
556
555
557
556
// Update the workspace
557
+ ctx := testutil .Context (t , testutil .WaitLong )
558
558
inv , root = clitest .New (t , "update" , "my-workspace" )
559
+ inv .WithContext (ctx )
559
560
clitest .SetupConfig (t , member , root )
560
561
doneChan := make (chan struct {})
561
562
pty := ptytest .New (t ).Attach (inv )
@@ -566,7 +567,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
566
567
}()
567
568
568
569
pty .ExpectMatch ("Planning workspace..." )
569
- <- doneChan
570
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
570
571
})
571
572
572
573
t .Run ("ParameterOptionChanged" , func (t * testing.T ) {
@@ -612,7 +613,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
612
613
require .NoError (t , err )
613
614
614
615
// Update the workspace
616
+ ctx := testutil .Context (t , testutil .WaitLong )
615
617
inv , root = clitest .New (t , "update" , "my-workspace" )
618
+ inv .WithContext (ctx )
616
619
clitest .SetupConfig (t , member , root )
617
620
doneChan := make (chan struct {})
618
621
pty := ptytest .New (t ).Attach (inv )
@@ -636,7 +639,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
636
639
}
637
640
}
638
641
639
- <- doneChan
642
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
640
643
})
641
644
642
645
t .Run ("ParameterOptionDisappeared" , func (t * testing.T ) {
@@ -683,7 +686,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
683
686
require .NoError (t , err )
684
687
685
688
// Update the workspace
689
+ ctx := testutil .Context (t , testutil .WaitLong )
686
690
inv , root = clitest .New (t , "update" , "my-workspace" )
691
+ inv .WithContext (ctx )
687
692
clitest .SetupConfig (t , member , root )
688
693
doneChan := make (chan struct {})
689
694
pty := ptytest .New (t ).Attach (inv )
@@ -707,7 +712,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
707
712
}
708
713
}
709
714
710
- <- doneChan
715
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
711
716
})
712
717
713
718
t .Run ("ParameterOptionFailsMonotonicValidation" , func (t * testing.T ) {
@@ -739,7 +744,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
739
744
require .NoError (t , err )
740
745
741
746
// Update the workspace
747
+ ctx := testutil .Context (t , testutil .WaitLong )
742
748
inv , root = clitest .New (t , "update" , "my-workspace" , "--always-prompt=true" )
749
+ inv .WithContext (ctx )
743
750
clitest .SetupConfig (t , member , root )
744
751
745
752
doneChan := make (chan struct {})
@@ -762,7 +769,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
762
769
pty .ExpectMatch (match )
763
770
}
764
771
765
- <- doneChan
772
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
766
773
})
767
774
768
775
t .Run ("ImmutableRequiredParameterExists_MutableRequiredParameterAdded" , func (t * testing.T ) {
@@ -804,7 +811,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
804
811
require .NoError (t , err )
805
812
806
813
// Update the workspace
814
+ ctx := testutil .Context (t , testutil .WaitLong )
807
815
inv , root = clitest .New (t , "update" , "my-workspace" )
816
+ inv .WithContext (ctx )
808
817
clitest .SetupConfig (t , member , root )
809
818
doneChan := make (chan struct {})
810
819
pty := ptytest .New (t ).Attach (inv )
@@ -828,7 +837,7 @@ func TestUpdateValidateRichParameters(t *testing.T) {
828
837
}
829
838
}
830
839
831
- <- doneChan
840
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
832
841
})
833
842
834
843
t .Run ("MutableRequiredParameterExists_ImmutableRequiredParameterAdded" , func (t * testing.T ) {
@@ -874,7 +883,9 @@ func TestUpdateValidateRichParameters(t *testing.T) {
874
883
require .NoError (t , err )
875
884
876
885
// Update the workspace
886
+ ctx := testutil .Context (t , testutil .WaitLong )
877
887
inv , root = clitest .New (t , "update" , "my-workspace" )
888
+ inv .WithContext (ctx )
878
889
clitest .SetupConfig (t , member , root )
879
890
doneChan := make (chan struct {})
880
891
pty := ptytest .New (t ).Attach (inv )
@@ -898,6 +909,6 @@ func TestUpdateValidateRichParameters(t *testing.T) {
898
909
}
899
910
}
900
911
901
- <- doneChan
912
+ _ = testutil . RequireRecvCtx ( ctx , t , doneChan )
902
913
})
903
914
}
0 commit comments