feat(service): add pagination to GetJobs endpoint
GetJobs now accepts page/page_size query parameters and returns JobListResponse instead of raw array. Uses in-memory pagination matching GetJobHistory pattern. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -149,14 +149,17 @@ func TestGetJobs(t *testing.T) {
|
||||
defer cleanup()
|
||||
|
||||
svc := NewJobService(client, zap.NewNop())
|
||||
jobs, err := svc.GetJobs(context.Background())
|
||||
result, err := svc.GetJobs(context.Background(), &model.JobListQuery{Page: 1, PageSize: 20})
|
||||
if err != nil {
|
||||
t.Fatalf("GetJobs: %v", err)
|
||||
}
|
||||
if len(jobs) != 1 {
|
||||
t.Fatalf("expected 1 job, got %d", len(jobs))
|
||||
if result.Total != 1 {
|
||||
t.Fatalf("expected total 1, got %d", result.Total)
|
||||
}
|
||||
j := jobs[0]
|
||||
if len(result.Jobs) != 1 {
|
||||
t.Fatalf("expected 1 job, got %d", len(result.Jobs))
|
||||
}
|
||||
j := result.Jobs[0]
|
||||
if j.JobID != 100 {
|
||||
t.Errorf("expected JobID 100, got %d", j.JobID)
|
||||
}
|
||||
@@ -175,6 +178,12 @@ func TestGetJobs(t *testing.T) {
|
||||
if j.Nodes != "node01" {
|
||||
t.Errorf("expected Nodes node01, got %s", j.Nodes)
|
||||
}
|
||||
if result.Page != 1 {
|
||||
t.Errorf("expected Page 1, got %d", result.Page)
|
||||
}
|
||||
if result.PageSize != 20 {
|
||||
t.Errorf("expected PageSize 20, got %d", result.PageSize)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetJob(t *testing.T) {
|
||||
@@ -621,7 +630,7 @@ func TestJobService_GetJobs_ErrorLog(t *testing.T) {
|
||||
defer srv.Close()
|
||||
|
||||
svc, recorded := newJobServiceWithObserver(srv)
|
||||
_, err := svc.GetJobs(context.Background())
|
||||
_, err := svc.GetJobs(context.Background(), &model.JobListQuery{Page: 1, PageSize: 20})
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user