@@ -503,6 +503,48 @@ func Test_processArgsOk(t *testing.T) {
503
503
},
504
504
},
505
505
},
506
+ {
507
+ name : "valid map input param" ,
508
+ processSchemaReq : map [string ]interface {}{
509
+ "type" : "array" ,
510
+ "prefixItems" : []interface {}{
511
+ map [string ]interface {}{
512
+ "name" : "varMap" ,
513
+ "type" : "object" ,
514
+ "details" : map [string ]interface {}{
515
+ "type" : "schema" ,
516
+ "internalSchema" : map [string ]interface {}{
517
+ "type" : "map" ,
518
+ "args" : []interface {}{
519
+ map [string ]interface {}{
520
+ "name" : "key" ,
521
+ "type" : "integer" ,
522
+ },
523
+ map [string ]interface {}{
524
+ "name" : "value" ,
525
+ "type" : "string" ,
526
+ },
527
+ },
528
+ },
529
+ },
530
+ },
531
+ },
532
+ },
533
+ input : map [string ]interface {}{
534
+ "varMap" : map [string ]interface {}{
535
+ "mapEntries" : []interface {}{
536
+ map [string ]interface {}{
537
+ "key" : float64 (1 ),
538
+ "value" : "val1" ,
539
+ },
540
+ map [string ]interface {}{
541
+ "key" : float64 (3 ),
542
+ "value" : "val3" ,
543
+ },
544
+ },
545
+ },
546
+ },
547
+ },
506
548
}
507
549
for _ , tc := range testCases {
508
550
t .Run (tc .name , func (t * testing.T ) {
@@ -944,6 +986,177 @@ func Test_processArgsErr(t *testing.T) {
944
986
},
945
987
expectedError : "invalid object passed" ,
946
988
},
989
+ {
990
+ name : "no mapEntries for map input param" ,
991
+ processSchemaReq : map [string ]interface {}{
992
+ "type" : "array" ,
993
+ "prefixItems" : []interface {}{
994
+ map [string ]interface {}{
995
+ "name" : "varMap" ,
996
+ "type" : "object" ,
997
+ "details" : map [string ]interface {}{
998
+ "type" : "schema" ,
999
+ "internalSchema" : map [string ]interface {}{
1000
+ "type" : "map" ,
1001
+ "args" : []interface {}{
1002
+ map [string ]interface {}{
1003
+ "name" : "key" ,
1004
+ "type" : "integer" ,
1005
+ },
1006
+ map [string ]interface {}{
1007
+ "name" : "value" ,
1008
+ "type" : "string" ,
1009
+ },
1010
+ },
1011
+ },
1012
+ },
1013
+ },
1014
+ },
1015
+ },
1016
+ input : map [string ]interface {}{
1017
+ "varMap" : map [string ]interface {}{
1018
+ "invalid" : []interface {}{
1019
+ map [string ]interface {}{
1020
+ "key" : float64 (1 ),
1021
+ "value" : "val1" ,
1022
+ },
1023
+ map [string ]interface {}{
1024
+ "key" : float64 (3 ),
1025
+ "value" : "val3" ,
1026
+ },
1027
+ },
1028
+ },
1029
+ },
1030
+ expectedError : "mapEntries schema property must be present" ,
1031
+ },
1032
+ {
1033
+ name : "value missing for map input param" ,
1034
+ processSchemaReq : map [string ]interface {}{
1035
+ "type" : "array" ,
1036
+ "prefixItems" : []interface {}{
1037
+ map [string ]interface {}{
1038
+ "name" : "varMap" ,
1039
+ "type" : "object" ,
1040
+ "details" : map [string ]interface {}{
1041
+ "type" : "schema" ,
1042
+ "internalSchema" : map [string ]interface {}{
1043
+ "type" : "map" ,
1044
+ "args" : []interface {}{
1045
+ map [string ]interface {}{
1046
+ "name" : "key" ,
1047
+ "type" : "integer" ,
1048
+ },
1049
+ map [string ]interface {}{
1050
+ "name" : "value" ,
1051
+ "type" : "string" ,
1052
+ },
1053
+ },
1054
+ },
1055
+ },
1056
+ },
1057
+ },
1058
+ },
1059
+ input : map [string ]interface {}{
1060
+ "varMap" : map [string ]interface {}{
1061
+ "mapEntries" : []interface {}{
1062
+ map [string ]interface {}{
1063
+ "key" : float64 (1 ),
1064
+ },
1065
+ map [string ]interface {}{
1066
+ "key" : float64 (3 ),
1067
+ "value" : "val3" ,
1068
+ },
1069
+ },
1070
+ },
1071
+ },
1072
+ expectedError : "Schema field 'value' wasn't found" ,
1073
+ },
1074
+ {
1075
+ name : "key missing for map input param" ,
1076
+ processSchemaReq : map [string ]interface {}{
1077
+ "type" : "array" ,
1078
+ "prefixItems" : []interface {}{
1079
+ map [string ]interface {}{
1080
+ "name" : "varMap" ,
1081
+ "type" : "object" ,
1082
+ "details" : map [string ]interface {}{
1083
+ "type" : "schema" ,
1084
+ "internalSchema" : map [string ]interface {}{
1085
+ "type" : "map" ,
1086
+ "args" : []interface {}{
1087
+ map [string ]interface {}{
1088
+ "name" : "key" ,
1089
+ "type" : "integer" ,
1090
+ },
1091
+ map [string ]interface {}{
1092
+ "name" : "value" ,
1093
+ "type" : "string" ,
1094
+ },
1095
+ },
1096
+ },
1097
+ },
1098
+ },
1099
+ },
1100
+ },
1101
+ input : map [string ]interface {}{
1102
+ "varMap" : map [string ]interface {}{
1103
+ "mapEntries" : []interface {}{
1104
+ map [string ]interface {}{
1105
+ "value" : "val1" ,
1106
+ },
1107
+ map [string ]interface {}{
1108
+ "key" : float64 (3 ),
1109
+ "value" : "val3" ,
1110
+ },
1111
+ },
1112
+ },
1113
+ },
1114
+ expectedError : "Schema field 'key' wasn't found" ,
1115
+ },
1116
+ {
1117
+ name : "unknown field for map input param" ,
1118
+ processSchemaReq : map [string ]interface {}{
1119
+ "type" : "array" ,
1120
+ "prefixItems" : []interface {}{
1121
+ map [string ]interface {}{
1122
+ "name" : "varMap" ,
1123
+ "type" : "object" ,
1124
+ "details" : map [string ]interface {}{
1125
+ "type" : "schema" ,
1126
+ "internalSchema" : map [string ]interface {}{
1127
+ "type" : "map" ,
1128
+ "args" : []interface {}{
1129
+ map [string ]interface {}{
1130
+ "name" : "key" ,
1131
+ "type" : "integer" ,
1132
+ },
1133
+ map [string ]interface {}{
1134
+ "name" : "value" ,
1135
+ "type" : "string" ,
1136
+ },
1137
+ },
1138
+ },
1139
+ },
1140
+ },
1141
+ },
1142
+ },
1143
+ input : map [string ]interface {}{
1144
+ "varMap" : map [string ]interface {}{
1145
+ "mapEntries" : []interface {}{
1146
+ map [string ]interface {}{
1147
+ "key" : float64 (1 ),
1148
+ "value" : "val1" ,
1149
+ "unknown" : float64 (1 ),
1150
+ },
1151
+ map [string ]interface {}{
1152
+ "key" : float64 (3 ),
1153
+ "value" : "val3" ,
1154
+ },
1155
+ },
1156
+ },
1157
+ },
1158
+ expectedError : "Unknown schema field 'unknown' in map entry" ,
1159
+ },
947
1160
}
948
1161
949
1162
for _ , tc := range testCases {
0 commit comments