-
Notifications
You must be signed in to change notification settings - Fork 89
Interfaces
Each significant object will have an interface, a "mock" and a "live" version in the bacalhau codebase.
So, for example, the "Networker" interface, it has:
- An interface file
- A live file
- A mock file
This will allow for dependency injection to each object via supporting the mock, instead of the live file.
Also, each command can be executed in test with the following structured command -
command, out, err := utils.ExecuteCommandC(suite.serveCmd, logger, "serve", "--", mocks.CALL_RUN_BACALHAU_RPC_SERVER_SUCCESSFUL_PROBE)
The arguments at the end (--
, ( can force a mock to bail out with a failure (if necessary) to test a particular code path, and be tested for.
Additionally, the cobra command instantiation of both command
and arguments
is used so that we can later test against them. This is particularly leaky and probably could be done another way - https://github.com/filecoin-project/bacalhau/pull/27/files#diff-199a649c491384b06dd53fc4ab3b14f6cf3a74397889104a2a9c8389093f9139R15