-
Notifications
You must be signed in to change notification settings - Fork 87
main: add regression test for aws upload target arch error #1032
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?
Conversation
2b4f7e6
to
5202cbd
Compare
5202cbd
to
1853fc9
Compare
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.
I would not do this, a global variable is sub-par even for testing. The function called handleAWSFlags
should have an argument that takes an interface, an uploader. The real code would pass a real implementation while the test would pass a mock.
Also, it smells like function called "handle flags" is perhaps doing too much and should be broken into smaller pieces, or maybe renamed to "initialize AWS".
Saying "it's sub-par even for testing" is a strong statement. Sometimes the dependency injection approach, sometimes the monkey patching approach is more appropriate. This style of having a var to mock is something I have seen in many go projects. Here is an example where we used it to make things easier (vs dependency injection) https://github.com/osbuild/bootc-image-builder/pull/1018/files - i.e. monkey patching can often avoid making the API more involved just so that its testable on the expense of an (internal) var like here. |
1853fc9
to
fe6143e
Compare
I am sorry but I see this and the linked patch as inferior solution to the problem. (Small) interfaces are cornerstone of Go, I see no reason why My acceptance threshold for monkey-patching is likely very different from yours. Granted I spent 10 years working on a massive Ruby on Rails project where this was bread and butter and learned to I hate it. Anyway, this isn't a review, I was just randomly commenting. Please carry on. |
While I agree that testing every function with monkey patching is silly (and dependency injection is super useful) I guess we have to agree to disagree. If used with discipline and in a predictable pattern (i.e. not random messing with global state but very controlled and predictable) I think monkey patching is a fine tool and often avoids extra complications that would otherwise be needed. |
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.
I think we should break the main
package into multiple files or even packages after this is merged into ibcli.
} | ||
|
||
func TestHandleAWSFlags(t *testing.T) { | ||
|
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.
Intentional empty line?
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.
No, silly me. I will fix it (thanks!)
fe6143e
to
d090739
Compare
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.
Needs a rebase.
This is a regression test to ensure the commandline handling of aws upload is correct. Its a followup for osbuild#1030
d090739
to
679249a
Compare
This is a regression test to ensure the commandline handling
of aws upload is correct. Its a followup for
#1030