Skip to content

chore: Add attestation marshal tests#4253

Open
KirtiRamchandani wants to merge 2 commits into
google:masterfrom
KirtiRamchandani:test/attestations-marshal
Open

chore: Add attestation marshal tests#4253
KirtiRamchandani wants to merge 2 commits into
google:masterfrom
KirtiRamchandani:test/attestations-marshal

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

Problem
Artifact attestation payload types are shared by organization, repository, and user attestation APIs, but the shared resource structs did not have dedicated JSON marshal coverage tracked by #55.

Root cause
Existing service tests exercise API decoding paths, while the resource-level marshal round-trip tests skipped Attestation and AttestationsResponse.

Solution
Add marshal tests for empty and populated Attestation and AttestationsResponse values. The populated cases use the existing json.RawMessage comparator so Sigstore bundle JSON is compared semantically.

Tests run

  • gofmt -w github/attestations_test.go
  • go test ./github -run 'TestAttestation(sResponse)?_Marshal'
  • go test ./github
  • go test ./...
  • git diff --cached --check

Linked issue
Part of #55

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label May 26, 2026
@gmlewis gmlewis changed the title Add attestation marshal tests chore: Add attestation marshal tests May 26, 2026
Comment thread github/attestations_test.go Outdated
@@ -0,0 +1,71 @@
// Copyright 2024 The go-github AUTHORS. All rights reserved.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2024 The go-github AUTHORS. All rights reserved.
// Copyright 2026 The go-github AUTHORS. All rights reserved.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (c207b27) to head (8613564).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4253   +/-   ##
=======================================
  Coverage   97.48%   97.48%           
=======================================
  Files         190      190           
  Lines       19178    19178           
=======================================
  Hits        18695    18695           
  Misses        268      268           
  Partials      215      215           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KirtiRamchandani
Copy link
Copy Markdown
Author

Thanks, updated the new test file copyright year to 2026 and reran the focused marshal test plus diff check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants