@@ -148,58 +148,76 @@ func TestGetUnrecognizedFormats(t *testing.T) {
148
148
}{
149
149
{
150
150
name : "empty format" ,
151
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "" }},
151
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "" , Type : [] string { "string" } }},
152
152
compatibilityVersion : version .MajorMinor (1 , 0 ),
153
153
expectedFormats : []string {},
154
154
},
155
155
{
156
156
name : "recognized format at version 1.0" ,
157
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "email" }},
157
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "email" , Type : [] string { "string" } }},
158
158
compatibilityVersion : version .MajorMinor (1 , 0 ),
159
159
expectedFormats : []string {},
160
160
},
161
161
{
162
162
name : "unrecognized format at version 1.0" ,
163
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "unknown-format" }},
163
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "unknown-format" , Type : [] string { "string" } }},
164
164
compatibilityVersion : version .MajorMinor (1 , 0 ),
165
165
expectedFormats : []string {"unknown-format" },
166
166
},
167
167
{
168
168
name : "recognized format with normalization" ,
169
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8s-short-name" }},
169
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8s-short-name" , Type : [] string { "string" } }},
170
170
compatibilityVersion : version .MajorMinor (1 , 34 ),
171
171
expectedFormats : []string {},
172
172
},
173
173
{
174
174
name : "unrecognized format with normalization" ,
175
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8s-long-name" }},
175
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8s-long-name" , Type : [] string { "string" } }},
176
176
compatibilityVersion : version .MajorMinor (1 , 33 ),
177
177
expectedFormats : []string {"k8s-long-name" },
178
178
},
179
179
{
180
180
name : "format introduced in later version" ,
181
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8s-short-name" }},
181
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8s-short-name" , Type : [] string { "string" } }},
182
182
compatibilityVersion : version .MajorMinor (1 , 0 ),
183
183
expectedFormats : []string {"k8s-short-name" },
184
184
},
185
185
{
186
186
name : "format with dash normalization" ,
187
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8sshortname" }},
187
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "k8sshortname" , Type : [] string { "string" } }},
188
188
compatibilityVersion : version .MajorMinor (1 , 34 ),
189
189
expectedFormats : []string {},
190
190
},
191
191
{
192
192
name : "recognized format at exact version" ,
193
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "uuid" }},
193
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "uuid" , Type : [] string { "string" } }},
194
194
compatibilityVersion : version .MajorMinor (1 , 0 ),
195
195
expectedFormats : []string {},
196
196
},
197
197
{
198
198
name : "recognized format at higher version" ,
199
- schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "email" }},
199
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "email" , Type : [] string { "string" } }},
200
200
compatibilityVersion : version .MajorMinor (1 , 35 ),
201
201
expectedFormats : []string {},
202
202
},
203
+ {
204
+ name : "unrecognized format for integer type is not reported" ,
205
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "unknown-format" , Type : []string {"integer" }}},
206
+ compatibilityVersion : version .MajorMinor (1 , 0 ),
207
+ expectedFormats : []string {},
208
+ },
209
+ {
210
+ name : "unrecognized format for string,null type is not reported" ,
211
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "unknown-format" , Type : []string {"string" , "null" }}},
212
+ compatibilityVersion : version .MajorMinor (1 , 0 ),
213
+ expectedFormats : []string {},
214
+ },
215
+ {
216
+ name : "unrecognized format for no type is not reported" ,
217
+ schema : & spec.Schema {SchemaProps : spec.SchemaProps {Format : "unknown-format" }},
218
+ compatibilityVersion : version .MajorMinor (1 , 0 ),
219
+ expectedFormats : []string {},
220
+ },
203
221
}
204
222
205
223
for _ , tc := range testCases {
0 commit comments