]> ruderich.org/simon Gitweb - safcm/safcm.git/blob - cmd/safcm-remote/sync/triggers_test.go
config: disallow negative permissions
[safcm/safcm.git] / cmd / safcm-remote / sync / triggers_test.go
1 // Copyright (C) 2021  Simon Ruderich
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 package sync
17
18 import (
19         "testing"
20
21         "ruderich.org/simon/safcm/testutil"
22 )
23
24 func TestTriggerPaths(t *testing.T) {
25         tests := []struct {
26                 name string
27                 path string
28                 exp  []string
29         }{
30
31                 {
32                         "root",
33                         "/",
34                         []string{"/"},
35                 },
36
37                 {
38                         "absolute path",
39                         "/foo/bar/baz",
40                         []string{"/", "/foo", "/foo/bar", "/foo/bar/baz"},
41                 },
42
43                 {
44                         "dot",
45                         ".",
46                         []string{"."},
47                 },
48
49                 {
50                         "relative path (for tests)",
51                         "foo/bar/baz",
52                         []string{".", "foo", "foo/bar", "foo/bar/baz"},
53                 },
54         }
55
56         for _, tc := range tests {
57                 t.Run(tc.name, func(t *testing.T) {
58                         res := triggerPaths(tc.path)
59                         testutil.AssertEqual(t, "res", res, tc.exp)
60                 })
61         }
62 }