@@ -16,21 +16,39 @@ describe("gpg", () => {
16
16
expect ( mockExec ) . toBeCalledTimes ( 1 ) ;
17
17
} ) ;
18
18
19
- it ( "uses the next keyserver in the pool if the previous fails" , async ( ) => {
20
- const failingServers = 3 ;
21
- let testedServers = 0 ;
19
+ // NOTE: Currently disabled as the pool only contains one server
20
+ // it("uses the next keyserver in the pool if the previous fails", async () => {
21
+ // const failingServers = 3;
22
+ // let testedServers = 0;
23
+
24
+ // mockExec.mockImplementation(() => {
25
+ // testedServers++;
26
+ // if (testedServers >= failingServers) {
27
+ // return Promise.resolve(0);
28
+ // } else {
29
+ // return Promise.resolve(1);
30
+ // }
31
+ // });
32
+
33
+ // await refreshKeys();
34
+ // expect(mockExec).toBeCalledTimes(3);
35
+ // });
36
+
37
+ it ( "makes a second attempt if the keyserver fails" , async ( ) => {
38
+ const attempts = 2 ;
39
+ let tests = 0 ;
22
40
23
41
mockExec . mockImplementation ( ( ) => {
24
- testedServers ++ ;
25
- if ( testedServers >= failingServers ) {
42
+ tests ++ ;
43
+ if ( tests >= attempts ) {
26
44
return Promise . resolve ( 0 ) ;
27
45
} else {
28
46
return Promise . resolve ( 1 ) ;
29
47
}
30
48
} ) ;
31
49
32
50
await refreshKeys ( ) ;
33
- expect ( mockExec ) . toBeCalledTimes ( 3 ) ;
51
+ expect ( mockExec ) . toBeCalledTimes ( 2 ) ;
34
52
} ) ;
35
53
36
54
it ( "throws an error if all servers in the pool fails" , async ( ) => {
0 commit comments