forked from mirrors/probot
fix: support setting `baseUrl` on Octokit constructor instead of Probot constructor (#1552)
This commit is contained in:
parent
01c2006700
commit
453ddd29bb
|
@ -43,11 +43,14 @@ export function getProbotOctokitWithDefaults(options: Options) {
|
|||
redisConfig: options.redisConfig,
|
||||
});
|
||||
|
||||
const defaultOptions: any = {
|
||||
baseUrl: options.baseUrl,
|
||||
let defaultOptions: any = {
|
||||
auth: authOptions,
|
||||
};
|
||||
|
||||
if (options.baseUrl) {
|
||||
defaultOptions.baseUrl = options.baseUrl;
|
||||
}
|
||||
|
||||
if (octokitThrottleOptions) {
|
||||
defaultOptions.throttle = octokitThrottleOptions;
|
||||
}
|
||||
|
|
|
@ -216,6 +216,23 @@ describe("Probot", () => {
|
|||
baseUrl: "https://notreallygithub.com/api/v3",
|
||||
}).load(appFn);
|
||||
});
|
||||
|
||||
it("requests from the correct API URL when setting `baseUrl` on Octokit constructor", async () => {
|
||||
const appFn = async (app: Probot) => {
|
||||
const octokit = await app.auth();
|
||||
expect(octokit.request.endpoint.DEFAULTS.baseUrl).toEqual(
|
||||
"https://notreallygithub.com/api/v3"
|
||||
);
|
||||
};
|
||||
|
||||
new Probot({
|
||||
appId,
|
||||
privateKey,
|
||||
Octokit: ProbotOctokit.defaults({
|
||||
baseUrl: "https://notreallygithub.com/api/v3",
|
||||
}),
|
||||
}).load(appFn);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ghe support with http", () => {
|
||||
|
|
Loading…
Reference in New Issue