Skip to content

chore: Add dependency graph marshal tests#4254

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

chore: Add dependency graph marshal tests#4254
KirtiRamchandani wants to merge 2 commits into
google:masterfrom
KirtiRamchandani:test/dependency-graph-marshal

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

Problem
Dependency graph and SBOM resource structs are newer API payloads, but their JSON marshal behavior was not covered by the resource-level marshal tests tracked by #55.

Root cause
The existing dependency graph tests focus on service request/response behavior. They do not round-trip the shared SBOM, dependency snapshot, manifest, detector, job, and creation response structs directly.

Solution
Add focused marshal tests for empty and populated dependency graph resource types, including SBOM metadata, package external refs, relationships, snapshot manifests, resolved dependencies, and snapshot creation data.

Tests run

  • gofmt -w github/dependency_graph_marshal_test.go
  • go test ./github -run 'Test(SBOM|CreationInfo|RepoDependencies|PackageExternalRef|SBOMRelationship|SBOMInfo|DependencyGraphSnapshot.*)_Marshal'
  • go test ./github
  • go test ./...
  • git diff --cached --check

Linked issue
Part of #55

@gmlewis gmlewis changed the title Add dependency graph marshal tests chore: Add dependency graph marshal tests May 26, 2026
Comment thread github/dependency_graph_marshal_test.go Outdated
@@ -0,0 +1,371 @@
// Copyright 2023 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.

Instead of creating a new file for this, please delete this file and add the tests to the end of the already-existing dependency_graph_test.go.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label May 26, 2026
@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 (c393feb).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4254   +/-   ##
=======================================
  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, moved the marshal tests into the existing dependency_graph_test.go file and removed the standalone test file. Reran the focused marshal test group, go test ./github, go test ./..., and git 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