summaryrefslogtreecommitdiffstats
path: root/nixos/tests/locale.nix
blob: 6c1ef5e3724f607d4a45c71504eb1e15c32af077 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ ... }:
{
  name = "imperative-locale";
  meta.maintainers = [ ];

  nodes = {
    node_static =
      { ... }:
      {
        i18n = {
          defaultLocale = "lt_LT.UTF-8";
          extraLocales = [ "en_US.UTF-8/UTF-8" ];
        };
      };

    node_imperative =
      { ... }:
      {
        i18n = {
          defaultLocale = "lt_LT.UTF-8";
          imperativeLocale = true;
          extraLocales = [ "en_US.UTF-8/UTF-8" ];
        };
      };
  };

  testScript =
    { ... }:
    ''
      node_static.wait_for_unit("dbus.socket")

      with subtest("static - declared locale is reported by localectl"):
          node_static.succeed("localectl status | grep -q 'System Locale: LANG=lt_LT.UTF-8'")

      with subtest("static - localectl set-locale is blocked"):
          node_static.fail("localectl set-locale LANG=en_US.UTF-8")
          node_static.succeed("localectl status | grep -q 'System Locale: LANG=lt_LT.UTF-8'")

      node_imperative.wait_for_unit("dbus.socket")

      with subtest("imperative - declared locale is reported by localectl on first boot"):
          node_imperative.succeed("localectl status | grep -q 'System Locale: LANG=lt_LT.UTF-8'")

      with subtest("imperative - localectl set-locale changes the locale"):
          node_imperative.succeed("localectl set-locale LANG=en_US.UTF-8")
          node_imperative.succeed("localectl status | grep -q 'System Locale: LANG=en_US.UTF-8'")

      with subtest("imperative - locale change persists across reboot"):
          node_imperative.shutdown()
          node_imperative.wait_for_unit("dbus.socket")
          node_imperative.succeed("localectl status | grep -q 'System Locale: LANG=en_US.UTF-8'")
    '';
}