Checker¶
A checker is a core concept of tc and will feel familiar to anyone who has used the python
testtools.Assertions are made on the tc.C methods.
c.Check(err, tc.ErrorIsNil)
c.Assert(something, tc.Equals, somethingElse)
The Check method will cause the test to fail if the checker returns false, but it will continue immediately, causing
the test to fail and will continue with the test.Assert if it fails will cause the test to stop immediately.
For further discussion, we have the following parts:
c.Assert(observed, checker, args...)
The key checkers in the tc module that juju uses most frequently are:
|
The observed value must be |
|
The observed value must not be |
|
The observed value must be the same type and value as the arg, which is the expected value. |
|
Checks for equality for more complex types like slices, maps, or structures. |
|
The observed value is expected to be an |
|
A regular expression match where the observed value is a string. |
|
The expected value is an integer, and works happily on nil slices or maps. |
|
Just an easier way to say |
|
Observed value must be false. |
|
For integer or float types. |
|
For integer or float types. |
|
Obtained is expected to be a string or a |
|
The same as |
|
Obtained is a string or |
|
Obtained and expected are slices of the same type, the checker makes sure that the values in one are in the other.They do not have the be in the same order. |
|
The arg is expected to be |
|
Obtained is a string or |
|
Works similarly to |
|
Also works with a string or |