CI / go (Server) (push) Successful in 23m34s
CI / go (Web-App) (push) Successful in 12m21s
CI / frontend (push) Failing after 10m55s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Successful in 1h57m19s
CI / mobile (push) Failing after 5m8s
CI / docker (push) Failing after 41m19s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
docwell-db's base image (tajniak81/pocketbase-docker-root) listens on 8070 by default. Use that port everywhere instead of overriding it to 8090: the Database image, every Docker compose file and .env example, the AIO start script, docwell-server's DOCWELL_PB_URL default, and the docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package config
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func lookup(env map[string]string) func(string) (string, bool) {
|
|
return func(k string) (string, bool) {
|
|
v, ok := env[k]
|
|
return v, ok
|
|
}
|
|
}
|
|
|
|
func TestDefaults(t *testing.T) {
|
|
cfg, err := fromLookup(lookup(map[string]string{
|
|
"DOCWELL_PB_EMAIL": "admin@docwell.test",
|
|
"DOCWELL_PB_PASSWORD": "secret",
|
|
}))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.Addr != ":8080" {
|
|
t.Errorf("Addr = %q", cfg.Addr)
|
|
}
|
|
if cfg.ShutdownTimeout != 15*time.Second {
|
|
t.Errorf("ShutdownTimeout = %v", cfg.ShutdownTimeout)
|
|
}
|
|
if len(cfg.CORSOrigins) != 2 {
|
|
t.Errorf("CORSOrigins = %v", cfg.CORSOrigins)
|
|
}
|
|
if !cfg.SignupEnabled || len(cfg.SignupDomains) != 0 {
|
|
t.Errorf("signup = %v %v", cfg.SignupEnabled, cfg.SignupDomains)
|
|
}
|
|
}
|
|
|
|
func TestOverridesAndTrimming(t *testing.T) {
|
|
cfg, err := fromLookup(lookup(map[string]string{
|
|
"DOCWELL_PB_EMAIL": "a@b.c",
|
|
"DOCWELL_PB_PASSWORD": "x",
|
|
"DOCWELL_PB_URL": "http://db:8070/",
|
|
"DOCWELL_CORS_ORIGINS": " https://a.test , ,https://b.test",
|
|
"DOCWELL_SHUTDOWN_TIMEOUT": "3s",
|
|
"DOCWELL_SIGNUP_ENABLED": "false",
|
|
"DOCWELL_SIGNUP_DOMAINS": "acme.test",
|
|
}))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.PocketBaseURL != "http://db:8070" {
|
|
t.Errorf("PocketBaseURL = %q", cfg.PocketBaseURL)
|
|
}
|
|
if len(cfg.CORSOrigins) != 2 || cfg.CORSOrigins[1] != "https://b.test" {
|
|
t.Errorf("CORSOrigins = %v", cfg.CORSOrigins)
|
|
}
|
|
if cfg.ShutdownTimeout != 3*time.Second {
|
|
t.Errorf("ShutdownTimeout = %v", cfg.ShutdownTimeout)
|
|
}
|
|
if cfg.SignupEnabled || len(cfg.SignupDomains) != 1 {
|
|
t.Errorf("signup = %v %v", cfg.SignupEnabled, cfg.SignupDomains)
|
|
}
|
|
}
|
|
|
|
func TestMissingCredentials(t *testing.T) {
|
|
if _, err := fromLookup(lookup(nil)); err == nil {
|
|
t.Fatal("expected error without PocketBase credentials")
|
|
}
|
|
}
|