MCPcopy
hub / github.com/PatchMon/PatchMon / TestLoad_ValidEnv

Function TestLoad_ValidEnv

server-source-code/internal/config/config_test.go:7–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestLoad_ValidEnv(t *testing.T) {
8 t.Setenv("ENV_FILE", "/nonexistent")
9 t.Setenv("DATABASE_URL", "postgresql://localhost/test")
10 t.Setenv("JWT_SECRET", "test-secret")
11 t.Setenv("PORT", "3001")
12 t.Setenv("ENABLE_LOGGING", "true")
13
14 cfg, err := Load()
15 if err != nil {
16 t.Fatalf("Load() error = %v", err)
17 }
18 if cfg.DatabaseURL != "postgresql://localhost/test" {
19 t.Errorf("DatabaseURL = %q, want postgresql://localhost/test", cfg.DatabaseURL)
20 }
21 if cfg.Port != 3001 {
22 t.Errorf("Port = %d, want 3001", cfg.Port)
23 }
24 if cfg.Version != DefaultVersion {
25 t.Errorf("Version = %q, want %s", cfg.Version, DefaultVersion)
26 }
27 if !cfg.EnableLogging {
28 t.Error("EnableLogging = false, want true")
29 }
30}
31
32func TestLoad_MissingDatabaseURL(t *testing.T) {
33 t.Setenv("ENV_FILE", "/nonexistent")

Callers

nothing calls this directly

Calls 2

LoadFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected