about summary refs log tree commit diff
path: root/nixos/tests/zsh-history.nix
blob: 64f32a07e2158b7452c3bba7b7c663b4e869e90d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "zsh-history";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ ];
  };

  nodes.default = { ... }: {
    programs = {
      zsh.enable = true;
    };
    environment.systemPackages = [ pkgs.zsh-history ];
    programs.zsh.interactiveShellInit = ''
      source ${pkgs.zsh-history.out}/share/zsh/init.zsh
    '';
    users.users.root.shell = "${pkgs.zsh}/bin/zsh";
  };

  testScript = ''
    start_all()
    default.wait_for_unit("multi-user.target")
    default.wait_until_succeeds("pgrep -f 'agetty.*tty1'")

    # Login
    default.wait_until_tty_matches("1", "login: ")
    default.send_chars("root\n")
    default.wait_until_tty_matches("1", r"\nroot@default\b")

    # Generate some history
    default.send_chars("echo foobar\n")
    default.wait_until_tty_matches("1", "foobar")

    # Ensure that command was recorded in history
    default.succeed("/run/current-system/sw/bin/history list | grep -q foobar")
  '';
})