Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 7m37s
34 lines
971 B
Go
34 lines
971 B
Go
package subscribe
|
|
|
|
import (
|
|
"testing"
|
|
|
|
commonLogic "github.com/perfect-panel/server/internal/logic/common"
|
|
"github.com/perfect-panel/server/internal/types"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFillUserSubscribeInfoEntitlementFields(t *testing.T) {
|
|
sub := &types.UserSubscribeInfo{}
|
|
entitlement := &commonLogic.EntitlementContext{
|
|
EffectiveUserID: 3001,
|
|
Source: commonLogic.EntitlementSourceFamilyOwner,
|
|
OwnerUserID: 3001,
|
|
ReadOnly: true,
|
|
}
|
|
|
|
fillUserSubscribeInfoEntitlementFields(sub, entitlement)
|
|
|
|
require.Equal(t, commonLogic.EntitlementSourceFamilyOwner, sub.EntitlementSource)
|
|
require.Equal(t, int64(3001), sub.EntitlementOwnerUserId)
|
|
require.True(t, sub.ReadOnly)
|
|
}
|
|
|
|
func TestNormalizeSubscribeNodeTags(t *testing.T) {
|
|
tags := normalizeSubscribeNodeTags("美国, 日本, , 美国, ,日本")
|
|
require.Equal(t, []string{"美国", "日本"}, tags)
|
|
|
|
empty := normalizeSubscribeNodeTags("")
|
|
require.Nil(t, empty)
|
|
}
|