Files
platforms/backend/api/internal/models/status_separation_test.go

38 lines
1.1 KiB
Go

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")
}
}