-
Notifications
You must be signed in to change notification settings - Fork 37
fix(iaas): print valid JSON/YAML output for list cmds #1365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
70b932b
14cca95
972a75e
7f78cf8
936bb00
07bb839
f015fae
7fb466a
2e13f98
fd6ccb0
6752d88
3f6a8be
8e34092
51fb3e1
4661dc5
e0db653
b3afc4b
f8d2829
bf4718f
a888af1
02db11e
42eafa4
48e9f80
b663d3d
777630a
8885e05
e72a115
4083b93
ee1b411
9b8c40d
de440de
f25cdc0
2a3e7ee
884f8c7
d24108d
dac4b2a
3e80ea6
68c108c
81e4c72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,23 +141,40 @@ func TestBuildRequest(t *testing.T) { | |
| } | ||
|
|
||
| func TestOutputResult(t *testing.T) { | ||
| type args struct { | ||
| outputFormat string | ||
| projectLabel string | ||
| instances []iaas.AffinityGroup | ||
| } | ||
| tests := []struct { | ||
| description string | ||
| model inputModel | ||
| response []iaas.AffinityGroup | ||
| args args | ||
| isValid bool | ||
| }{ | ||
| { | ||
| description: "empty", | ||
| model: inputModel{}, | ||
| response: []iaas.AffinityGroup{}, | ||
| args: args{}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You changed that testcase with that change. The Valid testcase, but be aware what you're doing here. As commented above the question is why you changed the method signature at all? 😄
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for reminding that the case differs, honestly I don't know if I was aware of that when editing but I am now. 😄 I would suggest maybe having both cases tested. |
||
| isValid: true, | ||
| }, | ||
| { | ||
| description: "empty slice", | ||
| args: args{ | ||
| instances: []iaas.AffinityGroup{}, | ||
| }, | ||
| isValid: true, | ||
| }, | ||
| { | ||
| description: "empty affinity group in slice", | ||
| args: args{ | ||
| instances: []iaas.AffinityGroup{{}}, | ||
| }, | ||
| isValid: true, | ||
| }, | ||
| } | ||
| params := testparams.NewTestParams() | ||
| for _, tt := range tests { | ||
| t.Run(tt.description, func(t *testing.T) { | ||
| err := outputResult(params.Printer, tt.model, tt.response) | ||
| err := outputResult(params.Printer, tt.args.outputFormat, tt.args.projectLabel, tt.args.instances) | ||
| if err != nil { | ||
| if !tt.isValid { | ||
| return | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this and the method signature?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looked weird at first glance that the signature differed from all other outputResult functions. I also could not see a benefit from passing the model into the function. Furthermore I also think the state that is checked in the function will not happen, since if the input model will be nil and the outputResult function cannot be called. But maybe I am overseeing something here. Should I change it to the old signature?