Files
OpenFlare/backend/plugins/drivers/driver_asynq_worker/utils_test.go
T
ryan 299ac30ee4 refactor(core): align with cordis spatiotemporal composability architecture
- Purify core micro-kernel by removing context hardcoded helpers and reverse dependencies
- Eliminate init() side effects in infra plugins with reversible lifecycle disposal
- Completely isolate plugins by removing cross-plugin imports and using core/contracts
- Introduce TaskService and RiskControlService contracts for unified cross-plugin APIs
- Regenerate Swagger documentation and update developer guide matrix
- Achieve 0 violations in check_cordis_architecture.sh and 100% test pass
2026-08-28 15:05:31 +08:00

61 lines
1.4 KiB
Go

// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package driver_asynq_worker
import (
"testing"
"github.com/redis/go-redis/v9/maintnotifications"
"Wavelet/pkg/config"
)
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")
}
}