You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Appreciate ideas for making it easier for extension authors to build better tests, a sentiment I believe @williammartin and I both support! ❤
I'm hesitant putting localhost/127.0.0.1 specific logic into restUrl as such URLs should be URLs and return back unmodified from the existing logic.
That said, I can see the challenge behind convincing the api logic to treat a given URL as a GHES or GitHub tenancy host 🤔 Possibly a host type override option?
The standard library's httptest package makes stubbing APIs easy, if the client calls the test server's URL:
In api.ClientOptions, one of the configuration fields is
Host
go-gh/pkg/api/client_options.go
Line 38 in 25db6b9
for certain values the argument is returned unmodified
go-gh/pkg/api/rest_client.go
Lines 151 to 154 in 25db6b9
I would like to propose adding another condition to the
restURL
function which would return the unmodifiedhttptest
server URLThis aligns with the conditional check on the prefix for the
pathOrURL
argument.For reference, setting the
ts.URL
value toHost
results in a URL similar to:as it satisfies this condition
go-gh/pkg/api/rest_client.go
Line 163 in 25db6b9
I don't know if this means my proposed solution would break with Enterprises.
In writing this all out, I also realized that passing the hostname + path to
client.Get
, rather than just the api path, solves this issue.The text was updated successfully, but these errors were encountered: