@@ -422,7 +422,7 @@ func TestJavaRoutes_ExtractRoutes(t *testing.T) {
422422 return NewReaderCloser (strings .NewReader (tt .mockOutput )), nil
423423 }}
424424
425- result , err := harvester .ExtractRoutes (tt .pid )
425+ result , err := harvester .ExtractRoutes (context . Background (), tt .pid )
426426
427427 if tt .expectedError {
428428 require .Error (t , err )
@@ -458,7 +458,7 @@ Header: ...
458458 return NewReaderCloser (strings .NewReader (symbolTableOutput )), nil
459459 }}
460460
461- result , err := harvester .ExtractRoutes (1234 )
461+ result , err := harvester .ExtractRoutes (context . Background (), 1234 )
462462
463463 require .NoError (t , err )
464464 require .NotNil (t , result )
@@ -478,7 +478,7 @@ Header: ...
478478 assert .Equal (t , expectedRoutes , result .Routes )
479479}
480480
481- func TestJavaRoutes_ExtractRoutesContext_ClosesReaderOnCancellation (t * testing.T ) {
481+ func TestJavaRoutes_ExtractRoutes_ClosesReaderOnCancellation (t * testing.T ) {
482482 harvester := NewJavaRoutesHarvester ()
483483 ctx , cancel := context .WithCancel (context .Background ())
484484 defer cancel ()
@@ -494,7 +494,7 @@ func TestJavaRoutes_ExtractRoutesContext_ClosesReaderOnCancellation(t *testing.T
494494
495495 errCh := make (chan error , 1 )
496496 go func () {
497- _ , err := harvester .ExtractRoutesContext (ctx , 1234 )
497+ _ , err := harvester .ExtractRoutes (ctx , 1234 )
498498 errCh <- err
499499 }()
500500
@@ -520,6 +520,20 @@ func TestJavaRoutes_ExtractRoutesContext_ClosesReaderOnCancellation(t *testing.T
520520 }
521521}
522522
523+ func TestJavaRoutes_ExtractRoutes_ReturnsPartialResultWhenAttachIsUnsupported (t * testing.T ) {
524+ harvester := NewJavaRoutesHarvester ()
525+ harvester .Attacher = FakeJavaAttacher {attachFunc : func (context.Context , app.PID , []string , bool ) (io.ReadCloser , error ) {
526+ return nil , nil
527+ }}
528+
529+ result , err := harvester .ExtractRoutes (context .Background (), 1234 )
530+
531+ require .NoError (t , err )
532+ require .NotNil (t , result )
533+ assert .Nil (t , result .Routes )
534+ assert .Equal (t , PartialRoutes , result .Kind )
535+ }
536+
523537func TestRegexPatterns (t * testing.T ) {
524538 t .Run ("validURLPath regex" , func (t * testing.T ) {
525539 validPaths := []string {
@@ -663,11 +677,7 @@ func (j FakeJavaAttacher) Init() {
663677func (j FakeJavaAttacher ) Cleanup () {
664678}
665679
666- func (j FakeJavaAttacher ) Attach (pid app.PID , argv []string , ignoreOnJ9 bool ) (io.ReadCloser , error ) {
667- return j .AttachContext (context .Background (), pid , argv , ignoreOnJ9 )
668- }
669-
670- func (j FakeJavaAttacher ) AttachContext (ctx context.Context , pid app.PID , argv []string , ignoreOnJ9 bool ) (io.ReadCloser , error ) {
680+ func (j FakeJavaAttacher ) Attach (ctx context.Context , pid app.PID , argv []string , ignoreOnJ9 bool ) (io.ReadCloser , error ) {
671681 return j .attachFunc (ctx , pid , argv , ignoreOnJ9 )
672682}
673683
0 commit comments