35 lines
1.6 KiB
Go
35 lines
1.6 KiB
Go
package business
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"kra/internal/biz/business"
|
|
"kra/internal/service/dto"
|
|
)
|
|
|
|
type channelPortraitTransportFake struct{ result *business.ChannelPortrait }
|
|
|
|
func (f channelPortraitTransportFake) Portrait(context.Context, business.ChannelKey, string) (*business.ChannelPortrait, error) {
|
|
return f.result, nil
|
|
}
|
|
|
|
func TestChannelPortraitKeepsContactAndCooperationStatusSeparateFromAudit(t *testing.T) {
|
|
level, auditStatus, days := 1, 1, 7
|
|
for _, sample := range []struct {
|
|
status int
|
|
label string
|
|
}{{0, "正常"}, {-1, "锁定"}, {-2, "解除合作"}} {
|
|
channel := &business.Channel{ChannelKey: business.ChannelKey{SourceDB: "lx", ID: 100}, Account: "渠道账号", Level: &level, Status: &auditStatus, LockStatus: &sample.status, Phone: "13812345678", SettlementDays: &days, BindingAccount: "SDK商务", BindingUserName: "所属商务", BusinessPath: []string{"一级商务", "所属商务"}}
|
|
service := &ChannelPortraitService{uc: channelPortraitTransportFake{&business.ChannelPortrait{Basic: &business.ChannelPortraitBasic{Channel: channel}}}}
|
|
result, err := service.Portrait(context.Background(), &dto.ChannelPortraitQuery{SourceDB: "lx", PromoteID: 100})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
b := result.Basic
|
|
if b.LockStatusLabel != sample.label || b.StatusLabel != "正常" || b.Phone != channel.Phone || b.SettlementDays == nil || *b.SettlementDays != 7 || b.BusierDisplayName != "SDK商务(所属商务)" || b.ParentPromoteName == nil || *b.ParentPromoteName != "所属商务" {
|
|
t.Fatalf("portrait metadata or status mismatch: %+v", b)
|
|
}
|
|
}
|
|
}
|