修复vip类型
This commit is contained in:
parent
3639cad484
commit
3ec7cc6a62
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -129,6 +130,33 @@ func TestVipResourcePayloadAcceptsStringResourceID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVipLevelPayloadMarshalsIDAsString(t *testing.T) {
|
||||
payload := payloadFromConfig(model.VipLevelConfig{
|
||||
ID: 2049402425177018368,
|
||||
SysOrigin: "LIKEI",
|
||||
Level: 1,
|
||||
LevelCode: "VIP1",
|
||||
DisplayName: "VIP 1",
|
||||
Enabled: true,
|
||||
})
|
||||
|
||||
body, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal vip level payload: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(body), `"id":"2049402425177018368"`) {
|
||||
t.Fatalf("vip level id was not emitted as string: %s", body)
|
||||
}
|
||||
|
||||
var decoded VipLevelPayload
|
||||
if err := json.Unmarshal(body, &decoded); err != nil {
|
||||
t.Fatalf("unmarshal vip level payload: %v", err)
|
||||
}
|
||||
if decoded.ID.Int64() != 2049402425177018368 {
|
||||
t.Fatalf("decoded id = %d, want 2049402425177018368", decoded.ID.Int64())
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourcePayloadUsesResourceGroupDetails(t *testing.T) {
|
||||
row := model.VipLevelConfig{
|
||||
Level: 2,
|
||||
|
||||
@ -83,7 +83,7 @@ type ConfigResponse struct {
|
||||
}
|
||||
|
||||
type VipLevelPayload struct {
|
||||
ID int64 `json:"id"`
|
||||
ID ResourceID `json:"id"`
|
||||
Level int `json:"level"`
|
||||
LevelCode string `json:"levelCode"`
|
||||
DisplayName string `json:"displayName"`
|
||||
@ -365,7 +365,7 @@ func payloadFromConfigWithResources(row model.VipLevelConfig, resources vipResou
|
||||
code = levelCode(row.Level)
|
||||
}
|
||||
return VipLevelPayload{
|
||||
ID: row.ID,
|
||||
ID: ResourceID(row.ID),
|
||||
Level: row.Level,
|
||||
LevelCode: code,
|
||||
DisplayName: displayName,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user