backend barebone done, big chunk of work done
CI / Go (build + vet + test) (push) Canceled after 0s
CI / Web (build + lint) (push) Canceled after 0s

This commit is contained in:
vantablackTea
2026-09-27 19:42:49 +03:00
parent 1a669c948a
commit c79a3cfe68
36 changed files with 2607 additions and 17 deletions
@@ -24,6 +24,7 @@ func TestLoadFromEnv(t *testing.T) {
t.Setenv("MESSENGER_HTTP_ADDR", ":9000")
t.Setenv("MESSENGER_ENV", "production")
t.Setenv("MESSENGER_ALLOWED_ORIGINS", "https://a.example, https://b.example")
t.Setenv("MESSENGER_JWT_SECRET", "prod-secret-at-least-32-chars-long!!")
cfg, err := Load()
if err != nil {
@@ -38,6 +39,9 @@ func TestLoadFromEnv(t *testing.T) {
if len(cfg.AllowedOrigins) != 2 || cfg.AllowedOrigins[1] != "https://b.example" {
t.Errorf("AllowedOrigins = %v, want [https://a.example https://b.example]", cfg.AllowedOrigins)
}
if cfg.DatabaseURL == "" {
t.Error("DatabaseURL = empty, want default DSN")
}
}
func TestLoadInvalidEnv(t *testing.T) {
@@ -47,3 +51,12 @@ func TestLoadInvalidEnv(t *testing.T) {
t.Fatal("Load() error = nil, want validation error")
}
}
func TestLoadRequiresJWTSecretInProduction(t *testing.T) {
t.Setenv("MESSENGER_ENV", "production")
t.Setenv("MESSENGER_JWT_SECRET", "")
if _, err := Load(); err == nil {
t.Fatal("Load() error = nil, want missing JWT secret error")
}
}