- 前端: 所有界面显示、i18n 文本、组件中的品牌名称 - 后端: 服务层、设置默认值、邮件模板、安装向导 - 数据库: 迁移脚本注释 - 保持功能完全一致,仅更改品牌名称 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
88 lines
1.6 KiB
Go
88 lines
1.6 KiB
Go
//go:build unit
|
|
|
|
package repository
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBillingBalanceKey(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
userID int64
|
|
expected string
|
|
}{
|
|
{
|
|
name: "normal_user_id",
|
|
userID: 123,
|
|
expected: "billing:balance:123",
|
|
},
|
|
{
|
|
name: "zero_user_id",
|
|
userID: 0,
|
|
expected: "billing:balance:0",
|
|
},
|
|
{
|
|
name: "negative_user_id",
|
|
userID: -1,
|
|
expected: "billing:balance:-1",
|
|
},
|
|
{
|
|
name: "max_int64",
|
|
userID: math.MaxInt64,
|
|
expected: "billing:balance:9223372036854775807",
|
|
},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := billingBalanceKey(tc.userID)
|
|
require.Equal(t, tc.expected, got)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestBillingSubKey(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
userID int64
|
|
groupID int64
|
|
expected string
|
|
}{
|
|
{
|
|
name: "normal_ids",
|
|
userID: 123,
|
|
groupID: 456,
|
|
expected: "billing:sub:123:456",
|
|
},
|
|
{
|
|
name: "zero_ids",
|
|
userID: 0,
|
|
groupID: 0,
|
|
expected: "billing:sub:0:0",
|
|
},
|
|
{
|
|
name: "negative_ids",
|
|
userID: -1,
|
|
groupID: -2,
|
|
expected: "billing:sub:-1:-2",
|
|
},
|
|
{
|
|
name: "max_int64_ids",
|
|
userID: math.MaxInt64,
|
|
groupID: math.MaxInt64,
|
|
expected: "billing:sub:9223372036854775807:9223372036854775807",
|
|
},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := billingSubKey(tc.userID, tc.groupID)
|
|
require.Equal(t, tc.expected, got)
|
|
})
|
|
}
|
|
}
|