修改部分枚举字段的编号与注释确保 0 值的正确语义

This commit is contained in:
2025-04-30 17:13:47 +08:00
parent fde5e7226e
commit bdac5d999a
12 changed files with 66 additions and 110 deletions

View File

@@ -109,7 +109,7 @@ func Test_cache(t *testing.T) {
// 准备测试数据
now := time.Now()
expiration := now.Add(24 * time.Hour)
expiration := common.LocalDateTime(now.Add(24 * time.Hour))
testChannels := []*models.Channel{
{
@@ -471,7 +471,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
if ch.Password != *info.Password {
return fmt.Errorf("通道密码不正确,期望 %s得到 %s", *info.Password, ch.Password)
}
if ch.Expiration.IsZero() {
if time.Time(ch.Expiration).IsZero() {
return fmt.Errorf("通道过期时间不应为空")
}
@@ -615,7 +615,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
if ch.Protocol != int32(info.Proto) {
return fmt.Errorf("通道协议不正确,期望 %d得到 %d", info.Proto, ch.Protocol)
}
if ch.Expiration.IsZero() {
if time.Time(ch.Expiration).IsZero() {
return fmt.Errorf("通道过期时间不应为空")
}
@@ -765,7 +765,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
if ch.Password != *info.Password {
return fmt.Errorf("通道密码不正确,期望 %s得到 %s", *info.Password, ch.Password)
}
if ch.Expiration.IsZero() {
if time.Time(ch.Expiration).IsZero() {
return fmt.Errorf("通道过期时间不应为空")
}
@@ -914,7 +914,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
ProxyID: 1,
ProxyPort: int32(i + 10000),
UserID: 101,
Expiration: expr,
Expiration: common.LocalDateTime(expr),
}
}
db.CreateInBatches(channels, 1000)
@@ -1040,9 +1040,9 @@ func Test_channelService_RemoveChannels(t *testing.T) {
// 创建通道
channels := []models.Channel{
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
}
// 保存预设数据
@@ -1154,9 +1154,9 @@ func Test_channelService_RemoveChannels(t *testing.T) {
// 创建通道
channels := []models.Channel{
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
}
// 保存预设数据
@@ -1268,9 +1268,9 @@ func Test_channelService_RemoveChannels(t *testing.T) {
// 创建通道
channels := []models.Channel{
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 3, UserID: 102, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: time.Now().Add(24 * time.Hour)},
{ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
{ID: 3, UserID: 102, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: common.LocalDateTime(time.Now().Add(24 * time.Hour))},
}
// 保存预设数据