Integration tests against Zenodo sandbox#45
Conversation
Add integration test scaffolding that runs against the real Zenodo sandbox API. - Tests for search records, communities, and licenses - Requires ZENODO_SANDBOX_TOKEN env var (skipped otherwise) - Build tag `integration` separates from unit tests - GitHub Actions workflow: manual trigger + weekly schedule - Tests timeout at 120s Closes #20 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces integration tests for the Zenodo CLI that run against the actual Zenodo sandbox API, providing end-to-end validation beyond the existing unit tests that use mock HTTP servers. The tests are isolated using Go build tags and only execute when a sandbox token is configured.
Changes:
- Added three integration tests covering records search, communities search, and licenses search
- Created a GitHub Actions workflow to run integration tests weekly and on-demand
- Used build tag
integrationto separate integration tests from unit tests
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/integration/records_test.go | Three integration test functions with sandbox client helper |
| .github/workflows/integration.yml | CI workflow with weekly schedule and manual trigger |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: "1.24" |
There was a problem hiding this comment.
The go-version is set to "1.24" which is inconsistent with go.mod that specifies "go 1.25.7". The workflow should use the same Go version as specified in go.mod to ensure consistent behavior between local development and CI environments. Consider updating this to "1.25" or "1.25.7" to match go.mod.
| go-version: "1.24" | |
| go-version: "1.25.7" |
| if result.Hits.Total < 0 { | ||
| t.Error("expected non-negative total") |
There was a problem hiding this comment.
The assertion "result.Hits.Total < 0" checks for negative values, but this is a very weak test. Since this is an integration test against a real sandbox, it would be more useful to verify that the search actually returns some results when querying "test". Consider changing this to check that Total is greater than 0, or at minimum use ">= 0" with a comment explaining why an empty result set is acceptable for this particular query.
| if result.Hits.Total < 0 { | |
| t.Error("expected non-negative total") | |
| if result.Hits.Total == 0 { | |
| t.Error("expected at least one record matching 'test'") |
| result, err := client.SearchCommunities("", 1, 5) | ||
| if err != nil { | ||
| t.Fatalf("SearchCommunities error: %v", err) | ||
| } |
There was a problem hiding this comment.
The SearchCommunities test doesn't include any assertions about the result beyond checking for errors. For an integration test, it would be more valuable to verify that the API returns a reasonable response, such as checking that result.Hits.Total is non-negative, or that when listing without a query the sandbox returns at least some communities.
| } | |
| } | |
| if result.Hits.Total < 0 { | |
| t.Error("expected non-negative total number of communities") | |
| } | |
| if result.Hits.Total == 0 { | |
| t.Error("expected at least one community in the sandbox for empty query") | |
| } |
ELI5
Unit tests use fake HTTP servers, but you also want to occasionally test against the real Zenodo sandbox to make sure nothing's drifted. These tests do that — they call the actual sandbox API to search records, communities, and licenses. They only run when you have a sandbox token set, and there's a GitHub Action to run them weekly or on-demand.
Summary
integrationso they don't run in normalgo testZENODO_SANDBOX_TOKENis not setCode changes
test/integration/records_test.go.github/workflows/integration.ymlTest plan
go test ./...— all 75 unit tests pass (integration tests excluded)go build ./...compilesCloses #20
🤖 Generated with Claude Code