mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 06:16:37 +08:00
528240026d
- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯 - .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化) - 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package driver_asynq_worker
|
|
|
|
import (
|
|
"Wavelet/pkg/config"
|
|
"testing"
|
|
|
|
"github.com/redis/go-redis/v9/maintnotifications"
|
|
)
|
|
|
|
func TestMaintNotificationsConfig(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
enabled bool
|
|
wantMode maintnotifications.Mode
|
|
}{
|
|
{
|
|
name: "disabled mode when flag is false",
|
|
enabled: false,
|
|
wantMode: maintnotifications.ModeDisabled,
|
|
},
|
|
{
|
|
name: "auto mode when flag is true",
|
|
enabled: true,
|
|
wantMode: maintnotifications.ModeAuto,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
cfg := maintNotificationsConfig(tt.enabled)
|
|
if cfg == nil {
|
|
t.Fatalf("maintNotificationsConfig(%v) = nil, want non-nil", tt.enabled)
|
|
}
|
|
if cfg.Mode != tt.wantMode {
|
|
t.Fatalf("maintNotificationsConfig(%v).Mode = %v, want %v", tt.enabled, cfg.Mode, tt.wantMode)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestPrefixedQueue(t *testing.T) {
|
|
oldPrefix := config.Config.Redis.KeyPrefix
|
|
defer func() {
|
|
config.Config.Redis.KeyPrefix = oldPrefix
|
|
}()
|
|
|
|
config.Config.Redis.KeyPrefix = "test:"
|
|
if got := PrefixedQueue("default"); got != "test:default" {
|
|
t.Fatalf("PrefixedQueue() = %q, want %q", got, "test:default")
|
|
}
|
|
|
|
config.Config.Redis.KeyPrefix = ""
|
|
if got := PrefixedQueue("default"); got != "default" {
|
|
t.Fatalf("PrefixedQueue() = %q, want %q", got, "default")
|
|
}
|
|
}
|