You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cmd/util/testutils: Add RunCmdAssertion test function (#330)
Adds a new function to the `testutils` package which allow easier
testing to be written on the `cmd` layer.
All the heavy lifting is done by `testutils.RunCmdAssertion` on the test
function, namely it:
1. Initializes the `ecctl.App` singleton from a `testutils.MockCfg`.
2. Sets the cobra `cmd.Command` Err and Out to `*Bytes.Buffer`s.
3. Executes the command with the specified Args.
4. Asserts the returned errors by `cmd.Execute()`
5. Asserts the written data to both the `Err` and `Out` buffers.
6. `ecctl.Cleanup` is called before returning so no instance is set.
It is important to note that global flags won't be parsed and instead,
must be provided as values to `testutils.MockCfg`. As new global flags
are added, the structure should be maintained to contain these.
Interaction with the `stdin` hasn't been written yet, but it will be a
follow-up patch.
Last, the tracker utils have been modified to use `DefaultTestFrequency`
when the host equals `api.DefaultMockHost` for ease of testing.
Signed-off-by: Marc Lopez <marc5.12@outlook.com>
0 commit comments