Skip to content

Instantly share code, notes, and snippets.

@joseivanlopez
Last active November 26, 2019 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseivanlopez/712b8b4232cf836253acb950339b9758 to your computer and use it in GitHub Desktop.
Save joseivanlopez/712b8b4232cf836253acb950339b9758 to your computer and use it in GitHub Desktop.

Goal

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).

How to do it

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment