The goal is to be able to add unit-test for snapper CLI commands. For example, check that user-given parameters are right, check that correct libsnapper calls are performed (e.g., a call for creating a snapshot would be perfomed), and check that commands returns expected output (e.g., with csv format, etc).
To support unit-test we need to prepare the code for that. And we can do it at different layers. Very roughly, we can see these layers in the snapper code:
CLI command
|
|
Proxy classes
|
|
libsnapper
|
|
system calls
Most of CLI commands use Proxy classes but there are some commands that use libsnapper directly. So we have the following options to prepare the code for unit-test:
-
Add a test implementation for the Proxy classes
-
Add a test implementation at libsnapper level to avoid system calls.