@@ -108,28 +108,51 @@ func TestClient_ConfigValidation(t *testing.T) {
108
108
expectedError error
109
109
}{
110
110
{
111
- name : "valid storage_prefix" ,
112
- cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "helloworld " },
111
+ name : "storage_prefix/valid " ,
112
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "helloWORLD123 " },
113
113
},
114
114
{
115
- name : "storage_prefix non-alphanumeric characters" ,
116
- cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello-world!" },
117
- expectedError : ErrInvalidCharactersInStoragePrefix ,
115
+ name : "storage_prefix/valid-subdir" ,
116
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello/world/env" },
118
117
},
119
118
{
120
- name : "storage_prefix suffixed with a slash (non-alphanumeric)" ,
121
- cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "helloworld/" },
122
- expectedError : ErrInvalidCharactersInStoragePrefix ,
119
+ name : "storage_prefix/valid-subdir-trailing-slash" ,
120
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello/world/env/" },
123
121
},
124
122
{
125
- name : "storage_prefix that has some character strings that have a meaning in unix paths (..) " ,
123
+ name : "storage_prefix/invalid-directory-up " ,
126
124
cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : ".." },
127
- expectedError : ErrInvalidCharactersInStoragePrefix ,
125
+ expectedError : ErrStoragePrefixInvalidCharacters ,
128
126
},
129
127
{
130
- name : "storage_prefix that has some character strings that have a meaning in unix paths (.) " ,
128
+ name : "storage_prefix/invalid-directory " ,
131
129
cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "." },
132
- expectedError : ErrInvalidCharactersInStoragePrefix ,
130
+ expectedError : ErrStoragePrefixInvalidCharacters ,
131
+ },
132
+ {
133
+ name : "storage_prefix/invalid-absolute-path" ,
134
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "/hello/world" },
135
+ expectedError : ErrStoragePrefixStartsWithSlash ,
136
+ },
137
+ {
138
+ name : "storage_prefix/invalid-..-in-a-path-segement" ,
139
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello/../test" },
140
+ expectedError : ErrStoragePrefixInvalidCharacters ,
141
+ },
142
+ {
143
+ name : "storage_prefix/invalid-empty-path-segement" ,
144
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello//test" },
145
+ expectedError : ErrStoragePrefixEmptyPathSegment ,
146
+ },
147
+ {
148
+ name : "storage_prefix/invalid-emoji" ,
149
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "👋" },
150
+ expectedError : ErrStoragePrefixInvalidCharacters ,
151
+ },
152
+ {
153
+ name : "storage_prefix/invalid-emoji" ,
154
+ cfg : Config {StorageBackendConfig : StorageBackendConfig {Backend : Filesystem }, StoragePrefix : "hello!world" },
155
+ expectedError : ErrStoragePrefixInvalidCharacters ,
133
156
},
134
157
{
135
158
name : "unsupported backend" ,
@@ -142,7 +165,11 @@ func TestClient_ConfigValidation(t *testing.T) {
142
165
tc := tc
143
166
t .Run (tc .name , func (t * testing.T ) {
144
167
actualErr := tc .cfg .Validate ()
145
- assert .ErrorIs (t , actualErr , tc .expectedError )
168
+ if tc .expectedError != nil {
169
+ assert .Equal (t , actualErr , tc .expectedError )
170
+ } else {
171
+ assert .NoError (t , actualErr )
172
+ }
146
173
})
147
174
}
148
175
}
0 commit comments