statuses update
This commit is contained in:
@@ -17,6 +17,7 @@ type Config struct {
|
||||
RabbitURL string
|
||||
Exchange string
|
||||
RoutingKey string
|
||||
StatusQueue string
|
||||
}
|
||||
|
||||
func Load() Config {
|
||||
@@ -31,6 +32,7 @@ func Load() Config {
|
||||
RabbitURL: getEnv("RABBITMQ_URL", "amqp://guest:guest@localhost:5672/"),
|
||||
Exchange: getEnv("RABBITMQ_EXCHANGE", "audio_pipeline"),
|
||||
RoutingKey: getEnv("RABBITMQ_ROUTING_KEY", "audio.new"),
|
||||
StatusQueue: getEnv("STATUS_QUEUE", "pipeline.status"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
watcher/internal/config/config_test.go
Normal file
47
watcher/internal/config/config_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user