fix: support setting `baseUrl` on Octokit constructor instead of Probot constructor (#1552)

This commit is contained in:
Gregor Martynus 2021-06-07 11:38:32 -07:00 committed by GitHub
parent 01c2006700
commit 453ddd29bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -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;
}

View File

@ -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", () => {