package client import("context";"net/http";"net/http/httptest";"testing";"strings") func TestClientPost(t *testing.T){ s:=httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter,r *http.Request){if r.URL.Path!="/api/v5/btc/wallet/balance"{t.Errorf("path: %s",r.URL.Path)};if r.Header.Get("X-BTC-KEY")!="test-only"{t.Error("missing test key")};w.Write([]byte(`{"ok":true,"result":{}}`))}));defer s.Close() c:=Client{BaseURL:s.URL};got,err:=c.Post(context.Background(),"/api/v5/btc/wallet/balance",[]byte(`{}`),"test-only");if err!=nil||!strings.Contains(string(got),`"ok":true`){t.Fatalf("got=%s err=%v",got,err)} if _,err=c.Post(context.Background(),"/admin",nil,"");err==nil{t.Fatal("expected rejection")} }