1
2# `redisTestHook` {#sec-redisTestHook}
3
4This hook starts a Redis server during `checkPhase`. Example:
5
6```nix
7{
8 stdenv,
9 redis,
10 redisTestHook,
11}:
12stdenv.mkDerivation {
13
14 # ...
15
16 nativeCheckInputs = [
17 redisTestHook
18 ];
19}
20```
21
22If you use a custom `checkPhase`, remember to add the `runHook` calls:
23```nix
24{
25 checkPhase = ''
26 runHook preCheck
27
28 # ... your tests
29
30 runHook postCheck
31 '';
32}
33```
34
35## Variables {#sec-redisTestHook-variables}
36
37The hook logic will read the following variables and set them to a default value if unset or empty.
38
39Exported variables:
40
41- `REDIS_SOCKET`: UNIX domain socket path
42
43Bash-only variables:
44
45 - `redisTestPort`: Port to use by Redis. Defaults to `6379`
46
47Example usage:
48
49```nix
50{
51 stdenv,
52 redis,
53 redisTestHook,
54}:
55stdenv.mkDerivation {
56
57 # ...
58
59 nativeCheckInputs = [
60 redisTestHook
61 ];
62
63 preCheck = ''
64 redisTestPort=6390;
65 '';
66}
67```