@@ -109,13 +109,16 @@ func TestProcess_BrokenModelConfig(t *testing.T) {
109109 req := httptest .NewRequest ("GET" , "/" , nil )
110110 w := httptest .NewRecorder ()
111111 process .ProxyRequest (w , req )
112- assert .Equal (t , http .StatusBadGateway , w .Code )
113- assert .Contains (t , w .Body .String (), "unable to start process" )
112+ assert .Equal (t , http .StatusBadGateway , w .Code ) // First attempt fails to start
113+ assert .Contains (t , w .Body .String (), "unable to start process: start() failed: exec: \" nonexistent-command\" : executable file not found in $PATH" )
114+ assert .Equal (t , StateFailed , process .CurrentState ()) // Should be in failed state after first attempt
114115
116+ // Second request should also attempt to start and fail similarly due to recovery logic
115117 w = httptest .NewRecorder ()
116118 process .ProxyRequest (w , req )
117- assert .Equal (t , http .StatusServiceUnavailable , w .Code )
118- assert .Contains (t , w .Body .String (), "Process can not ProxyRequest, state is failed" )
119+ assert .Equal (t , http .StatusBadGateway , w .Code ) // Second attempt also fails to start
120+ assert .Contains (t , w .Body .String (), "unable to start process: start() failed: exec: \" nonexistent-command\" : executable file not found in $PATH" )
121+ assert .Equal (t , StateFailed , process .CurrentState ()) // Should end up in failed state again
119122}
120123
121124func TestProcess_UnloadAfterTTL (t * testing.T ) {
@@ -266,7 +269,7 @@ func TestProcess_SwapState(t *testing.T) {
266269 {"Ready to Starting" , StateReady , StateReady , StateStarting , ErrInvalidStateTransition , StateReady },
267270 {"Ready to Failed" , StateReady , StateReady , StateFailed , ErrInvalidStateTransition , StateReady },
268271 {"Stopping to Ready" , StateStopping , StateStopping , StateReady , ErrInvalidStateTransition , StateStopping },
269- {"Failed to Stopped" , StateFailed , StateFailed , StateStopped , ErrInvalidStateTransition , StateFailed },
272+ {"Failed to Stopped" , StateFailed , StateFailed , StateStopped , nil , StateStopped },
270273 {"Failed to Starting" , StateFailed , StateFailed , StateStarting , ErrInvalidStateTransition , StateFailed },
271274 {"Shutdown to Stopped" , StateShutdown , StateShutdown , StateStopped , ErrInvalidStateTransition , StateShutdown },
272275 {"Shutdown to Starting" , StateShutdown , StateShutdown , StateStarting , ErrInvalidStateTransition , StateShutdown },
0 commit comments