Skip to content
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

Default states #80

Merged
merged 2 commits into from
Jun 5, 2023
Merged

Default states #80

merged 2 commits into from
Jun 5, 2023

Conversation

RincewindsHat
Copy link
Member

Allow setting of default states for partial results.
This solves a problem where partialResults are generated dynamically
later in the code and a program would need to remember the state itself outside
of this library to generate the results correctly

Lorenz Kästle added 2 commits June 5, 2023 12:20
This commit hides the "state" attribute of partial results
and implements a Setter for it.
This way it can remember if the state was set explicitely
or not.

In combination with the default state, it is now possible
to set a default state which is used, if NO partial results and NO
explicit states are set later.

An example:

var subcheck PartialResult
subcheck.SetDefaultState(check.Warning)

will create a PartialResult which returns Warning if nothing else
happens.
If I now, later in the code either add PartialResults or set the state
explicitely, this is overriden.

This way application code does not need to remember in what state
it put a PartialResult previously, but can just set a sane default
at the beginning.
@pdorschner pdorschner merged commit 183ebf0 into master Jun 5, 2023
@RincewindsHat RincewindsHat deleted the default_states branch June 19, 2023 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants