55
66 "github.com/cli/cli/v2/pkg/cmd/attestation/io"
77 "github.com/cli/cli/v2/pkg/cmd/attestation/test/data"
8-
98 "github.com/stretchr/testify/require"
109)
1110
@@ -17,7 +16,8 @@ const (
1716
1817func NewClientWithMockGHClient (hasNextPage bool ) Client {
1918 fetcher := mockDataGenerator {
20- NumAttestations : 5 ,
19+ NumUserAttestations : 5 ,
20+ NumGitHubAttestations : 4 ,
2121 }
2222 l := io .NewTestHandler ()
2323
@@ -47,12 +47,21 @@ var testFetchParamsWithOwner = FetchParams{
4747 Limit : DefaultLimit ,
4848 Owner : testOwner ,
4949 PredicateType : "https://slsa.dev/provenance/v1" ,
50+ Initiator : "user" ,
5051}
5152var testFetchParamsWithRepo = FetchParams {
5253 Digest : testDigest ,
5354 Limit : DefaultLimit ,
5455 Repo : testRepo ,
5556 PredicateType : "https://slsa.dev/provenance/v1" ,
57+ Initiator : "user" ,
58+ }
59+
60+ var testFetchParamsWithRepoWithGitHubInitiator = FetchParams {
61+ Digest : testDigest ,
62+ Limit : DefaultLimit ,
63+ Repo : testRepo ,
64+ Initiator : "github" ,
5665}
5766
5867type getByTestCase struct {
@@ -93,6 +102,11 @@ var getByTestCases = []getByTestCase{
93102 expectedAttestations : 7 ,
94103 hasNextPage : true ,
95104 },
105+ {
106+ name : "get by digest with repo and GitHub initiator" ,
107+ params : testFetchParamsWithRepoWithGitHubInitiator ,
108+ expectedAttestations : 4 ,
109+ },
96110}
97111
98112func TestGetByDigest (t * testing.T ) {
@@ -115,7 +129,7 @@ func TestGetByDigest(t *testing.T) {
115129
116130func TestGetByDigest_NoAttestationsFound (t * testing.T ) {
117131 fetcher := mockDataGenerator {
118- NumAttestations : 5 ,
132+ NumUserAttestations : 5 ,
119133 }
120134
121135 httpClient := & mockHttpClient {}
@@ -135,7 +149,7 @@ func TestGetByDigest_NoAttestationsFound(t *testing.T) {
135149
136150func TestGetByDigest_Error (t * testing.T ) {
137151 fetcher := mockDataGenerator {
138- NumAttestations : 5 ,
152+ NumUserAttestations : 5 ,
139153 }
140154
141155 c := LiveClient {
@@ -339,7 +353,7 @@ func TestGetAttestationsRetries(t *testing.T) {
339353 getAttestationRetryInterval = 0
340354
341355 fetcher := mockDataGenerator {
342- NumAttestations : 5 ,
356+ NumUserAttestations : 5 ,
343357 }
344358
345359 c := & LiveClient {
@@ -369,7 +383,7 @@ func TestGetAttestationsMaxRetries(t *testing.T) {
369383 getAttestationRetryInterval = 0
370384
371385 fetcher := mockDataGenerator {
372- NumAttestations : 5 ,
386+ NumUserAttestations : 5 ,
373387 }
374388
375389 c := & LiveClient {
0 commit comments