Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_aliases.aug
1 (*
2 Module: Test_Aliases
3   Provides unit tests and examples for the <Aliases> lens.
4 *)
5
6 module Test_aliases =
7
8 (* Variable: file
9    A full configuration file *)
10   let file = "#
11 #  Aliases in this file will NOT be expanded in the header from
12 #  Mail, but WILL be visible over networks or from /bin/mail.
13
14 # Basic system aliases -- these MUST be present.
15 mailer-daemon:  postmaster
16 postmaster:     root
17
18 # General redirections for pseudo accounts.
19 bin:            root , adm,
20   bob
21 daemon:         root
22 adm:            root
23 file:           /var/foo
24 pipe1:          |/bin/ls
25 pipe2 :         |\"/usr/bin/ls args,\"
26 "
27
28 (* Test: Aliases.lns
29    Testing <Aliases.lns> on <file> *)
30   test Aliases.lns get file =
31     { }
32     { "#comment" = "Aliases in this file will NOT be expanded in the header from" }
33     { "#comment" = "Mail, but WILL be visible over networks or from /bin/mail." }
34     {}
35     { "#comment" = "Basic system aliases -- these MUST be present." }
36     { "1" { "name" = "mailer-daemon" }
37           { "value" = "postmaster" } }
38     { "2" { "name" = "postmaster" }
39           { "value" = "root" } }
40     {}
41     { "#comment" = "General redirections for pseudo accounts." }
42     { "3" { "name" = "bin" }
43           { "value" = "root" }
44           { "value" = "adm" }
45           { "value" = "bob" } }
46     { "4" { "name" = "daemon" }
47           { "value" = "root" } }
48     { "5" { "name" = "adm" }
49           { "value" = "root" } }
50     { "6" { "name" = "file" }
51           { "value" = "/var/foo" } }
52     { "7" { "name" = "pipe1" }
53           { "value" = "|/bin/ls" } }
54     { "8" { "name" = "pipe2" }
55           { "value" = "|\"/usr/bin/ls args,\"" } }
56
57 (* Test: Aliases.lns
58    Put test for <Aliases.lns> on <file> *)
59   test Aliases.lns put file after
60     rm "/4" ; rm "/5" ; rm "/6" ; rm "/7" ; rm "/8" ;
61       set "/1/value[2]" "barbar" ;
62       set "/3/value[2]" "ruth"
63     = "#
64 #  Aliases in this file will NOT be expanded in the header from
65 #  Mail, but WILL be visible over networks or from /bin/mail.
66
67 # Basic system aliases -- these MUST be present.
68 mailer-daemon:  postmaster, barbar
69 postmaster:     root
70
71 # General redirections for pseudo accounts.
72 bin:            root , ruth,
73   bob
74 "
75
76   (* Test: Aliases.lns
77      Schema violation, no 3/name *)
78   test Aliases.lns put file after
79       rm "/3" ;
80       set "/3/value/2" "ruth"
81     = *
82
83   (* Variable: nocomma
84      Don't have to have whitespace after a comma *)
85   let nocomma = "alias: target1,target2\n"
86
87   (* Test: Aliases.lns
88      Testing <Aliases.lns> on <nocomma> *)
89   test Aliases.lns get nocomma =
90     { "1"
91         { "name" = "alias" }
92         { "value" = "target1" }
93         { "value" = "target2" } }
94
95   (* Test: Aliases.lns
96      Ticket #229: commands can be fully enclosed in quotes *)
97   test Aliases.lns get "somebody: \"|exit 67\"\n" =
98     { "1"
99         { "name" = "somebody" }
100         { "value" = "\"|exit 67\"" } }
101
102   (* Test: Aliases.lns
103      Don't have to have whitespace after the colon *)
104   test Aliases.lns get "alias:target\n" =
105     { "1"
106         { "name" = "alias" }
107         { "value" = "target" } }
108
109 (* Local Variables: *)
110 (* mode: caml       *)
111 (* End:             *)