MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestLoadConfig_Defaults

Function TestLoadConfig_Defaults

pkg/mcp/config_test.go:22–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestLoadConfig_Defaults(t *testing.T) {
23 // Clear any env vars that might be set
24 os.Unsetenv("GOSQLX_MCP_HOST")
25 os.Unsetenv("GOSQLX_MCP_PORT")
26 os.Unsetenv("GOSQLX_MCP_AUTH_TOKEN")
27
28 cfg, err := LoadConfig()
29 if err != nil {
30 t.Fatalf("unexpected error: %v", err)
31 }
32 if cfg.Host != "127.0.0.1" {
33 t.Errorf("Host = %q, want %q", cfg.Host, "127.0.0.1")
34 }
35 if cfg.Port != 8080 {
36 t.Errorf("Port = %d, want 8080", cfg.Port)
37 }
38 if cfg.AuthEnabled() {
39 t.Error("AuthEnabled() = true, want false")
40 }
41 if cfg.Addr() != "127.0.0.1:8080" {
42 t.Errorf("Addr() = %q, want %q", cfg.Addr(), "127.0.0.1:8080")
43 }
44}
45
46func TestLoadConfig_CustomPort(t *testing.T) {
47 os.Setenv("GOSQLX_MCP_PORT", "9090")

Callers

nothing calls this directly

Calls 6

AuthEnabledMethod · 0.80
AddrMethod · 0.80
LoadConfigFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected