statuses update

This commit is contained in:
sanek5g
2026-06-24 18:58:35 +03:00
parent fdddacf534
commit 0a9bfd0799
39 changed files with 2099 additions and 12 deletions

View File

@@ -0,0 +1,47 @@
package config
import (
"testing"
"time"
)
func TestLoadDefaults(t *testing.T) {
t.Setenv("STORAGE_ROOT", "")
t.Setenv("RABBITMQ_URL", "")
t.Setenv("STATUS_QUEUE", "")
cfg := Load()
if cfg.StorageRoot != "/data/storage" {
t.Fatalf("StorageRoot: got %q", cfg.StorageRoot)
}
if cfg.StatusQueue != "pipeline.status" {
t.Fatalf("StatusQueue: got %q", cfg.StatusQueue)
}
if cfg.PollInterval != 5*time.Second {
t.Fatalf("PollInterval: got %v", cfg.PollInterval)
}
if cfg.StableChecks != 3 {
t.Fatalf("StableChecks: got %d", cfg.StableChecks)
}
}
func TestLoadFromEnv(t *testing.T) {
t.Setenv("STORAGE_ROOT", "/tmp/storage")
t.Setenv("POLL_INTERVAL", "10s")
t.Setenv("STABLE_CHECKS", "5")
t.Setenv("STATUS_QUEUE", "custom.status")
cfg := Load()
if cfg.StorageRoot != "/tmp/storage" {
t.Fatalf("StorageRoot: got %q", cfg.StorageRoot)
}
if cfg.PollInterval != 10*time.Second {
t.Fatalf("PollInterval: got %v", cfg.PollInterval)
}
if cfg.StableChecks != 5 {
t.Fatalf("StableChecks: got %d", cfg.StableChecks)
}
if cfg.StatusQueue != "custom.status" {
t.Fatalf("StatusQueue: got %q", cfg.StatusQueue)
}
}