@@ -508,54 +508,6 @@ func TestServerAddResourceTemplate(t *testing.T) {
508508 }
509509}
510510
511- // TestServerSessionkeepaliveCancelOverwritten is to verify that `ServerSession.keepaliveCancel` is assigned exactly once,
512- // ensuring that only a single goroutine is responsible for the session's keepalive ping mechanism.
513- func TestServerSessionkeepaliveCancelOverwritten (t * testing.T ) {
514- // Set KeepAlive to a long duration to ensure the keepalive
515- // goroutine stays alive for the duration of the test without actually sending
516- // ping requests, since we don't have a real client connection established.
517- server := NewServer (testImpl , & ServerOptions {KeepAlive : 5 * time .Second })
518- ss := & ServerSession {server : server }
519-
520- // 1. Initialize the session.
521- _ , err := ss .initialize (context .Background (), & InitializeParams {})
522- if err != nil {
523- t .Fatalf ("ServerSession initialize failed: %v" , err )
524- }
525-
526- // 2. Call 'initialized' for the first time. This should start the keepalive mechanism.
527- _ , err = ss .initialized (context .Background (), & InitializedParams {})
528- if err != nil {
529- t .Fatalf ("First initialized call failed: %v" , err )
530- }
531- if ss .keepaliveCancel == nil {
532- t .Fatalf ("expected ServerSession.keepaliveCancel to be set after the first call of initialized" )
533- }
534-
535- // Save the cancel function and use defer to ensure resources are cleaned up.
536- firstCancel := ss .keepaliveCancel
537- defer firstCancel ()
538-
539- // 3. Manually set the field to nil.
540- // Do this to facilitate the test's core assertion. The goal is to verify that
541- // 'ss.keepaliveCancel' is not assigned a second time. By setting it to nil,
542- // we can easily check after the next call if a new keepalive goroutine was started.
543- ss .keepaliveCancel = nil
544-
545- // 4. Call 'initialized' for the second time. This should return an error.
546- _ , err = ss .initialized (context .Background (), & InitializedParams {})
547- if err == nil {
548- t .Fatalf ("Expected 'duplicate initialized received' error on second call, got nil" )
549- }
550-
551- // 5. Re-check the field to ensure it remains nil.
552- // Since 'initialized' correctly returned an error and did not call
553- // 'startKeepalive', the field should remain unchanged.
554- if ss .keepaliveCancel != nil {
555- t .Fatal ("expected ServerSession.keepaliveCancel to be nil after we manually niled it and re-initialized" )
556- }
557- }
558-
559511// panicks reports whether f() panics.
560512func panics (f func ()) (b bool ) {
561513 defer func () {
0 commit comments