aboutsummaryrefslogtreecommitdiffstats
path: root/tests/by-name/at/atuin-sync
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/by-name/at/atuin-sync/test.nix66
1 files changed, 43 insertions, 23 deletions
diff --git a/tests/by-name/at/atuin-sync/test.nix b/tests/by-name/at/atuin-sync/test.nix
index 627e89e..cf8f0d8 100644
--- a/tests/by-name/at/atuin-sync/test.nix
+++ b/tests/by-name/at/atuin-sync/test.nix
@@ -1,11 +1,6 @@
{
- nixos-lib,
- pkgsUnstable,
- nixpkgs-unstable,
- vhackPackages,
pkgs,
extraModules,
- nixLib,
turtle,
vhack,
...
@@ -63,9 +58,9 @@ vhack.runTest {
testScript = {nodes, ...}: let
mkSyncConfig = pkgs.writeShellScript "register-atuin-sync-account" ''
- mkdir --parents ~/.config/atuin/
+ mkdir --parents ~/.config/turtle/
- cat << EOF > ~/.config/atuin/config.toml
+ cat << EOF > ~/.config/turtle/config.toml
[sync]
address = "https://atuin-sync.server"
@@ -74,7 +69,7 @@ vhack.runTest {
EOF
'';
- runCommandAndRecordInAtuin = pkgs.writeShellScript "run-command-and-record-in-atuin" ''
+ runCommandAndRecordInTurtle = pkgs.writeShellScript "run-command-and-record-in-atuin" ''
# SPDX-SnippetBegin
# SPDX-SnippetCopyrightText: 2023 mentalisttraceur (https://github.com/mentalisttraceur)
# Source: https://github.com/atuinsh/atuin/issues/1188#issuecomment-1698354107
@@ -83,10 +78,10 @@ vhack.runTest {
local id
local status
local escaped_command="$(printf '%q ' "$@")"
- id="$(atuin history start -- "$escaped_command")"
+ id="$(turtle history start -- "$escaped_command")"
"$@"
status=$?
- atuin history end --exit $status "$id"
+ turtle history end --exit $status "$id"
return $status
}
# SPDX-SnippetEnd
@@ -102,30 +97,28 @@ vhack.runTest {
client1.wait_until_succeeds("curl https://atuin-sync.server")
with subtest("Setup client syncing"):
- # See https://docs.atuin.sh/guide/sync/
for client in [client1, client2]:
client.succeed("${mkSyncConfig}")
- with subtest("Start atuin daemons"):
+ with subtest("Start turtle daemon"):
for client in [client1, client2]:
- client.succeed("systemd-run atuin daemon start")
+ client.succeed("systemd-run turtle-daemon start")
for client in [client1, client2]:
- client.wait_until_succeeds("atuin daemon status")
+ client.wait_until_succeeds("turtle daemon status")
- with subtest("Can import shell history"):
- client1.succeed("${runCommandAndRecordInAtuin} echo hi - client 1")
- client2.succeed("${runCommandAndRecordInAtuin} echo hi - client 2")
+ with subtest("Can generate shell history"):
+ client1.succeed("${runCommandAndRecordInTurtle} echo hi - client 1")
+ client2.succeed("${runCommandAndRecordInTurtle} echo hi - client 2")
- with subtest("Can sync tasks"):
+ with subtest("Can sync"):
for client in [client1, client2]:
- client.succeed("atuin sync perform --force")
- client1.succeed("atuin sync perform --force")
-
+ client.succeed("turtle sync perform")
+ client1.succeed("turtle sync perform")
with subtest("Have correct tasks"):
- hist1 = client1.succeed("atuin history list --session --format '{command}'").strip().split('\n')
- hist2 = client2.succeed("atuin history list --session --format '{command}'").strip().split('\n')
+ hist1 = client1.succeed("turtle history list --cmd-only").strip().split('\n')
+ hist2 = client2.succeed("turtle history list --cmd-only").strip().split('\n')
hist1.sort()
hist2.sort()
@@ -137,5 +130,32 @@ vhack.runTest {
assert hist1 == hist2, f"The clients don't have the same amount of history items, client1: '{hist1}', client2: '{hist2}'"
assert hist1 == canonicalHistory, f"The history is not correct: '{hist1}' vs. '{canonicalHistory}'"
+
+ with subtest("Can sync again"):
+ client1.succeed("${runCommandAndRecordInTurtle} echo second try - client 1")
+ client2.succeed("${runCommandAndRecordInTurtle} echo second try - client 2")
+
+ for client in [client1, client2]:
+ client.succeed("turtle sync perform")
+ client1.succeed("turtle sync perform")
+
+ hist1 = client1.succeed("turtle history list --cmd-only").strip().split('\n')
+ hist2 = client2.succeed("turtle history list --cmd-only").strip().split('\n')
+
+ hist1.sort()
+ hist2.sort()
+
+ canonicalHistory = [
+ # The old history
+ "echo hi - client 1",
+ "echo hi - client 2",
+
+ # Our newly added history entries
+ "echo second try - client 1",
+ "echo second try - client 2"
+ ]
+
+ assert hist1 == hist2, f"The clients don't have the same amount of history items, client1: '{hist1}', client2: '{hist2}'"
+ assert hist1 == canonicalHistory, f"The history is not correct, got: '{hist1}', expected: '{canonicalHistory}'"
'';
}