Files
gitlore/tests/fixtures/gitlab_discussions_page.json
Taylor Eernisse f53645790a test: Add comprehensive test suite with fixtures
Establishes testing infrastructure for reliable development.

tests/fixtures/ - GitLab API response samples:
- gitlab_issue.json: Single issue with full metadata
- gitlab_issues_page.json: Paginated issue list response
- gitlab_discussion.json: Discussion thread with notes
- gitlab_discussions_page.json: Paginated discussions response
All fixtures captured from real GitLab API responses with
sensitive data redacted, ensuring tests match actual behavior.

tests/gitlab_types_tests.rs - Type deserialization tests:
- Validates serde parsing of all GitLab API types
- Tests edge cases: null fields, empty arrays, nested objects
- Ensures GitLabIssue, GitLabDiscussion, GitLabNote parse correctly
- Verifies optional fields handle missing data gracefully
- Tests author/assignee extraction from various formats

tests/fixture_tests.rs - Integration with fixtures:
- Loads fixture files and validates parsing
- Tests transformer functions produce correct database rows
- Verifies IssueWithMetadata extracts labels and assignees
- Tests NormalizedDiscussion/NormalizedNote structure
- Validates raw payload preservation logic

tests/migration_tests.rs - Database schema tests:
- Creates in-memory SQLite for isolation
- Runs all migrations and verifies schema
- Tests table creation with expected columns
- Validates foreign key constraints
- Tests index creation for query performance
- Verifies idempotent migration behavior

Test infrastructure uses:
- tempfile for isolated database instances
- wiremock for HTTP mocking (available for future API tests)
- Standard Rust #[test] attributes

Run with: cargo test
Run single: cargo test test_name
Run with output: cargo test -- --nocapture

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:29:06 -05:00

121 lines
2.9 KiB
JSON

[
{
"id": "6a9c1750b37d513a43987b574953fceb50b03ce7",
"individual_note": false,
"notes": [
{
"id": 1001,
"type": "DiscussionNote",
"body": "First threaded discussion",
"author": {
"id": 1,
"username": "testuser",
"name": "Test User"
},
"created_at": "2024-01-16T09:00:00.000Z",
"updated_at": "2024-01-16T09:00:00.000Z",
"system": false,
"resolvable": true,
"resolved": false,
"resolved_by": null,
"resolved_at": null,
"position": null
},
{
"id": 1002,
"type": "DiscussionNote",
"body": "Reply in thread",
"author": {
"id": 2,
"username": "reviewer",
"name": "Reviewer"
},
"created_at": "2024-01-16T10:00:00.000Z",
"updated_at": "2024-01-16T10:00:00.000Z",
"system": false,
"resolvable": true,
"resolved": false,
"resolved_by": null,
"resolved_at": null,
"position": null
}
]
},
{
"id": "abc123def456",
"individual_note": true,
"notes": [
{
"id": 2001,
"type": null,
"body": "A standalone comment (individual_note=true)",
"author": {
"id": 3,
"username": "commenter",
"name": "Commenter"
},
"created_at": "2024-01-17T11:30:00.000Z",
"updated_at": "2024-01-17T11:30:00.000Z",
"system": false,
"resolvable": false,
"resolved": false,
"resolved_by": null,
"resolved_at": null,
"position": null
}
]
},
{
"id": "system123note456",
"individual_note": true,
"notes": [
{
"id": 3001,
"type": null,
"body": "assigned to @reviewer",
"author": {
"id": 1,
"username": "testuser",
"name": "Test User"
},
"created_at": "2024-01-17T08:00:00.000Z",
"updated_at": "2024-01-17T08:00:00.000Z",
"system": true,
"resolvable": false,
"resolved": false,
"resolved_by": null,
"resolved_at": null,
"position": null
}
]
},
{
"id": "resolved789thread",
"individual_note": false,
"notes": [
{
"id": 4001,
"type": "DiscussionNote",
"body": "This is a resolved discussion",
"author": {
"id": 2,
"username": "reviewer",
"name": "Reviewer"
},
"created_at": "2024-01-18T14:00:00.000Z",
"updated_at": "2024-01-18T15:00:00.000Z",
"system": false,
"resolvable": true,
"resolved": true,
"resolved_by": {
"id": 1,
"username": "testuser",
"name": "Test User"
},
"resolved_at": "2024-01-18T15:00:00.000Z",
"position": null
}
]
}
]