Status checking#7
Conversation
There was a problem hiding this comment.
Seems like passing in code is done purely for testing purposes; it'd be better to not do so and instead find some other way to set the status, probably by mocking a Service object.
Also I don't quite understand why exact was added; what's wrong with always being exact, or always being fuzzy?
There was a problem hiding this comment.
Passing code to method allows error checking, because monit stores codes in status and error flags in status_hint.
There was a problem hiding this comment.
I'm confused, then; how does code allow error checking? Shouldn't has_errors? already have all the information it needs between the Service object and the constants you've added?
There was a problem hiding this comment.
Monit has many errors flags. Argument code allows testing of special error codes. If you call has_errors? without arguments then it just determine presence of errors.
There was a problem hiding this comment.
Ah I get it now, thanks for explaining.
I guess I prefer the ActiveRecord way of doing things. .valid? doesn't let you assert against specific errors but rather only generally if there was an error. To check against specific errors, you have to check .errors
I suppose it's just personal preference, though.
|
👍 for a |
Monit service has fields
statusandstatus_hint. If error occurs then monit sets bit in status field and resets same bit in status_hint.I add constants and method for errors checking in status field.