MCPcopy Index your code
hub / github.com/coder/agentapi / TestServer_Stop_Idempotency

Function TestServer_Stop_Idempotency

lib/httpapi/server_test.go:961–992  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

959}
960
961func TestServer_Stop_Idempotency(t *testing.T) {
962 t.Parallel()
963 ctx := logctx.WithLogger(context.Background(), slog.New(slog.NewTextHandler(os.Stdout, nil)))
964
965 srv, err := httpapi.NewServer(ctx, httpapi.ServerConfig{
966 AgentType: msgfmt.AgentTypeClaude,
967 AgentIO: nil,
968 Port: 0,
969 ChatBasePath: "/chat",
970 AllowedHosts: []string{"*"},
971 AllowedOrigins: []string{"*"},
972 })
973 require.NoError(t, err)
974
975 // First call to Stop should succeed
976 stopCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
977 defer cancel()
978 err = srv.Stop(stopCtx)
979 require.NoError(t, err)
980
981 // Second call to Stop should also succeed (no-op)
982 stopCtx2, cancel2 := context.WithTimeout(context.Background(), 5*time.Second)
983 defer cancel2()
984 err = srv.Stop(stopCtx2)
985 require.NoError(t, err)
986
987 // Third call to Stop should also succeed (no-op)
988 stopCtx3, cancel3 := context.WithTimeout(context.Background(), 5*time.Second)
989 defer cancel3()
990 err = srv.Stop(stopCtx3)
991 require.NoError(t, err)
992}

Callers

nothing calls this directly

Calls 3

StopMethod · 0.95
WithLoggerFunction · 0.92
NewServerFunction · 0.92

Tested by

no test coverage detected