Skip to content

Interfaces

David Aronchick edited this page Feb 13, 2022 · 2 revisions

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)

https://github.com/filecoin-project/bacalhau/pull/27/files#diff-fbde87a30b2f9a52272230d598e497e141720032d24218d83a2e9d7a7d223f8aR48

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

Clone this wiki locally