@@ -55,101 +55,107 @@ func (suite *GetAttestationCommandTestSuite) TestGetAttestationCmd() {
5555 tests := []cmdTestCase {
5656 {
5757 wantError : false ,
58- name : "if no attestation found, say so" ,
58+ name : "01 if no attestation found when getting by name , say so" ,
5959 cmd : fmt .Sprintf (`get attestation non-existent-attestation --flow %s --trail %s %s` , suite .flowName , suite .trailName , suite .defaultKosliArguments ),
6060 golden : "No attestations found.\n " ,
6161 },
6262 {
6363 wantError : false ,
64- name : "if no attestation found return empty list in json format" ,
64+ name : "02 if no attestation found when getting by name return empty list in json format" ,
6565 cmd : fmt .Sprintf (`get attestation non-existent-attestation --flow %s --trail %s %s --output json` , suite .flowName , suite .trailName , suite .defaultKosliArguments ),
6666 goldenJson : []jsonCheck {{"" , "[]" }},
6767 },
6868 {
6969 wantError : true ,
70- name : "providing more than one argument fails" ,
70+ name : "03 providing more than one argument fails" ,
7171 cmd : fmt .Sprintf (`get attestation first-attestation second-attestation --flow %s --trail %s %s` , suite .flowName , suite .trailName , suite .defaultKosliArguments ),
7272 golden : "Error: accepts at most 1 arg(s), received 2\n " ,
7373 },
7474 {
7575 wantError : true ,
76- name : "missing --flow fails when ATTESTATION-NAME is provided" ,
76+ name : "04 missing --flow fails when ATTESTATION-NAME is provided" ,
7777 cmd : fmt .Sprintf (`get attestation first-artifact-attestation --trail %s %s` , suite .trailName , suite .defaultKosliArguments ),
78- golden : "Error: required flag(s) \" flow \" not set \n " ,
78+ golden : "Error: --flow is required when using ATTESTATION-NAME \n " ,
7979 },
8080 {
8181 wantError : true ,
82- name : "missing --api-token fails" ,
82+ name : "05 missing --api-token fails" ,
8383 cmd : fmt .Sprintf (`get attestation first-artifact-attestation --flow %s --org orgX` , suite .flowName ),
8484 golden : "Error: --api-token is not set\n Usage: kosli get attestation [ATTESTATION-NAME] [flags]\n " ,
8585 },
8686 {
87- name : "getting an existing trail attestation works" ,
87+ name : "06 getting an existing trail attestation works" ,
8888 cmd : fmt .Sprintf (`get attestation first-trail-attestation --flow %s --trail %s %s` , suite .flowName , suite .trailName , suite .defaultKosliArguments ),
8989 },
9090 {
91- name : "getting an existing trail attestation with --output json works" ,
91+ name : "07 getting an existing trail attestation with --output json works" ,
9292 cmd : fmt .Sprintf (`get attestation first-trail-attestation --flow %s --trail %s --output json %s` , suite .flowName , suite .trailName , suite .defaultKosliArguments ),
9393 goldenJson : []jsonCheck {{"" , "non-empty" }},
9494 },
9595 {
96- name : "getting an existing artifact attestation works" ,
96+ name : "08 getting an existing artifact attestation works" ,
9797 cmd : fmt .Sprintf (`get attestation first-artifact-attestation --flow %s --fingerprint %s %s` , suite .flowName , suite .fingerprint , suite .defaultKosliArguments ),
9898 },
9999 {
100- name : "getting an existing artifact attestation with --output json works" ,
100+ name : "09 getting an existing artifact attestation with --output json works" ,
101101 cmd : fmt .Sprintf (`get attestation first-artifact-attestation --flow %s --fingerprint %s --output json %s` , suite .flowName , suite .fingerprint , suite .defaultKosliArguments ),
102102 goldenJson : []jsonCheck {{"" , "non-empty" }},
103103 },
104104 {
105105 wantError : true ,
106- name : "missing both trail and fingerprint fails" ,
106+ name : "10 missing both trail and fingerprint fails if ATTESTATION-NAME provided " ,
107107 cmd : fmt .Sprintf (`get attestation first-artifact-attestation --flow %s %s` , suite .flowName , suite .defaultKosliArguments ),
108- golden : "Error: at least one of --trail, --fingerprint is required\n " ,
108+ golden : "Error: at least one of --trail, --fingerprint is required when using ATTESTATION-NAME \n " ,
109109 },
110110 {
111111 wantError : true ,
112- name : "providing both trail and fingerprint fails" ,
112+ name : "11 providing both trail and fingerprint fails" ,
113113 cmd : fmt .Sprintf (`get attestation first-artifact-attestation --flow %s --trail %s --fingerprint %s %s` , suite .flowName , suite .trailName , suite .fingerprint , suite .defaultKosliArguments ),
114- golden : "Error: only one of --trail, --fingerprint is allowed\n " ,
114+ golden : "Error: only one of --trail, --fingerprint is allowed when using ATTESTATION-NAME \n " ,
115115 },
116116 {
117- name : "can get an attestation from its id" ,
117+ name : "12 can get an attestation from its id" ,
118118 cmd : fmt .Sprintf (`get attestation --attestation-id %s %s` , suite .attestationId , suite .defaultKosliArguments ),
119119 },
120+ {
121+ wantError : false ,
122+ name : "13 if no attestation found when getting by name, say so" ,
123+ cmd : fmt .Sprintf (`get attestation --attestation-id %s %s` , "non-existent-attestation-id" , suite .defaultKosliArguments ),
124+ golden : "No attestations found.\n " ,
125+ },
120126 {
121127 wantError : false ,
122- name : "if no attestation found when getting by id return empty list in json format" ,
128+ name : "14 if no attestation found when getting by id return empty list in json format" ,
123129 cmd : fmt .Sprintf (`get attestation --attestation-id %s --output json %s` , "non-existent-attestation-id" , suite .defaultKosliArguments ),
124130 goldenJson : []jsonCheck {{"data" , "length:0" }},
125131 },
126132 {
127133 wantError : true ,
128- name : "providing both attestation id and attestation name fails" ,
134+ name : "15 providing both attestation id and attestation name fails" ,
129135 cmd : fmt .Sprintf (`get attestation %s --attestation-id %s %s` , "first-artifact-attestation" , suite .attestationId , suite .defaultKosliArguments ),
130136 golden : "Error: --attestation-id cannot be used when ATTESTATION-NAME is provided\n " ,
131137 },
132138 {
133139 wantError : true ,
134- name : "providing both attestation id and trail fails" ,
140+ name : "16 providing both attestation id and trail fails" ,
135141 cmd : fmt .Sprintf (`get attestation --attestation-id %s --trail %s %s` , suite .attestationId , suite .trailName , suite .defaultKosliArguments ),
136142 golden : "Error: --flow, --trail, and --fingerprint flags cannot be used with --attestation-id\n " ,
137143 },
138144 {
139145 wantError : true ,
140- name : "providing both attestation id and fingerprint fails" ,
146+ name : "17 providing both attestation id and fingerprint fails" ,
141147 cmd : fmt .Sprintf (`get attestation --attestation-id %s --fingerprint %s %s` , suite .attestationId , suite .fingerprint , suite .defaultKosliArguments ),
142148 golden : "Error: --flow, --trail, and --fingerprint flags cannot be used with --attestation-id\n " ,
143149 },
144150 {
145151 wantError : true ,
146- name : "providing both attestation id and flow fails" ,
152+ name : "18 providing both attestation id and flow fails" ,
147153 cmd : fmt .Sprintf (`get attestation --attestation-id %s --flow %s %s` , suite .attestationId , suite .flowName , suite .defaultKosliArguments ),
148154 golden : "Error: --flow, --trail, and --fingerprint flags cannot be used with --attestation-id\n " ,
149155 },
150156 {
151157 wantError : true ,
152- name : "providing neither attestation id or flow fails" ,
158+ name : "19 providing neither attestation id or flow fails" ,
153159 cmd : fmt .Sprintf (`get attestation %s` , suite .defaultKosliArguments ),
154160 golden : "Error: one of ATTESTATION-NAME argument or --attestation-id flag is required\n " ,
155161 },
0 commit comments