summaryrefslogtreecommitdiff
path: root/internal/api/executions_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/executions_test.go')
-rw-r--r--internal/api/executions_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/api/executions_test.go b/internal/api/executions_test.go
index a2bba21..45548ad 100644
--- a/internal/api/executions_test.go
+++ b/internal/api/executions_test.go
@@ -258,6 +258,26 @@ func TestGetExecutionLog_FollowSSEHeaders(t *testing.T) {
}
}
+func TestListRecentExecutions_LimitClamped(t *testing.T) {
+ srv, _ := testServer(t)
+
+ req := httptest.NewRequest("GET", "/api/executions?limit=10000000", nil)
+ w := httptest.NewRecorder()
+ srv.Handler().ServeHTTP(w, req)
+
+ if w.Code != http.StatusOK {
+ t.Fatalf("status: want 200, got %d; body: %s", w.Code, w.Body.String())
+ }
+ // The handler should not pass limit > maxLimit to the store.
+ // We verify indirectly: if the query param is accepted without error and
+ // does not cause a panic or 500, the clamp is in effect.
+ // A direct assertion requires a mock store; here we check the response is valid.
+ var execs []storage.RecentExecution
+ if err := json.NewDecoder(w.Body).Decode(&execs); err != nil {
+ t.Fatalf("decoding response: %v", err)
+ }
+}
+
func TestListTasks_ReturnsStateField(t *testing.T) {
srv, store := testServer(t)
createTaskWithState(t, store, "state-check", task.StateRunning)