@@ -3345,85 +3345,3 @@ func TestValidationRules_HasValueRule_ArrayValidators(t *testing.T) {
33453345 })
33463346 }
33473347}
3348-
3349- func TestExtractImports_ArrayValidators (t * testing.T ) {
3350- tests := []struct {
3351- name string
3352- metadata * ConfigMetadata
3353- expectedImport string
3354- }{
3355- {
3356- name : "minItems triggers errors import" ,
3357- metadata : & ConfigMetadata {
3358- Type : ObjectType ,
3359- Properties : map [string ]* ConfigMetadata {
3360- "tags" : {Type : SliceType , Values : & ConfigMetadata {Type : StringType }, MinItems : Ptr (1 )},
3361- },
3362- },
3363- expectedImport : "errors" ,
3364- },
3365- {
3366- name : "maxItems triggers errors import" ,
3367- metadata : & ConfigMetadata {
3368- Type : ObjectType ,
3369- Properties : map [string ]* ConfigMetadata {
3370- "tags" : {Type : SliceType , Values : & ConfigMetadata {Type : StringType }, MaxItems : Ptr (10 )},
3371- },
3372- },
3373- expectedImport : "errors" ,
3374- },
3375- {
3376- name : "uniqueItems triggers errors import" ,
3377- metadata : & ConfigMetadata {
3378- Type : ObjectType ,
3379- Properties : map [string ]* ConfigMetadata {
3380- "tags" : {Type : SliceType , Values : & ConfigMetadata {Type : StringType }, UniqueItems : true },
3381- },
3382- },
3383- expectedImport : "errors" ,
3384- },
3385- {
3386- name : "contains with enum triggers slices import" ,
3387- metadata : & ConfigMetadata {
3388- Type : ObjectType ,
3389- Properties : map [string ]* ConfigMetadata {
3390- "tags" : {
3391- Type : SliceType ,
3392- Values : & ConfigMetadata {Type : StringType },
3393- Contains : & ConfigMetadata {Type : StringType , Enum : []any {"a" }},
3394- },
3395- },
3396- },
3397- expectedImport : "slices" ,
3398- },
3399- }
3400-
3401- for _ , tt := range tests {
3402- t .Run (tt .name , func (t * testing.T ) {
3403- result , err := ExtractImportsFromConfig (tt .metadata , "" , "" )
3404- require .NoError (t , err )
3405- require .Contains (t , result , tt .expectedImport )
3406- })
3407- }
3408- }
3409-
3410- func TestSchemaTypeToGoType (t * testing.T ) {
3411- tests := []struct {
3412- schemaType SchemaType
3413- expected string
3414- }{
3415- {StringType , "string" },
3416- {IntType , "int" },
3417- {Float64Type , "float64" },
3418- {BoolType , "bool" },
3419- {ObjectType , "any" },
3420- {SliceType , "any" },
3421- {"" , "any" },
3422- }
3423-
3424- for _ , tt := range tests {
3425- t .Run (string (tt .schemaType ), func (t * testing.T ) {
3426- require .Equal (t , tt .expected , schemaTypeToGoType (tt .schemaType ))
3427- })
3428- }
3429- }
0 commit comments