hollywood icon indicating copy to clipboard operation
hollywood copied to clipboard

examples/restarts: avoid using global variables

Open yarcat opened this issue 1 year ago • 2 comments

This PR introduces the following changes:

  1. Avoid using global variables. Even for examples. Especially when it makes the code shorter.
  2. Move done() invocation after the print statement. Because of the async nature of Go, it happens that sometimes "I restarted and processed ..." message was printed, and sometimes it wasn't. Now it is always printed.

yarcat avatar Mar 17 '24 20:03 yarcat

In general, I feel like global variables in hollywood tests are OK. global variables reduce testability, but in the tests themselves they're not at all harmfull.

Hollywood has a test style that is very terse and to the point, something I've learned to appreciate.

This is still a valuable PR, but I wouldn't spend time hunting for global variable use in the tests. :-)

perbu avatar Mar 23 '24 07:03 perbu

In general, I feel like global variables in hollywood tests are OK. global variables reduce testability, but in the tests themselves they're not at all harmfull.

Hollywood has a test style that is very terse and to the point, something I've learned to appreciate.

This is still a valuable PR, but I wouldn't spend time hunting for global variable use in the tests. :-)

I have an allergy for global variables. In 99% case they could be replaced with something else, which is localized. Even for tests. And this PR is one of these cases.

yarcat avatar Mar 23 '24 11:03 yarcat