Skip to content

Integration tests against Zenodo sandbox#45

Merged
ran-codes merged 1 commit intomainfrom
issue-20/integration-tests
Feb 17, 2026
Merged

Integration tests against Zenodo sandbox#45
ran-codes merged 1 commit intomainfrom
issue-20/integration-tests

Conversation

@ran-codes
Copy link
Copy Markdown
Owner

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

  • Integration tests for records, communities, and licenses search
  • Build-tagged integration so they don't run in normal go test
  • Gracefully skip when ZENODO_SANDBOX_TOKEN is not set
  • GitHub Actions workflow with manual dispatch + weekly schedule

Code changes

File What
test/integration/records_test.go 3 integration tests
.github/workflows/integration.yml CI workflow for integration tests

Test plan

  • go test ./... — all 75 unit tests pass (integration tests excluded)
  • go build ./... compiles

Closes #20

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings February 17, 2026 20:03
@ran-codes ran-codes merged commit 1f1ff0e into main Feb 17, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 integration to 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"
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
go-version: "1.24"
go-version: "1.25.7"

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +33
if result.Hits.Total < 0 {
t.Error("expected non-negative total")
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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'")

Copilot uses AI. Check for mistakes.
result, err := client.SearchCommunities("", 1, 5)
if err != nil {
t.Fatalf("SearchCommunities error: %v", err)
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
}
}
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")
}

Copilot uses AI. Check for mistakes.
@ran-codes ran-codes deleted the issue-20/integration-tests branch February 18, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration tests against Zenodo sandbox

2 participants