- rename ctcloud -> bucketeer everywhere (cmd/bucketeer, binary, compose service) - group brand assets under assets/ (light/dark logo + UI screenshot) - move long-form docs under docs/ (ARCHITECTURE, DESIGN, GOAL) and add docs/SKILL.md: how an agent queries/audits a running instance and answers user questions from the API and PostgreSQL - README: large logo (light/dark picture) and UI screenshot, repository layout - .gitignore: /bucketeer, .env, pgdata, build/test artifacts, OS junk - .dockerignore: keep brand/docs/markdown out of the build context
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestLoadDefaults(t *testing.T) {
|
|
t.Setenv("DATABASE_URL", "postgres://localhost/bucketeer")
|
|
c, err := Load()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if c.DatabaseURL != "postgres://localhost/bucketeer" {
|
|
t.Fatalf("database url = %q", c.DatabaseURL)
|
|
}
|
|
if c.DNSWorkers != 64 || c.DNSMaxCNAMEdepth != 8 {
|
|
t.Fatalf("unexpected DNS defaults: %+v", c)
|
|
}
|
|
if c.ActiveProbing {
|
|
t.Fatal("active probing must default to false")
|
|
}
|
|
}
|
|
|
|
func TestLoadOverrides(t *testing.T) {
|
|
t.Setenv("DATABASE_URL", "postgres://localhost/bucketeer")
|
|
t.Setenv("DNS_WORKERS", "4")
|
|
t.Setenv("ACTIVE_PROBING", "true")
|
|
t.Setenv("DB_FLUSH_INTERVAL", "250ms")
|
|
t.Setenv("STATS_INTERVAL", "30s")
|
|
c, err := Load()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if c.DNSWorkers != 4 || !c.ActiveProbing {
|
|
t.Fatalf("overrides not applied: %+v", c)
|
|
}
|
|
if c.DBFlushInterval != 250*time.Millisecond || c.StatsInterval != 30*time.Second {
|
|
t.Fatalf("duration overrides not applied: %+v", c)
|
|
}
|
|
}
|
|
|
|
func TestLoadInvalid(t *testing.T) {
|
|
t.Setenv("DATABASE_URL", "")
|
|
if _, err := Load(); err == nil {
|
|
t.Fatal("expected error without DATABASE_URL")
|
|
}
|
|
t.Setenv("DATABASE_URL", "postgres://localhost/bucketeer")
|
|
t.Setenv("LOG_LEVEL", "verbose")
|
|
if _, err := Load(); err == nil {
|
|
t.Fatal("expected error for bad LOG_LEVEL")
|
|
}
|
|
}
|