]> ruderich.org/simon Gitweb - safcm/safcm.git/blob - remote/sync/triggers_test.go
Use SPDX license identifiers
[safcm/safcm.git] / remote / sync / triggers_test.go
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright (C) 2021-2024  Simon Ruderich
3
4 package sync
5
6 import (
7         "testing"
8
9         "ruderich.org/simon/safcm/testutil"
10 )
11
12 func TestTriggerPaths(t *testing.T) {
13         tests := []struct {
14                 name string
15                 path string
16                 exp  []string
17         }{
18
19                 {
20                         "root",
21                         "/",
22                         []string{"/"},
23                 },
24
25                 {
26                         "absolute path",
27                         "/foo/bar/baz",
28                         []string{"/", "/foo", "/foo/bar", "/foo/bar/baz"},
29                 },
30
31                 {
32                         "dot",
33                         ".",
34                         []string{"."},
35                 },
36
37                 {
38                         "relative path (for tests)",
39                         "foo/bar/baz",
40                         []string{".", "foo", "foo/bar", "foo/bar/baz"},
41                 },
42         }
43
44         for _, tc := range tests {
45                 t.Run(tc.name, func(t *testing.T) {
46                         res := triggerPaths(tc.path)
47                         testutil.AssertEqual(t, "res", res, tc.exp)
48                 })
49         }
50 }