Skip to content

Conversation

@yuvraj-kolkar17
Copy link

What type of PR is this?

/kind test
/area attestations

What this PR does / why we need it:
This PR adds a complete unit test suite for the logic defined in internal/attestations/github.go.

Coverage Improvement

File Previous Coverage New Coverage
github.go 49.2% 83.1%

Before vs After Coverage:

Before Coverage After Coverage

Which issue(s) this PR fixes:
#463

Does this PR introduce a user-facing change?
None

@kusari-inspector
Copy link

kusari-inspector bot commented Jul 24, 2025

Kusari Analysis Results

Analysis for commit: bbf0f32, performed at: 2025-08-11T20:49:59Z

@kusari-inspector rerun - Trigger a re-analysis of this PR

@kusari-inspector feedback [your message] - Send feedback to our AI and team


Recommendation

✅ PROCEED with this Pull Request

Summary

No Flagged Issues Detected

All values appear to be within acceptable risk parameters.

No pinned version dependency changes, code issues or exposed secrets detected!

Found this helpful? Give it a 👍 or 👎 reaction!

@patzielinski
Copy link
Collaborator

This looks to affect the same code tests as #995. I'll take a look if there's anything that is still untested after that one is merged.

@yuvraj-kolkar17
Copy link
Author

Thank you for the update @patzielinski
Since PR #995 covers similar areas, I’ll wait for it to be merged or closed. Meanwhile, I will like to pick up other areas in the project where I can help improve tests or coverage and contribute. Please suggest if any ?

@patzielinski
Copy link
Collaborator

@yuvraj-kolkar17 Please feel free to take a look at https://coveralls.io/github/gittuf/gittuf, the coverage report for gittuf. Most files that don't have decent coverage can be worked on to better their coverage.

@patzielinski patzielinski force-pushed the test-github-go-coverage branch from 05455ef to 371c083 Compare August 11, 2025 20:45
@kusari-inspector
Copy link

Kusari PR Analysis rerun based on - 371c083 performed at: 2025-08-11T20:45:38Z - link to updated analysis

@patzielinski patzielinski force-pushed the test-github-go-coverage branch from 371c083 to bbf0f32 Compare August 11, 2025 20:49
@kusari-inspector
Copy link

Kusari PR Analysis rerun based on - bbf0f32 performed at: 2025-08-11T20:49:59Z - link to updated analysis

Co-authored-by: Yongjae Chung <[email protected]>
Signed-off-by: yuvraj Kolkar <[email protected]>
@patzielinski patzielinski force-pushed the test-github-go-coverage branch from bbf0f32 to ab41e72 Compare October 7, 2025 16:12
attestations := &Attestations{}

// This should fail validation
err := attestations.SetGitHubPullRequestApprovalAttestation(repo, invalidEnv, baseURL, 1, appName, testRef, testID, testID)
Copy link
Member

Choose a reason for hiding this comment

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

This case shouldn't be under TestGetGitHubPullRequestApprovalAttestation I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@adityasaky Seems like we already test for validation in a different test file:

func TestValidatePullRequestApproval(t *testing.T) {

Should we get rid of this particular test case here then? Should we factor it out to a different test function?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that we can probably put this case under TestSetGitHubPullRequestApprovalAttestation.

Copy link
Member

Choose a reason for hiding this comment

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

I could see it either way, do we see a coverage difference with and without this specific case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, we cover an addition line where validation errors. I'll go ahead and move the test case under TestSetGitHubPullRequestApprovalAttestation.


// Try to get attestation with invalid URL
_, err := attestations.GetGitHubPullRequestApprovalAttestationForReviewID(repo, "invalid-url", 123, "github")
assert.NotNil(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a specific error we can test for here?

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.

4 participants