effectVMTest

effectVMTest :: AttrSet → Derivation

Create offline tests for effect functions.

This returns a derivation that tests an effect using QEMU and nixosTest.

Parameters

name

Name of the test. Appears in the store path and in the dashboard page with the log.

Default: "unnamed"

effects

An attribute set of effects. These can be run with

Example:

effectVMTest {

  effects = {
    hello = mkEffect { /* ... */ };
  };

  testScript = ''

    # ... setup ...

    agent.succeed("effect-hello")

    # ... assertions ...

  '';
}

nodes

An attribute set of NixOS configurations. Merged into this is a node named agent, which is responsible for running the effects.

secrets

Secrets data that is made available to the effects.

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 ];
  };
}

testScript

Function to python statements. See NixOS manual: Writing Tests.