File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -459,11 +459,22 @@ func (ts *testServerImpl) pollListeningURLFile() error {
459459// Start runs the process, returning an error on any problems,
460460// including being unable to start, but not unexpected failure.
461461// It should only be called once in the lifetime of a TestServer object.
462+ // If the server is already running, this function is a no-op.
463+ // If the server stopped or failed, please don't use ts.Start()
464+ // to restart a testserver, but use NewTestServer().
462465func (ts * testServerImpl ) Start () error {
463466 ts .mu .Lock ()
464467 if ts .state != stateNew {
465468 ts .mu .Unlock ()
466- return errors .New ("Start() can only be called once" )
469+ switch ts .state {
470+ case stateRunning :
471+ return nil // No-op if server is already running.
472+ case stateStopped , stateFailed :
473+ // Start() can only be called once.
474+ return errors .New (
475+ "Start() cannot be used to restart a stopped or failed server. " +
476+ "Please use NewTestServer()" )
477+ }
467478 }
468479 ts .state = stateRunning
469480 ts .mu .Unlock ()
You can’t perform that action at this time.
0 commit comments