MCPcopy Create free account
hub / github.com/compose-spec/compose-go / TestPathMatches

Function TestPathMatches

tree/path_test.go:26–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestPathMatches(t *testing.T) {
27 testcases := []struct {
28 doc string
29 path Path
30 pattern Path
31 expected bool
32 }{
33 {
34 doc: "pattern too short",
35 path: NewPath("one", "two", "three"),
36 pattern: NewPath("one", "two"),
37 },
38 {
39 doc: "pattern too long",
40 path: NewPath("one", "two"),
41 pattern: NewPath("one", "two", "three"),
42 },
43 {
44 doc: "pattern mismatch",
45 path: NewPath("one", "three", "two"),
46 pattern: NewPath("one", "two", "three"),
47 },
48 {
49 doc: "pattern mismatch with match-all part",
50 path: NewPath("one", "three", "two"),
51 pattern: NewPath(PathMatchAll, "two", "three"),
52 },
53 {
54 doc: "pattern match with match-all part",
55 path: NewPath("one", "two", "three"),
56 pattern: NewPath("one", "*", "three"),
57 expected: true,
58 },
59 {
60 doc: "pattern match",
61 path: NewPath("one", "two", "three"),
62 pattern: NewPath("one", "two", "three"),
63 expected: true,
64 },
65 }
66 for _, testcase := range testcases {
67 assert.Check(t, is.Equal(testcase.expected, testcase.path.Matches(testcase.pattern)))
68 }
69}

Callers

nothing calls this directly

Calls 2

NewPathFunction · 0.85
MatchesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…