Skip to content

Commit 3937e50

Browse files
committed
Formatting
1 parent bde5480 commit 3937e50

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

__tests__/gpg.test.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
import * as exec from "@actions/exec";
22
import { setupKeys, verify, refreshKeys } from "../src/gpg";
33

4-
jest.mock("@actions/exec")
4+
jest.mock("@actions/exec");
55

6-
const mockExec = exec.exec as jest.Mock
6+
const mockExec = exec.exec as jest.Mock;
77

88
describe("gpg", () => {
9-
109
afterEach(() => {
11-
mockExec.mockClear()
12-
})
10+
mockExec.mockClear();
11+
});
1312

14-
it('uses the first responding keyserver in the pool', async () => {
15-
mockExec.mockImplementation(() => Promise.resolve(0))
16-
await refreshKeys()
17-
expect(mockExec).toBeCalledTimes(1)
18-
})
13+
it("uses the first responding keyserver in the pool", async () => {
14+
mockExec.mockImplementation(() => Promise.resolve(0));
15+
await refreshKeys();
16+
expect(mockExec).toBeCalledTimes(1);
17+
});
1918

20-
it('uses the next keyserver in the pool if the previous fails', async () => {
21-
const failingServers = 3
22-
let testedServers = 0
19+
it("uses the next keyserver in the pool if the previous fails", async () => {
20+
const failingServers = 3;
21+
let testedServers = 0;
2322

2423
mockExec.mockImplementation(() => {
25-
testedServers++
24+
testedServers++;
2625
if (testedServers >= failingServers) {
27-
return Promise.resolve(0)
26+
return Promise.resolve(0);
2827
} else {
29-
return Promise.resolve(1)
28+
return Promise.resolve(1);
3029
}
31-
})
30+
});
31+
32+
await refreshKeys();
33+
expect(mockExec).toBeCalledTimes(3);
34+
});
3235

33-
await refreshKeys()
34-
expect(mockExec).toBeCalledTimes(3)
35-
})
36+
it("throws an error if all servers in the pool fails", async () => {
37+
mockExec.mockImplementation(() => Promise.resolve(1));
3638

37-
it('throws an error if all servers in the pool fails', async () => {
38-
mockExec.mockImplementation(() => Promise.resolve(1))
39-
4039
try {
41-
await refreshKeys()
40+
await refreshKeys();
4241
} catch (e) {
43-
expect(e).toEqual(new Error("Failed to refresh keys from any server in the pool."));
42+
expect(e).toEqual(
43+
new Error("Failed to refresh keys from any server in the pool.")
44+
);
4445
}
45-
})
46-
47-
})
46+
});
47+
});

src/gpg.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ export async function refreshKeys() {
2626
"ha.pool.sks-keyservers.net",
2727
"keyserver.ubuntu.com",
2828
"hkp://keyserver.ubuntu.com",
29-
"pgp.mit.edu"
30-
]
29+
"pgp.mit.edu",
30+
];
3131

3232
for (const server of pool) {
3333
core.debug(`Refreshing keys from ${server}`);
34-
if (await refreshKeysFromServer(server)) {
34+
if (await refreshKeysFromServer(server)) {
3535
core.debug(`Refresh successful`);
36-
return
36+
return;
3737
}
3838
core.debug(`Refresh failed`);
3939
}
40-
40+
4141
throw new Error("Failed to refresh keys from any server in the pool.");
4242
}
4343

4444
function refreshKeysFromServer(server: string): Promise<boolean> {
45-
return exec(
46-
`gpg --keyserver ${server} --refresh-keys Swift`
47-
)
48-
.then( code => code === 0 )
49-
.catch(error => {
50-
core.warning(`An error occurred when trying to refresh keys from ${server}: ${error}`)
51-
return false
52-
})
45+
return exec(`gpg --keyserver ${server} --refresh-keys Swift`)
46+
.then((code) => code === 0)
47+
.catch((error) => {
48+
core.warning(
49+
`An error occurred when trying to refresh keys from ${server}: ${error}`
50+
);
51+
return false;
52+
});
5353
}

0 commit comments

Comments
 (0)