|
9 | 9 | "github.com/databricks/cli/bundle/config" |
10 | 10 | "github.com/databricks/cli/bundle/config/loader" |
11 | 11 | "github.com/databricks/cli/internal/testutil" |
| 12 | + "github.com/databricks/cli/libs/diag" |
12 | 13 | "github.com/stretchr/testify/assert" |
13 | 14 | "github.com/stretchr/testify/require" |
14 | 15 | ) |
@@ -111,3 +112,70 @@ func TestProcessRootIncludesNotExists(t *testing.T) { |
111 | 112 | require.True(t, diags.HasError()) |
112 | 113 | assert.ErrorContains(t, diags.Error(), "notexist.yml defined in 'include' section does not match any files") |
113 | 114 | } |
| 115 | + |
| 116 | +func TestProcessRootIncludesGlobInRootPath(t *testing.T) { |
| 117 | + tests := []struct { |
| 118 | + name string |
| 119 | + root string |
| 120 | + diag diag.Diagnostic |
| 121 | + }{ |
| 122 | + { |
| 123 | + name: "star", |
| 124 | + root: "foo/a*", |
| 125 | + diag: diag.Diagnostic{ |
| 126 | + Severity: diag.Error, |
| 127 | + Summary: "Bundle root path contains glob pattern characters", |
| 128 | + Detail: `The path to the bundle root foo/a* contains glob pattern character "*". Please remove the character from this path to use bundle commands.`, |
| 129 | + }, |
| 130 | + }, |
| 131 | + { |
| 132 | + name: "question mark", |
| 133 | + root: "bar/?b", |
| 134 | + diag: diag.Diagnostic{ |
| 135 | + Severity: diag.Error, |
| 136 | + Summary: "Bundle root path contains glob pattern characters", |
| 137 | + Detail: `The path to the bundle root bar/?b contains glob pattern character "?". Please remove the character from this path to use bundle commands.`, |
| 138 | + }, |
| 139 | + }, |
| 140 | + { |
| 141 | + name: "left bracket", |
| 142 | + root: "[ab", |
| 143 | + diag: diag.Diagnostic{ |
| 144 | + Severity: diag.Error, |
| 145 | + Summary: "Bundle root path contains glob pattern characters", |
| 146 | + Detail: `The path to the bundle root [ab contains glob pattern character "[". Please remove the character from this path to use bundle commands.`, |
| 147 | + }, |
| 148 | + }, |
| 149 | + { |
| 150 | + name: "right bracket", |
| 151 | + root: "ab]/bax", |
| 152 | + diag: diag.Diagnostic{ |
| 153 | + Severity: diag.Error, |
| 154 | + Summary: "Bundle root path contains glob pattern characters", |
| 155 | + Detail: `The path to the bundle root ab]/bax contains glob pattern character "]". Please remove the character from this path to use bundle commands.`, |
| 156 | + }, |
| 157 | + }, |
| 158 | + { |
| 159 | + name: "hat", |
| 160 | + root: "ab^bax", |
| 161 | + diag: diag.Diagnostic{ |
| 162 | + Severity: diag.Error, |
| 163 | + Summary: "Bundle root path contains glob pattern characters", |
| 164 | + Detail: `The path to the bundle root ab^bax contains glob pattern character "^". Please remove the character from this path to use bundle commands.`, |
| 165 | + }, |
| 166 | + }, |
| 167 | + } |
| 168 | + |
| 169 | + for _, test := range tests { |
| 170 | + t.Run(test.name, func(t *testing.T) { |
| 171 | + b := &bundle.Bundle{ |
| 172 | + BundleRootPath: test.root, |
| 173 | + } |
| 174 | + |
| 175 | + diags := bundle.Apply(context.Background(), b, loader.ProcessRootIncludes()) |
| 176 | + require.True(t, diags.HasError()) |
| 177 | + assert.Len(t, diags, 1) |
| 178 | + assert.Equal(t, test.diag, diags[0]) |
| 179 | + }) |
| 180 | + } |
| 181 | +} |
0 commit comments