@@ -138,28 +138,51 @@ func TestClient_ConfigValidation(t *testing.T) {
138
138
expectedError error
139
139
}{
140
140
{
141
- name : "valid storage_prefix" ,
142
- cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "helloworld " },
141
+ name : "storage_prefix/valid " ,
142
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "helloWORLD123 " },
143
143
},
144
144
{
145
- name : "storage_prefix non-alphanumeric characters" ,
146
- cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello-world!" },
147
- expectedError : ErrInvalidCharactersInStoragePrefix ,
145
+ name : "storage_prefix/valid-subdir" ,
146
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello/world/env" },
148
147
},
149
148
{
150
- name : "storage_prefix suffixed with a slash (non-alphanumeric)" ,
151
- cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "helloworld/" },
152
- expectedError : ErrInvalidCharactersInStoragePrefix ,
149
+ name : "storage_prefix/valid-subdir-trailing-slash" ,
150
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello/world/env/" },
153
151
},
154
152
{
155
- name : "storage_prefix that has some character strings that have a meaning in unix paths (..) " ,
153
+ name : "storage_prefix/invalid-directory-up " ,
156
154
cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : ".." },
157
- expectedError : ErrInvalidCharactersInStoragePrefix ,
155
+ expectedError : ErrStoragePrefixInvalidCharacters ,
158
156
},
159
157
{
160
- name : "storage_prefix that has some character strings that have a meaning in unix paths (.) " ,
158
+ name : "storage_prefix/invalid-directory " ,
161
159
cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "." },
162
- expectedError : ErrInvalidCharactersInStoragePrefix ,
160
+ expectedError : ErrStoragePrefixInvalidCharacters ,
161
+ },
162
+ {
163
+ name : "storage_prefix/invalid-absolute-path" ,
164
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "/hello/world" },
165
+ expectedError : ErrStoragePrefixStartsWithSlash ,
166
+ },
167
+ {
168
+ name : "storage_prefix/invalid-..-in-a-path-segement" ,
169
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello/../test" },
170
+ expectedError : ErrStoragePrefixInvalidCharacters ,
171
+ },
172
+ {
173
+ name : "storage_prefix/invalid-empty-path-segement" ,
174
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello//test" },
175
+ expectedError : ErrStoragePrefixEmptyPathSegment ,
176
+ },
177
+ {
178
+ name : "storage_prefix/invalid-emoji" ,
179
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "👋" },
180
+ expectedError : ErrStoragePrefixInvalidCharacters ,
181
+ },
182
+ {
183
+ name : "storage_prefix/invalid-emoji" ,
184
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello!world" },
185
+ expectedError : ErrStoragePrefixInvalidCharacters ,
163
186
},
164
187
{
165
188
name : "unsupported backend" ,
@@ -172,7 +195,11 @@ func TestClient_ConfigValidation(t *testing.T) {
172
195
tc := tc
173
196
t .Run (tc .name , func (t * testing.T ) {
174
197
actualErr := tc .cfg .Validate ()
175
- assert .ErrorIs (t , actualErr , tc .expectedError )
198
+ if tc .expectedError != nil {
199
+ assert .Equal (t , actualErr , tc .expectedError )
200
+ } else {
201
+ assert .NoError (t , actualErr )
202
+ }
176
203
})
177
204
}
178
205
}
0 commit comments