resonate icon indicating copy to clipboard operation
resonate copied to clipboard

add strict flag for assert

Open susarlanikhilesh opened this issue 9 months ago • 4 comments

Addresses Issue

susarlanikhilesh avatar May 16 '24 05:05 susarlanikhilesh

Thank you so much @susarlanikhilesh 🎉 🎉

The tests are failing because some of our tests expect a panic to occur, and if the flag is not set (eg: the code is run via a test rather than cli) I believe viper is returning the default boolean value of false. Is there a way to check if the flag is not set and, if not, set strict to true instead?

dfarr avatar May 16 '24 15:05 dfarr

Yes the strict flag is false, I did set when panic is true in the test cases

susarlanikhilesh avatar May 16 '24 17:05 susarlanikhilesh

I would prefer for strict=true in cases where not explicitly set. Our philosophy here is to panic by default when an unexpected event occurs, this way we can protect ourselves from being in an invalid state.

viper.GetBool("strict") // if not set needs to be defaulted to true

An easier way to do it might be to invert the name of the flag to something like ignore-asserts that we can default to false which makes things a little easier to implement.

dfarr avatar May 16 '24 17:05 dfarr

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 55.35%. Comparing base (9f31bbe) to head (097d546). Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #329   +/-   ##
=======================================
  Coverage   55.34%   55.35%           
=======================================
  Files         113      113           
  Lines        9885     9886    +1     
=======================================
+ Hits         5471     5472    +1     
  Misses       4052     4052           
  Partials      362      362           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 16 '24 17:05 codecov[bot]