@@ -174,36 +174,43 @@ func TestOutputResult(t *testing.T) {
174174 tests := []struct {
175175 description string
176176 projectId string
177- keyRings [] kms.KeyRing
177+ resp * kms.KeyRingList
178178 outputFormat string
179179 projectLabel string
180180 wantErr bool
181181 }{
182182 {
183183 description : "nil response" ,
184- keyRings : nil ,
184+ resp : nil ,
185+ projectId : uuid .NewString (),
186+ projectLabel : "my-project" ,
187+ wantErr : true ,
188+ },
189+ {
190+ description : "empty response" ,
191+ resp : & kms.KeyRingList {},
185192 projectId : uuid .NewString (),
186193 projectLabel : "my-project" ,
187194 wantErr : true ,
188195 },
189196 {
190197 description : "default output" ,
191198 projectId : uuid .NewString (),
192- keyRings : []kms.KeyRing {},
199+ resp : & kms. KeyRingList { KeyRings : & []kms.KeyRing {} },
193200 projectLabel : "my-project" ,
194201 wantErr : false ,
195202 },
196203 {
197204 description : "json output" ,
198205 projectId : uuid .NewString (),
199- keyRings : []kms.KeyRing {},
206+ resp : & kms. KeyRingList { KeyRings : & []kms.KeyRing {} },
200207 outputFormat : print .JSONOutputFormat ,
201208 wantErr : false ,
202209 },
203210 {
204211 description : "yaml output" ,
205212 projectId : uuid .NewString (),
206- keyRings : []kms.KeyRing {},
213+ resp : & kms. KeyRingList { KeyRings : & []kms.KeyRing {} },
207214 outputFormat : print .YAMLOutputFormat ,
208215 wantErr : false ,
209216 },
@@ -213,7 +220,7 @@ func TestOutputResult(t *testing.T) {
213220 p .Cmd = NewCmd (& params.CmdParams {Printer : p })
214221 for _ , tt := range tests {
215222 t .Run (tt .description , func (t * testing.T ) {
216- err := outputResult (p , tt .outputFormat , tt .projectId , tt .keyRings )
223+ err := outputResult (p , tt .outputFormat , tt .projectId , tt .resp )
217224 if (err != nil ) != tt .wantErr {
218225 t .Errorf ("outputResult() error = %v, wantErr %v" , err , tt .wantErr )
219226 }
0 commit comments