MCPcopy Index your code
hub / github.com/docker/cli / TestPathMatches

Function TestPathMatches

cli/compose/interpolation/interpolation_test.go:105–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestPathMatches(t *testing.T) {
106 testcases := []struct {
107 doc string
108 path Path
109 pattern Path
110 expected bool
111 }{
112 {
113 doc: "pattern too short",
114 path: NewPath("one", "two", "three"),
115 pattern: NewPath("one", "two"),
116 },
117 {
118 doc: "pattern too long",
119 path: NewPath("one", "two"),
120 pattern: NewPath("one", "two", "three"),
121 },
122 {
123 doc: "pattern mismatch",
124 path: NewPath("one", "three", "two"),
125 pattern: NewPath("one", "two", "three"),
126 },
127 {
128 doc: "pattern mismatch with match-all part",
129 path: NewPath("one", "three", "two"),
130 pattern: NewPath(PathMatchAll, "two", "three"),
131 },
132 {
133 doc: "pattern match with match-all part",
134 path: NewPath("one", "two", "three"),
135 pattern: NewPath("one", "*", "three"),
136 expected: true,
137 },
138 {
139 doc: "pattern match",
140 path: NewPath("one", "two", "three"),
141 pattern: NewPath("one", "two", "three"),
142 expected: true,
143 },
144 }
145 for _, testcase := range testcases {
146 assert.Check(t, is.Equal(testcase.expected, testcase.path.matches(testcase.pattern)))
147 }
148}

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…