(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestPatternIncludes(t *testing.T) { |
| 69 | tests := []struct { |
| 70 | pattern string |
| 71 | other string |
| 72 | otherIsIncluded bool |
| 73 | }{ |
| 74 | {"**", "**", true}, |
| 75 | {"**/*", "*/**", true}, |
| 76 | // **/* and ** are equivalent because IDs are required to always have at least one component |
| 77 | {"**/*", "**", true}, |
| 78 | {"**", "**/*", true}, |
| 79 | {"**/**", "**/**", true}, |
| 80 | {"**/*/**", "**/**", true}, |
| 81 | {"**/*/*", "*/*/**", true}, |
| 82 | {"**/*/*", "**", false}, |
| 83 | {"**", "**/foo", true}, |
| 84 | {"**/foo", "**", false}, |
| 85 | {"**/foo", "**/foo", true}, |
| 86 | {"foo/**", "**/foo", false}, |
| 87 | {"**", "bar/**/foo", true}, |
| 88 | {"**", "*/bar/**/foo", true}, |
| 89 | {"*", "*", true}, |
| 90 | {"*/foo", "*", false}, |
| 91 | {"*", "*/foo", false}, |
| 92 | {"docker/*/mcp/*", "docker/proj1/**", false}, |
| 93 | {"docker/proj1/**", "docker/*/mcp/*", true}, |
| 94 | {"docker/proj1/**", "docker/**/mcp/**", false}, |
| 95 | {"docker/**", "docker/**/mcp/**", true}, |
| 96 | } |
| 97 | for idx, tc := range tests { |
| 98 | t.Run(fmt.Sprintf("pattern %d", idx+1), func(t *testing.T) { |
| 99 | p, err := ParsePattern(tc.pattern) |
| 100 | require.NoError(t, err) |
| 101 | other, err := ParsePattern(tc.other) |
| 102 | require.NoError(t, err) |
| 103 | assert.Equal(t, tc.otherIsIncluded, p.Includes(other)) |
| 104 | }) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | func Test_Filter(t *testing.T) { |
| 109 | tests := []struct { |
nothing calls this directly
no test coverage detected