@@ -380,6 +380,7 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) {
380
380
}
381
381
}
382
382
383
+ //nolint:tparallel // Sub tests need to run sequentially.
383
384
func TestAgent_Session_TTY_MOTD_Update (t * testing.T ) {
384
385
t .Parallel ()
385
386
if runtime .GOOS == "windows" {
@@ -439,33 +440,38 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
439
440
}
440
441
//nolint:dogsled // Allow the blank identifiers.
441
442
conn , client , _ , _ , _ := setupAgent (t , agentsdk.Manifest {}, 0 , setSBInterval )
442
- for _ , test := range tests {
443
+
444
+ sshClient , err := conn .SSHClient (ctx )
445
+ require .NoError (t , err )
446
+ t .Cleanup (func () {
447
+ _ = sshClient .Close ()
448
+ })
449
+
450
+ //nolint:paralleltest // These tests need to swap the banner func.
451
+ for i , test := range tests {
443
452
test := test
444
- // Set new banner func and wait for the agent to call it to update the
445
- // banner.
446
- ready := make (chan struct {}, 2 )
447
- client .SetServiceBannerFunc (func () (codersdk.ServiceBannerConfig , error ) {
448
- select {
449
- case ready <- struct {}{}:
450
- default :
451
- }
452
- return test .banner , nil
453
- })
454
- <- ready
455
- <- ready // Wait for two updates to ensure the value has propagated.
453
+ t .Run (fmt .Sprintf ("%d" , i ), func (t * testing.T ) {
454
+ // Set new banner func and wait for the agent to call it to update the
455
+ // banner.
456
+ ready := make (chan struct {}, 2 )
457
+ client .SetServiceBannerFunc (func () (codersdk.ServiceBannerConfig , error ) {
458
+ select {
459
+ case ready <- struct {}{}:
460
+ default :
461
+ }
462
+ return test .banner , nil
463
+ })
464
+ <- ready
465
+ <- ready // Wait for two updates to ensure the value has propagated.
456
466
457
- sshClient , err := conn .SSHClient (ctx )
458
- require .NoError (t , err )
459
- t .Cleanup (func () {
460
- _ = sshClient .Close ()
461
- })
462
- session , err := sshClient .NewSession ()
463
- require .NoError (t , err )
464
- t .Cleanup (func () {
465
- _ = session .Close ()
466
- })
467
+ session , err := sshClient .NewSession ()
468
+ require .NoError (t , err )
469
+ t .Cleanup (func () {
470
+ _ = session .Close ()
471
+ })
467
472
468
- testSessionOutput (t , session , test .expected , test .unexpected , nil )
473
+ testSessionOutput (t , session , test .expected , test .unexpected , nil )
474
+ })
469
475
}
470
476
}
471
477
0 commit comments