Files
platforms/backend/api/internal/logic/delivery/profile_test.go
2026-08-22 19:49:28 +08:00

34 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 功能描述验证配送点资料响应仅暴露本点只读展示所需字段。版本v1.0.0。
package delivery
import (
"testing"
"time"
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
)
// TestBuildDeliveryProfileView 验证资料响应包含所属气站名称且保持公开标识。
func TestBuildDeliveryProfileView(t *testing.T) {
now := time.Date(2026, time.August, 22, 10, 30, 0, 0, time.UTC)
point := models.DeliveryBasic{
Entity: models.Entity{ID: 19, Identity: "delivery-identity", Status: 1, CreatedAt: now, UpdatedAt: now},
DeliveryCode: "D-001",
Name: "测试配送点",
Principal: "负责人",
Address: "测试地址",
}
station := models.GasBasic{
Entity: models.Entity{ID: 7, Identity: "gas-identity"},
Name: "测试气站",
}
view := buildDeliveryProfileView(point, station)
if view.ID != point.ID || view.Identity != point.Identity || view.GasBasicIdentity != station.Identity {
t.Fatalf("资料标识映射错误:%#v", view)
}
if view.GasBasicName != station.Name || view.Name != point.Name || view.Status != point.Status {
t.Fatalf("资料展示字段映射错误:%#v", view)
}
}