@@ -1264,6 +1264,60 @@ dynamic_endpoints:
12641264 },
12651265 },
12661266 },
1267+ {
1268+ name : "dynamic_jmespath_with_state_variable" ,
1269+ specYAML : `
1270+ name: "Test Dynamic JMESPath State Var"
1271+ defaults:
1272+ state:
1273+ base_url: "{base_url}"
1274+
1275+ dynamic_endpoints:
1276+ - iterate: '["customer_type", "order_type"]'
1277+ into: "state.endpoint_name"
1278+ endpoint:
1279+ name: "{state.endpoint_name}"
1280+ request:
1281+ url: "{state.base_url}/{state.endpoint_name}"
1282+ response:
1283+ records:
1284+ jmespath: "{state.endpoint_name}[]"
1285+ ` ,
1286+ expectedEndpointNames : []string {
1287+ "customer_type" ,
1288+ "order_type" ,
1289+ },
1290+ dataResponses : map [string ]map [string ]any {
1291+ "/customer_type" : {
1292+ "customer_type" : []map [string ]any {
1293+ {"id" : 1 , "name" : "Retail" },
1294+ {"id" : 2 , "name" : "Wholesale" },
1295+ },
1296+ },
1297+ "/order_type" : {
1298+ "order_type" : []map [string ]any {
1299+ {"id" : 10 , "name" : "Standard" },
1300+ {"id" : 20 , "name" : "Express" },
1301+ {"id" : 30 , "name" : "Overnight" },
1302+ },
1303+ },
1304+ },
1305+ expectedRecordCounts : map [string ]int {
1306+ "customer_type" : 2 ,
1307+ "order_type" : 3 ,
1308+ },
1309+ expectedRecordValues : map [string ][]any {
1310+ "customer_type" : {
1311+ map [string ]any {"id" : float64 (1 ), "name" : "Retail" },
1312+ map [string ]any {"id" : float64 (2 ), "name" : "Wholesale" },
1313+ },
1314+ "order_type" : {
1315+ map [string ]any {"id" : float64 (10 ), "name" : "Standard" },
1316+ map [string ]any {"id" : float64 (20 ), "name" : "Express" },
1317+ map [string ]any {"id" : float64 (30 ), "name" : "Overnight" },
1318+ },
1319+ },
1320+ },
12671321 }
12681322
12691323 for _ , tt := range tests {
0 commit comments