diff options
author | Morgan Helton <mhelton@gmail.com> | 2022-12-15 21:07:15 -0600 |
---|---|---|
committer | Morgan Helton <mhelton@gmail.com> | 2022-12-15 21:07:15 -0600 |
commit | a935888d452387d6ae5d96d87662c8d8388b8f43 (patch) | |
tree | 9b11a2fde0588005a2ef46a7d314ea238cb4cac0 /nixos/tests/atuin.nix | |
parent | 823d4b7e8cae198ed3cbbb52a00fe9e7eaef27e6 (diff) |
nixos/atuin: init module
Diffstat (limited to 'nixos/tests/atuin.nix')
-rw-r--r-- | nixos/tests/atuin.nix | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/nixos/tests/atuin.nix b/nixos/tests/atuin.nix new file mode 100644 index 0000000000000..85213d1e53eac --- /dev/null +++ b/nixos/tests/atuin.nix @@ -0,0 +1,65 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: + +let + testPort = 8888; + testUser = "testerman"; + testPass = "password"; + testEmail = "test.testerman@test.com"; +in +with lib; +{ + name = "atuin"; + meta.maintainers = with pkgs.lib.maintainers; [ devusb ]; + + nodes = { + server = + { ... }: + { + services.atuin = { + enable = true; + port = testPort; + host = "0.0.0.0"; + openFirewall = true; + openRegistration = true; + }; + }; + + client = + { ... }: + { }; + + }; + + testScript = with pkgs; '' + start_all() + + # wait for atuin server startup + server.wait_for_unit("atuin.service") + server.wait_for_open_port(${toString testPort}) + + # configure atuin client on server node + server.execute("mkdir -p ~/.config/atuin") + server.execute("echo 'sync_address = \"http://localhost:${toString testPort}\"' > ~/.config/atuin/config.toml") + + # register with atuin server on server node + server.succeed("${atuin}/bin/atuin register -u ${testUser} -p ${testPass} -e ${testEmail}") + _, key = server.execute("${atuin}/bin/atuin key") + + # store test record in atuin server and sync + server.succeed("ATUIN_SESSION=$(${atuin}/bin/atuin uuid) ${atuin}/bin/atuin history start 'shazbot'") + server.succeed("${atuin}/bin/atuin sync") + + # configure atuin client on client node + client.execute("mkdir -p ~/.config/atuin") + client.execute("echo 'sync_address = \"http://server:${toString testPort}\"' > ~/.config/atuin/config.toml") + + # log in to atuin server on client node + client.succeed(f"${atuin}/bin/atuin login -u ${testUser} -p ${testPass} -k {key}") + + # pull records from atuin server + client.succeed("${atuin}/bin/atuin sync -f") + + # check for test record + client.succeed("ATUIN_SESSION=$(${atuin}/bin/atuin uuid) ${atuin}/bin/atuin history list | grep shazbot") + ''; +}) |