refactor platform logic and add gasorder domain
This commit is contained in:
@@ -35,6 +35,11 @@ func TestEveryContractHasRegisteredRoute(t *testing.T) {
|
||||
assertRouteMethods(t, routes, path+"/:identity/status", http.MethodPatch)
|
||||
assertNoRouteMethods(t, routes, path, http.MethodDelete)
|
||||
assertNoRouteMethods(t, routes, path+"/:identity", http.MethodDelete)
|
||||
case platform.Managed:
|
||||
assertRouteMethods(t, routes, path, http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, path+"/:identity", http.MethodGet, http.MethodPut)
|
||||
assertNoRouteMethods(t, routes, path, http.MethodDelete)
|
||||
assertNoRouteMethods(t, routes, path+"/:identity", http.MethodPatch, http.MethodDelete)
|
||||
default:
|
||||
assertRouteMethods(t, routes, path, http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, path+"/:identity", http.MethodGet, http.MethodPut, http.MethodDelete)
|
||||
@@ -51,7 +56,7 @@ func TestPlatformGasRouteUsesGasBasic(t *testing.T) {
|
||||
if route.Path == "/heqi/platform/v1/gas/gas_station" {
|
||||
t.Fatal("gas station route must use gas_basic as its resource name")
|
||||
}
|
||||
if route.Method == "GET" && route.Path == "/heqi/platform/v1/gas/gas_basic" {
|
||||
if route.Method == "GET" && route.Path == "/heqi/platform/v1/gas_basic" {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -71,26 +76,26 @@ func TestPlatformOrganizationAndAccountRoutesExposeResourceCRUD(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, resource := range []string{
|
||||
"/gas/gas_basic",
|
||||
"/gas/gas_account",
|
||||
"/delivery/delivery_basic",
|
||||
"/delivery/delivery_account",
|
||||
"/staff/account",
|
||||
"/staff/credential",
|
||||
"/user/account",
|
||||
"/user/address",
|
||||
"/user/service_relation",
|
||||
"/platform/platfrom_account",
|
||||
"/platform/platform_role",
|
||||
"/platform/platform_menu",
|
||||
"/gas_basic",
|
||||
"/gas_account",
|
||||
"/delivery_basic",
|
||||
"/delivery_account",
|
||||
"/staff_account",
|
||||
"/staff_credential",
|
||||
"/user_account",
|
||||
"/user_address",
|
||||
"/user_service_relation",
|
||||
"/platfrom_account",
|
||||
"/platform_role",
|
||||
"/platform_menu",
|
||||
} {
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource, http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource+"/:identity", http.MethodGet, http.MethodPut, http.MethodDelete)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource+"/:identity/status", http.MethodPatch)
|
||||
}
|
||||
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/platform/platform_role/:identity/menu", http.MethodGet, http.MethodPut)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/platform/platform_role/:identity/menus", http.MethodPut)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/platform_role/:identity/menu", http.MethodGet, http.MethodPut)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/platform_role/:identity/menus", http.MethodPut)
|
||||
}
|
||||
|
||||
func TestPlatformProductCommerceAndDeliveryRoutesFollowTheirContracts(t *testing.T) {
|
||||
@@ -106,20 +111,30 @@ func TestPlatformProductCommerceAndDeliveryRoutesFollowTheirContracts(t *testing
|
||||
}
|
||||
|
||||
for _, resource := range []string{
|
||||
"/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",
|
||||
"/ec_category", "/ec_product", "/ec_product_attribute", "/ec_product_image", "/ec_cart", "/ec_order", "/ec_order_item", "/ec_review",
|
||||
} {
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource, http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource+"/:identity", http.MethodGet, http.MethodPut, http.MethodDelete)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource+"/:identity/status", http.MethodPatch)
|
||||
}
|
||||
|
||||
trackPoint := "/heqi/platform/v1/delivery/delivery_track_point"
|
||||
assertRouteMethods(t, routes, trackPoint, http.MethodGet)
|
||||
assertRouteMethods(t, routes, trackPoint+"/:identity", http.MethodGet)
|
||||
assertNoRouteMethods(t, routes, trackPoint, http.MethodPost)
|
||||
assertNoRouteMethods(t, routes, trackPoint+"/:identity", http.MethodPut, http.MethodDelete)
|
||||
assertNoRouteMethods(t, routes, trackPoint+"/:identity/status", http.MethodPatch)
|
||||
for _, resource := range []string{"/gasorder_item", "/gasorder_assign", "/gasorder_status", "/gasorder_track", "/gasorder_track_point", "/gasorder_confirm", "/gasorder_payment", "/gasorder_contract_revision"} {
|
||||
path := "/heqi/platform/v1" + resource
|
||||
assertRouteMethods(t, routes, path, http.MethodGet)
|
||||
assertRouteMethods(t, routes, path+"/:identity", http.MethodGet)
|
||||
assertNoRouteMethods(t, routes, path, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete)
|
||||
assertNoRouteMethods(t, routes, path+"/:identity", http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete)
|
||||
}
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/gasorder_contract", http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/gasorder_contract/:identity", http.MethodGet, http.MethodPut)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/gasorder_basic", http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/gasorder_basic/:identity", http.MethodGet)
|
||||
for _, action := range []string{"assign", "filling", "ready", "exception", "recover", "cancel"} {
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1/gasorder_basic/:identity/"+action, http.MethodPost)
|
||||
}
|
||||
for _, old := range []string{"/delivery/delivery_task", "/delivery/delivery_track", "/delivery/delivery_track_point"} {
|
||||
assertNoRouteMethods(t, routes, "/heqi/platform/v1"+old, http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete)
|
||||
}
|
||||
|
||||
for _, resource := range []string{"/product_type", "/product_warehouse", "/product_info", "/product_repair"} {
|
||||
path := "/heqi/platform/v1" + resource
|
||||
@@ -157,8 +172,8 @@ func TestPlatformFinanceContentRoutesFollowTheirContracts(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, resource := range []string{
|
||||
"/finance/fin_payment", "/finance/fin_settlement", "/finance/fin_reconciliation",
|
||||
"/content/cms_content", "/customer_service/cs_ticket",
|
||||
"/fin_payment", "/fin_settlement", "/fin_reconciliation",
|
||||
"/cms_content", "/cs_ticket",
|
||||
} {
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource, http.MethodGet, http.MethodPost)
|
||||
assertRouteMethods(t, routes, "/heqi/platform/v1"+resource+"/:identity", http.MethodGet, http.MethodPut, http.MethodDelete)
|
||||
|
||||
Reference in New Issue
Block a user