Add the Config view: edit and save the settings, applied without a restart
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -122,3 +122,22 @@ func TestTransportErrorHidesAPIKey(t *testing.T) {
|
||||
t.Errorf("error leaks API key: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconfigure(t *testing.T) {
|
||||
var gotKey string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotKey = r.URL.Query().Get("apikey")
|
||||
w.Write([]byte(`{"version":"5.1"}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient("http://127.0.0.1:1", "old") // unreachable until reconfigured
|
||||
if _, err := c.Version(context.Background()); err == nil {
|
||||
t.Fatal("expected a connection error")
|
||||
}
|
||||
c.Reconfigure(srv.URL+"/", "new")
|
||||
v, err := c.Version(context.Background())
|
||||
if err != nil || v != "5.1" || gotKey != "new" {
|
||||
t.Errorf("version=%q key=%q err=%v", v, gotKey, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user