1import ./make-test-python.nix ({ pkgs, lib, ... }:
2
3let
4 testPort = 8888;
5 testUser = "testerman";
6 testPass = "password";
7 testEmail = "test.testerman@test.com";
8in
9{
10 name = "atuin";
11 meta.maintainers = with lib.maintainers; [ devusb ];
12
13 nodes = {
14 server =
15 { ... }:
16 {
17 services.postgresql.enable = true;
18
19 services.atuin = {
20 enable = true;
21 port = testPort;
22 host = "0.0.0.0";
23 openFirewall = true;
24 openRegistration = true;
25 };
26 };
27
28 client =
29 { ... }:
30 { };
31
32 };
33
34 testScript = with pkgs; ''
35 start_all()
36
37 # wait for atuin server startup
38 server.wait_for_unit("atuin.service")
39 server.wait_for_open_port(${toString testPort})
40
41 # configure atuin client on server node
42 server.execute("mkdir -p ~/.config/atuin")
43 server.execute("echo 'sync_address = \"http://localhost:${toString testPort}\"' > ~/.config/atuin/config.toml")
44
45 # register with atuin server on server node
46 server.succeed("${atuin}/bin/atuin register -u ${testUser} -p ${testPass} -e ${testEmail}")
47 _, key = server.execute("${atuin}/bin/atuin key")
48
49 # store test record in atuin server and sync
50 server.succeed("ATUIN_SESSION=$(${atuin}/bin/atuin uuid) ${atuin}/bin/atuin history start 'shazbot'")
51 server.succeed("${atuin}/bin/atuin sync")
52
53 # configure atuin client on client node
54 client.execute("mkdir -p ~/.config/atuin")
55 client.execute("echo 'sync_address = \"http://server:${toString testPort}\"' > ~/.config/atuin/config.toml")
56
57 # log in to atuin server on client node
58 client.succeed(f"${atuin}/bin/atuin login -u ${testUser} -p ${testPass} -k \"{key}\"")
59
60 # pull records from atuin server
61 client.succeed("${atuin}/bin/atuin sync -f")
62
63 # check for test record
64 client.succeed("ATUIN_SESSION=$(${atuin}/bin/atuin uuid) ${atuin}/bin/atuin history list | grep shazbot")
65 '';
66})