@@ -326,7 +326,7 @@ func testSubscribe(h interface{ Helper() }, numberOfSubscribers int) {
326326 for i := 0 ; i < numberOfSubscribers ; i ++ {
327327 go func () {
328328 defer wg .Done ()
329- ctx , cancel := context .WithCancel (context . Background ())
329+ ctx , cancel := context .WithCancel (t . Context ())
330330 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/books/1&topic=string&topic=http://example.com/reviews/{id}&topic=http://example.com/hub?topic=faulty{iri" , nil ).WithContext (ctx )
331331
332332 w := & responseTester {
@@ -351,7 +351,7 @@ func TestSubscribe(t *testing.T) {
351351func testSubscribeLogs (t * testing.T , hub * Hub , payload interface {}) {
352352 t .Helper ()
353353
354- ctx , cancel := context .WithCancel (context . Background ())
354+ ctx , cancel := context .WithCancel (t . Context ())
355355 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/reviews/{id}" , nil ).WithContext (ctx )
356356 req .AddCookie (& http.Cookie {Name : "mercureAuthorization" , Value : createDummyAuthorizedJWTWithPayload (roleSubscriber , []string {"http://example.com/reviews/22" }, payload )})
357357
@@ -405,7 +405,7 @@ func TestSubscribeLogAnonymousSubscriber(t *testing.T) {
405405
406406 h := createAnonymousDummy (WithLogger (zap .New (core )))
407407
408- ctx , cancel := context .WithCancel (context . Background ())
408+ ctx , cancel := context .WithCancel (t . Context ())
409409 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/" , nil ).WithContext (ctx )
410410
411411 w := & responseTester {
@@ -427,7 +427,7 @@ func TestUnsubscribe(t *testing.T) {
427427
428428 s , _ := hub .transport .(* LocalTransport )
429429 assert .Equal (t , 0 , s .subscribers .Len ())
430- ctx , cancel := context .WithCancel (context . Background ())
430+ ctx , cancel := context .WithCancel (t . Context ())
431431
432432 var wg sync.WaitGroup
433433 wg .Add (1 )
@@ -493,7 +493,7 @@ func TestSubscribePrivate(t *testing.T) {
493493 }
494494 }()
495495
496- ctx , cancel := context .WithCancel (context . Background ())
496+ ctx , cancel := context .WithCancel (t . Context ())
497497 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/reviews/{id}" , nil ).WithContext (ctx )
498498 req .AddCookie (& http.Cookie {Name : "mercureAuthorization" , Value : createDummyAuthorizedJWT (roleSubscriber , []string {"http://example.com/reviews/22" , "http://example.com/reviews/23" })})
499499
@@ -513,8 +513,8 @@ func TestSubscriptionEvents(t *testing.T) {
513513 hub := createDummy (WithSubscriptions ())
514514
515515 var wg sync.WaitGroup
516- ctx1 , cancel1 := context .WithCancel (context . Background ())
517- ctx2 , cancel2 := context .WithCancel (context . Background ())
516+ ctx1 , cancel1 := context .WithCancel (t . Context ())
517+ ctx2 , cancel2 := context .WithCancel (t . Context ())
518518 wg .Add (3 )
519519 go func () {
520520 // Authorized to receive connection events
@@ -567,7 +567,7 @@ func TestSubscriptionEvents(t *testing.T) {
567567 }
568568 }
569569
570- ctx , cancelRequest2 := context .WithCancel (context . Background ())
570+ ctx , cancelRequest2 := context .WithCancel (t . Context ())
571571 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=https://example.com" , nil ).WithContext (ctx )
572572 req .AddCookie (& http.Cookie {Name : "mercureAuthorization" , Value : createDummyAuthorizedJWT (roleSubscriber , []string {})})
573573
@@ -617,7 +617,7 @@ func TestSubscribeAll(t *testing.T) {
617617 }
618618 }()
619619
620- ctx , cancel := context .WithCancel (context . Background ())
620+ ctx , cancel := context .WithCancel (t . Context ())
621621 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/reviews/{id}" , nil ).WithContext (ctx )
622622 req .Header .Add ("Authorization" , bearerPrefix + createDummyAuthorizedJWT (roleSubscriber , []string {"random" , "*" }))
623623
@@ -661,7 +661,7 @@ func TestSendMissedEvents(t *testing.T) {
661661 go func () {
662662 defer wg .Done ()
663663
664- ctx , cancel := context .WithCancel (context . Background ())
664+ ctx , cancel := context .WithCancel (t . Context ())
665665 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}&Last-Event-ID=a" , nil ).WithContext (ctx )
666666
667667 w := & responseTester {
@@ -677,7 +677,7 @@ func TestSendMissedEvents(t *testing.T) {
677677 go func () {
678678 defer wg .Done ()
679679
680- ctx , cancel := context .WithCancel (context . Background ())
680+ ctx , cancel := context .WithCancel (t . Context ())
681681 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}&lastEventID=a" , nil ).WithContext (ctx )
682682
683683 w := & responseTester {
@@ -693,7 +693,7 @@ func TestSendMissedEvents(t *testing.T) {
693693 go func () {
694694 defer wg .Done ()
695695
696- ctx , cancel := context .WithCancel (context . Background ())
696+ ctx , cancel := context .WithCancel (t . Context ())
697697 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}" , nil ).WithContext (ctx )
698698 req .Header .Add ("Last-Event-ID" , "a" )
699699
@@ -738,7 +738,7 @@ func TestSendAllEvents(t *testing.T) {
738738 go func () {
739739 defer wg .Done ()
740740
741- ctx , cancel := context .WithCancel (context . Background ())
741+ ctx , cancel := context .WithCancel (t . Context ())
742742 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}&lastEventID=" + EarliestLastEventID , nil ).WithContext (ctx )
743743
744744 w := & responseTester {
@@ -755,7 +755,7 @@ func TestSendAllEvents(t *testing.T) {
755755 go func () {
756756 defer wg .Done ()
757757
758- ctx , cancel := context .WithCancel (context . Background ())
758+ ctx , cancel := context .WithCancel (t . Context ())
759759 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}" , nil ).WithContext (ctx )
760760 req .Header .Add ("Last-Event-ID" , EarliestLastEventID )
761761
@@ -795,7 +795,7 @@ func TestUnknownLastEventID(t *testing.T) {
795795 go func () {
796796 defer wg .Done ()
797797
798- ctx , cancel := context .WithCancel (context . Background ())
798+ ctx , cancel := context .WithCancel (t . Context ())
799799 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}&lastEventID=unknown" , nil ).WithContext (ctx )
800800
801801 w := & responseTester {
@@ -813,7 +813,7 @@ func TestUnknownLastEventID(t *testing.T) {
813813 go func () {
814814 defer wg .Done ()
815815
816- ctx , cancel := context .WithCancel (context . Background ())
816+ ctx , cancel := context .WithCancel (t . Context ())
817817 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}" , nil ).WithContext (ctx )
818818 req .Header .Add ("Last-Event-ID" , "unknown" )
819819
@@ -864,7 +864,7 @@ func TestUnknownLastEventIDEmptyHistory(t *testing.T) {
864864 go func () {
865865 defer wg .Done ()
866866
867- ctx , cancel := context .WithCancel (context . Background ())
867+ ctx , cancel := context .WithCancel (t . Context ())
868868 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}&lastEventID=unknown" , nil ).WithContext (ctx )
869869
870870 w := & responseTester {
@@ -882,7 +882,7 @@ func TestUnknownLastEventIDEmptyHistory(t *testing.T) {
882882 go func () {
883883 defer wg .Done ()
884884
885- ctx , cancel := context .WithCancel (context . Background ())
885+ ctx , cancel := context .WithCancel (t . Context ())
886886 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/foos/{id}" , nil ).WithContext (ctx )
887887 req .Header .Add ("Last-Event-ID" , "unknown" )
888888
@@ -942,7 +942,7 @@ func TestSubscribeHeartbeat(t *testing.T) {
942942 }
943943 }()
944944
945- ctx , cancel := context .WithCancel (context . Background ())
945+ ctx , cancel := context .WithCancel (t . Context ())
946946 req := httptest .NewRequest (http .MethodGet , defaultHubURL + "?topic=http://example.com/books/1&topic=http://example.com/reviews/{id}" , nil ).WithContext (ctx )
947947
948948 w := & responseTester {
0 commit comments