refactor platform domain states and permissions
This commit is contained in:
37
backend/api/internal/models/status_separation_test.go
Normal file
37
backend/api/internal/models/status_separation_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBusinessModelsUseDedicatedStatusFields(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
model any
|
||||
field string
|
||||
}{
|
||||
{GasorderContract{}, "ContractStatus"},
|
||||
{GasorderBasic{}, "OrderStatus"},
|
||||
{ProductInfo{}, "ProductStatus"},
|
||||
{EcOrder{}, "OrderStatus"},
|
||||
{WalletPayment{}, "PaymentStatus"},
|
||||
{WalletRefund{}, "RefundStatus"},
|
||||
{WalletApplyCash{}, "ApplyStatus"},
|
||||
{FinPayment{}, "PaymentStatus"},
|
||||
{FinReconciliation{}, "ReconciliationStatus"},
|
||||
{CsTicket{}, "TicketStatus"},
|
||||
} {
|
||||
if _, ok := reflect.TypeOf(test.model).FieldByName(test.field); !ok {
|
||||
t.Fatalf("%T is missing dedicated business status field %s", test.model, test.field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestProductEnablementHasSingleSource(t *testing.T) {
|
||||
if _, ok := reflect.TypeOf(ProductInfo{}).FieldByName("IsEnabled"); ok {
|
||||
t.Fatal("ProductInfo duplicates Entity.Status with IsEnabled")
|
||||
}
|
||||
if _, ok := reflect.TypeOf(ProductWarehouse{}).FieldByName("IsEnabled"); ok {
|
||||
t.Fatal("ProductWarehouse duplicates Entity.Status with IsEnabled")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user