mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2026-07-17 18:30:21 +00:00
TestServe started the server in a goroutine that captured Serve's return value, slept two seconds, then called assert.NoError on it. The test body returned immediately after Shutdown without ever joining that goroutine, so the assertion ran after the test had already been recorded as passed and could never affect its result (a dead assertion). It was also wrong: closing the listener in Shutdown makes Serve return a net.ErrClosed error, not nil. Capture Serve's error over a buffered channel and assert it synchronously in the test body after Shutdown, checking it wraps net.ErrClosed so the check actually runs within the test's lifetime and catches an unexpected Serve failure. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com> Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>