Skip to content

Add unit and integration tests for GitLab trigger sources #1186

@geoffjay

Description

@geoffjay

Summary

Add unit and integration tests for the GitLab trigger source implementations, covering API response parsing, task mapping, error handling, pagination, and configuration resolution.

Context

The existing GitHub implementation has unit tests for JSON parsing (parse_gh_issues, parse_gh_pull_requests) that verify the response-to-Task mapping. The GitLab implementation needs equivalent coverage plus tests for the config resolution (following the pattern from linear.rs).

Acceptance Criteria

Unit Tests (in crates/orchestrator/src/scheduler/gitlab.rs)

  • Test parse_gitlab_issues() helper:
    • Standard issue with all fields populated
    • Issue with null/missing description
    • Issue with empty assignees array
    • Issue with multiple labels
    • Empty response array
  • Test parse_gitlab_merge_requests() helper:
    • Standard MR with branch info and merge status
    • Draft MR (draft: true)
    • MR with no assignees
    • Metadata correctly populated: source_branch, target_branch, merge_status, draft
    • Empty response array
  • Test GitlabConfig::resolve():
    • Env var takes precedence over config file
    • Config file fallback works
    • Error when neither is set
    • Custom AGENTD_GITLAB_URL overrides default
    • is_configured() returns correct boolean
  • Test TriggerConfig deserialization:
    • gitlab_issues YAML parses correctly with defaults
    • gitlab_merge_requests YAML parses correctly
    • State defaults to "opened" when omitted
    • assignee and assignees fields are optional

Integration Tests

  • Test full TriggerConfig round-trip: serialize to JSON, deserialize back, verify fields
  • Test trigger_type() returns correct strings
  • Test SourceTemplate parsing from YAML (in apply.rs test module)

Key Files

  • crates/orchestrator/src/scheduler/gitlab.rs - unit tests module
  • crates/cli/src/commands/apply.rs - SourceTemplate parsing tests

Blocked By

  • The GitlabIssueSource implementation issue
  • The GitlabMergeRequestSource implementation issue

Stack Base

Branch off: feature/autonomous-pipeline
Blocked by: #1181, #1182

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-testsArea needs dedicated test coverage

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions