Merge pull request #122 from github/case-bug

ensure all handles are treated the same (as lowercase)
This commit is contained in:
Grant Birkinbine 2023-11-27 14:21:02 -07:00 коммит произвёл GitHub
Родитель 5f97a67765 a3d1539bb3
Коммит 54fc5236ee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 42 добавлений и 1 удалений

Просмотреть файл

@ -31,6 +31,31 @@ requesters:
});
});
test("We receive the expected config content with values converted to lowercase", async () => {
let configContent = `---
requesters:
roBot:
labels:
- testing
RoBot_TwO:
labels:
- dependencies
- github_actions
`;
let provider = new GitHubProvider("token");
jest
.spyOn(provider, "getConfigContent")
.mockImplementation(() => configContent);
expect(provider.getConfigContent()).toBe(configContent);
let privilegedRequester = new PrivilegedRequester(provider);
let requesters = await privilegedRequester.getRequesters();
expect(requesters).toStrictEqual({
robot: { labels: ["testing"] },
robot_two: { labels: ["dependencies", "github_actions"] },
});
});
test("We do not receive the expected config content", async () => {
let provider = new GitHubProvider("token");
jest.spyOn(provider, "getConfigContent").mockImplementation(() => false);

8
dist/index.js сгенерированный поставляемый
Просмотреть файл

@ -37086,6 +37086,14 @@ class PrivilegedRequester {
this.configContents = yaml.load(config);
this.requesters = this.configContents["requesters"];
// set the key (which is the requester name) to lowercase
if (this.requesters) {
this.requesters = Object.keys(this.requesters).reduce((acc, key) => {
acc[key.toLowerCase()] = this.requesters[key];
return acc;
}, {});
}
} catch (err) {
lib_core.error(
`There was a problem with the privileged requester configuration.\n${err}\n${err.stack}`,

2
dist/index.js.map сгенерированный поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -18,6 +18,14 @@ class PrivilegedRequester {
this.configContents = yaml.load(config);
this.requesters = this.configContents["requesters"];
// set the key (which is the requester name) to lowercase
if (this.requesters) {
this.requesters = Object.keys(this.requesters).reduce((acc, key) => {
acc[key.toLowerCase()] = this.requesters[key];
return acc;
}, {});
}
} catch (err) {
core.error(
`There was a problem with the privileged requester configuration.\n${err}\n${err.stack}`,