@@ -440,7 +440,7 @@ func TestPluginNoLogging(t *testing.T) {
440
440
}
441
441
}
442
442
443
- func TestPluginStartTriggerManual (t * testing.T ) {
443
+ func TestPluginStartTriggerManualStart (t * testing.T ) {
444
444
445
445
fixture := newTestFixture (t , nil )
446
446
fixture .server .ch = make (chan UpdateRequestV1 )
@@ -476,22 +476,45 @@ func TestPluginStartTriggerManual(t *testing.T) {
476
476
if ! maps .Equal (result .Labels , exp .Labels ) {
477
477
t .Fatalf ("Expected: %v but got: %v" , exp , result )
478
478
}
479
+ }
480
+
481
+ func TestPluginStartTriggerManual (t * testing.T ) {
482
+ fixture := newTestFixture (t , nil )
483
+ fixture .server .ch = make (chan UpdateRequestV1 )
484
+ defer fixture .server .stop ()
485
+ tr := plugins .TriggerManual
486
+ fixture .plugin .config .Trigger = & tr
479
487
480
488
status := testStatus ()
481
489
482
490
fixture .plugin .BulkUpdateBundleStatus (map [string ]* bundle.Status {"test" : status })
483
491
484
- // make sure the lastBundleStatuses has been written so the trigger sends the expected status
485
- // otherwise there could be a race condition before the bundle status is written
486
- time .Sleep (10 * time .Millisecond )
492
+ statuses := <- fixture .plugin .bulkBundleCh
493
+ fixture .plugin .lastBundleStatuses = statuses
487
494
488
495
// trigger the status update
489
496
go func () {
490
- _ = fixture .plugin .Trigger (ctx )
497
+ _ = fixture .plugin .Trigger (context . Background () )
491
498
}()
492
499
493
- result = <- fixture .server .ch
500
+ go func () {
501
+ update := <- fixture .plugin .trigger
502
+ err := fixture .plugin .oneShot (update .ctx )
503
+ if err != nil {
504
+ t .Error (err )
505
+ return
506
+ }
507
+ }()
508
+
509
+ result := <- fixture .server .ch
494
510
511
+ exp := UpdateRequestV1 {
512
+ Labels : map [string ]string {
513
+ "id" : "test-instance-id" ,
514
+ "app" : "example-app" ,
515
+ "version" : version .Version ,
516
+ },
517
+ }
495
518
exp .Bundles = map [string ]* bundle.Status {"test" : status }
496
519
497
520
if ! maps .EqualFunc (result .Bundles , exp .Bundles , (* bundle .Status ).Equal ) {
0 commit comments