MCPcopy Create free account
hub / github.com/docker/secrets-engine / Test_apply

Function Test_apply

x/secrets/pattern_test.go:159–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func Test_apply(t *testing.T) {
160 type query struct {
161 pattern string
162 result string
163 }
164 tests := []struct {
165 pattern string
166 queries []query
167 }{
168 {
169 pattern: "foo/bar/**",
170 queries: []query{
171 {
172 pattern: "baz",
173 result: "foo/bar/baz",
174 },
175 {
176 pattern: "**",
177 result: "foo/bar/**",
178 },
179 {
180 pattern: "**/*",
181 result: "foo/bar/**/*",
182 },
183 },
184 },
185 {
186 pattern: "**/*",
187 queries: []query{
188 {
189 pattern: "baz",
190 result: "baz/*",
191 },
192 {
193 pattern: "bar/baz",
194 result: "bar/baz/*",
195 },
196 {
197 pattern: "**",
198 result: "**/*",
199 },
200 },
201 },
202 {
203 pattern: "**/**",
204 queries: []query{
205 {
206 pattern: "**/bar",
207 },
208 },
209 },
210 }
211 for idx, test := range tests {
212 t.Run(fmt.Sprintf("%d - %s", idx, test.pattern), func(t *testing.T) {
213 for inner, query := range test.queries {
214 t.Run(fmt.Sprintf("%d-%d %s %s", idx, inner, test.pattern, query.pattern), func(t *testing.T) {
215 result, err := replace1(test.pattern, query.pattern)
216 if query.result == "" {

Callers

nothing calls this directly

Calls 3

replace1Function · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected