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