feat: support updating Garmin credentials at runtime

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 18:57:54 +02:00
parent 684b026ff4
commit 6f62686d29
3 changed files with 47 additions and 0 deletions

View File

@@ -20,3 +20,20 @@ func TestParseAuthResult(t *testing.T) {
}
}
}
func TestMcpClient_UpdateCredentials_ResetsStartedState(t *testing.T) {
c := &mcpClient{cfg: Config{GarminEmail: "old@example.com", GarminPassword: "old"}}
c.started = true // simulate an already-spawned subprocess
c.UpdateCredentials("new@example.com", "new")
if c.cfg.GarminEmail != "new@example.com" || c.cfg.GarminPassword != "new" {
t.Errorf("cfg after update = %+v, want new@example.com/new", c.cfg)
}
if c.started {
t.Error("started should be reset to false so the next call respawns the subprocess")
}
if c.inner != nil {
t.Error("inner should be cleared so ensureStarted spawns a fresh client")
}
}