Files
lijiaoqiao/supply-api/internal/config/config_samples_test.go
Your Name 5ea6750cf3 test(supply-api): validate shipped config samples
Add regression tests for the shipped development and SMS sample configs, and fix the SMS example to match the runtime flat Config schema instead of nested provider blocks. Verified with fresh go test runs for ./internal/config and ./internal/sms before commit.
2026-04-11 11:31:05 +08:00

32 lines
878 B
Go

package config
import (
"path/filepath"
"testing"
)
func TestDevSampleConfigLoads(t *testing.T) {
configPath := filepath.Join("..", "..", "config", "config.dev.yaml")
cfg, err := LoadFromPath("dev", configPath)
if err != nil {
t.Fatalf("expected dev sample config to load, got error: %v", err)
}
if cfg.Server.Addr != ":18082" {
t.Fatalf("expected addr :18082, got %s", cfg.Server.Addr)
}
if cfg.Database.Host != "localhost" {
t.Fatalf("expected database host localhost, got %s", cfg.Database.Host)
}
if cfg.Redis.Host != "localhost" {
t.Fatalf("expected redis host localhost, got %s", cfg.Redis.Host)
}
if cfg.Token.Issuer != "lijiaoqiao/supply-api" {
t.Fatalf("expected issuer lijiaoqiao/supply-api, got %s", cfg.Token.Issuer)
}
if cfg.Settlement.WithdrawEnabled {
t.Fatal("expected dev sample config to keep withdraw disabled by default")
}
}