getBrowserNameByOS doesn't have unit tests, so I decided to add one.
Right now, it's basically a subtest that runs based on the value of runtime.GOOS since the way getBrowserNameByOS is written is only meant to handle cases where we're dealing with a darwin based OS. Not only does the unit test do that, but it tests every possible denormalized string value.
I was thinking that since the function only handles cases for a darwin OS, we can ensure that any other value for runtime.GOOS will result in a return value of a null string. While it does adhere to the current behavior, I feel like it could be overkill.
The code for it also seemed like it could have been simplified a bit for a few reasons:
variable name 'k' for the sole string argument didn't seem like it provided any context as to what the argument was
doubly nested switch, case blocks for basic logic just seemed like it could be simplified.
To ensure that my changes to the function work as intended, I created the test, ran the entire test suite and ensured it passed, modified getBrowserNameByOS, then ran tests a final time to ensure its behavior remained unchanged.
getBrowserNameByOS
doesn't have unit tests, so I decided to add one.Right now, it's basically a subtest that runs based on the value of
runtime.GOOS
since the waygetBrowserNameByOS
is written is only meant to handle cases where we're dealing with adarwin
based OS. Not only does the unit test do that, but it tests every possible denormalized string value.I was thinking that since the function only handles cases for a
darwin
OS, we can ensure that any other value forruntime.GOOS
will result in a return value of a null string. While it does adhere to the current behavior, I feel like it could be overkill.The code for it also seemed like it could have been simplified a bit for a few reasons:
switch, case
blocks for basic logic just seemed like it could be simplified.To ensure that my changes to the function work as intended, I created the test, ran the entire test suite and ensured it passed, modified
getBrowserNameByOS
, then ran tests a final time to ensure its behavior remained unchanged.