Skip to content

Add sandbox integration tests #52

@ran-codes

Description

@ran-codes

This is a v0.2+ feature as release v0.1 doesn't havea any write actions; sandbox is useful for write/edit/publish testing

Summary

Our unit tests mock API responses, but the mocks can be wrong. In PR #51, a unit test passed with a fake response shape that didn't match the real Zenodo API — the bug shipped because the cardboard cutout didn't look like the real opponent.

See .claude/reference/v0.1/bugs/integrated-testing.md for full write-up.

Problem

  • Unit tests only verify "if the API returns X, does the CLI do Y?"
  • They cannot verify "does the API actually return X?"
  • Wrong assumptions about response shapes, endpoints, and field names go undetected
  • This caused three bugs in a single session: wrong endpoint, wrong return type, verbose table dump

Proposal

Add integration tests that hit sandbox.zenodo.org with a real token, gated behind ZENODO_SANDBOX_TOKEN env var. Tests skip gracefully when the token is absent.

Use Context7 MCP to pull live Zenodo API documentation when generating test cases — this ensures mocks and assertions match the actual API spec rather than relying on assumptions.

Action Items

Ideation

  • Decide which API methods need integration test coverage (list records, search, get record, deposit CRUD, versions)
  • Decide on test data strategy — create fixtures in sandbox once, or create/teardown per test run?
  • Evaluate if recorded fixtures (VCR-style) are worth adding alongside live tests
  • Investigate using Context7 to fetch Zenodo API docs for generating accurate test cases and mocks

Planning

  • Define the integration test file structure (e.g. *_integration_test.go with build tags)
  • Document sandbox account setup steps for contributors
  • Plan GitHub Actions workflow to run integration tests with a secret token
  • Define workflow for using Context7 to validate API response shapes before writing mocks

Implementation

  • Create sandbox.zenodo.org account and generate API token
  • Use Context7 to pull current Zenodo API docs and verify endpoint response schemas
  • Write integration tests for ListUserRecords, SearchRecords, GetRecord, ListVersions
  • Write integration test for table output formatting with real API data
  • Generate/update unit test mocks using Context7-sourced API documentation
  • Add ZENODO_SANDBOX_TOKEN as GitHub Actions secret
  • Add CI workflow step that runs integration tests when token is available
  • Update DEVELOP.md with instructions for running integration tests locally

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions