effectVMTest
effectVMTest :: Module → Derivation
Create offline tests for effect functions.
This returns a derivation that tests one or more effects using a NixOS VM test.
Full example: test for the ssh
function
Parameter
The only parameter is a test module. It is mixed in with the NixOS VM test framework and `hercules-ci-effects’ own options.
effects.<name>
An attribute set of effects. These can be run with
Example:
effectVMTest {
effects = {
hello = mkEffect { /* ... */ };
};
nodes.foo = {
# ... A NixOS configuration running SSH or
# any other relevant service. ...
}
testScript = ''
# ... setup ...
agent.succeed("effect-hello")
# ... assertions ...
'';
}
secrets.<name>
Secrets to make available to the effects. These are added to the store, so don’t copy real-world secrets into this!
Example:
effectVMTest {
secrets.deploykey.data = {
publicKey = builtins.readFile ./test/id.pub;
privateKey = builtins.readFile ./test/id;
};
effects.deploy = mkEffect {
secretsMap.ssh = "deploykey";
# ...
};
nodes.target = { ... }: {
users.users.root.openssh.authorizedKeys.keyFiles = [ ./test/id.pub ];
};
}
nodes.agent
The hercules-ci-effects
framework adds this VM. It is responsible for running the effects.
You could modify the settings of this node, but most settings have no effect and the effects,
because effects run in a sandbox.
Other nodes can be defined in nodes.<name>
as usual.
*
For the other options, refer to the NixOS VM test framework documentation.