package config

import (
	"os"
	"path/filepath"
	"testing"
)

func TestLoadUsesFileValues(t *testing.T) {
	dir := t.TempDir()
	cfgPath := filepath.Join(dir, "wormhole.yaml")
	content := []byte(`server:
  bridge_addr: ":9528"
  http_addr: ":9529"
database:
  path: "./tmp.db"
auth:
  jwt_secret: "test-secret"
  token_ttl: 1h
metrics:
  flush_interval: 10s
`)
	if err := os.WriteFile(cfgPath, content, 0644); err != nil {
		t.Fatal(err)
	}
	cfg, err := Load(cfgPath)
	if err != nil {
		t.Fatal(err)
	}
	if cfg.Server.BridgeAddr != ":9528" || cfg.Server.HTTPAddr != ":9529" {
		t.Fatalf("server config not applied: %+v", cfg.Server)
	}
}
