test: define safe and audit resource rename contract

This commit is contained in:
2026-07-27 14:03:45 +08:00
parent fcfe1b6a5b
commit 7a35bfe58c
4 changed files with 65 additions and 5 deletions

View File

@@ -101,7 +101,7 @@ func TestPlatformDeviceSafetyCommerceAndDeliveryRoutesFollowTheirContracts(t *te
for _, resource := range []string{
"/device/dev_smart_cylinder_valve", "/device/dev_device_binding",
"/safety/saf_rule", "/safety/saf_event", "/safety/saf_inspection",
"/safety/safe_rule", "/safety/safe_event", "/safety/safe_inspection",
"/ec/ec_category", "/ec/ec_product", "/ec/ec_product_attribute", "/ec/ec_product_image", "/ec/ec_cart", "/ec/ec_order", "/ec/ec_order_item", "/ec/ec_review",
"/delivery/delivery_task", "/delivery/delivery_track",
} {
@@ -126,7 +126,7 @@ func TestPlatformDeviceSafetyCommerceAndDeliveryRoutesFollowTheirContracts(t *te
}
}
disposal := "/heqi/platform/v1/safety/saf_event/:identity/disposals"
disposal := "/heqi/platform/v1/safety/safe_event/:identity/disposals"
assertRouteMethods(t, routes, disposal, http.MethodPost)
if routes[disposal][http.MethodDelete] {
t.Fatal("safety event disposals must be append-only")
@@ -157,7 +157,7 @@ func TestPlatformFinanceContentAndAuditRoutesFollowTheirContracts(t *testing.T)
for _, resource := range []string{
"/wallet/wallet", "/wallet/wallet_ledger", "/wallet/wallet_recharge", "/wallet/wallet_withdrawal",
"/report/report", "/report/report_item", "/report/report_metric_snapshot",
"/audit/aud_operation_log", "/audit/aud_export_log", "/audit/aud_approval",
"/audit/audit_operation_log", "/audit/audit_export_log", "/audit/audit_approval",
} {
path := "/heqi/platform/v1" + resource
assertRouteMethods(t, routes, path, http.MethodGet)
@@ -169,7 +169,7 @@ func TestPlatformFinanceContentAndAuditRoutesFollowTheirContracts(t *testing.T)
}
}
assertRouteMethods(t, routes, "/heqi/platform/v1/audit/aud_approval/:identity/approve", http.MethodPost)
assertRouteMethods(t, routes, "/heqi/platform/v1/audit/audit_approval/:identity/approve", http.MethodPost)
}
func assertRouteMethods(t *testing.T, routes map[string]map[string]bool, path string, methods ...string) {