(t *testing.T)
| 959 | } |
| 960 | |
| 961 | func 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 | } |
nothing calls this directly
no test coverage detected