@@ -6,6 +6,8 @@ const Updates = require('..')
6
6
7
7
const { TOKEN : token } = process . env
8
8
9
+ const cache = 100
10
+
9
11
const createServer = ( ) =>
10
12
new Promise ( resolve => {
11
13
const updates = new Updates ( { token } )
@@ -27,12 +29,14 @@ test('Updates', async t => {
27
29
t . equal ( res . status , 404 )
28
30
29
31
await t . test ( 'exists and has update' , async t => {
30
- const res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
31
- t . equal ( res . status , 200 )
32
- const body = await res . json ( )
33
- t . ok ( body . name )
34
- t . match ( body . url , / - m a c \. z i p $ / )
35
- t . ok ( body . notes )
32
+ for ( let i = 0 ; i < cache ; i ++ ) {
33
+ const res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
34
+ t . equal ( res . status , 200 )
35
+ const body = await res . json ( )
36
+ t . ok ( body . name )
37
+ t . match ( body . url , / - m a c \. z i p $ / )
38
+ t . ok ( body . notes )
39
+ }
36
40
} )
37
41
38
42
await t . test ( 'exists but no updates' , async t => {
@@ -44,60 +48,77 @@ test('Updates', async t => {
44
48
const release = releases . find (
45
49
release => ! release . draft && ! release . prerelease
46
50
)
47
- res = await fetch (
48
- `${ address } /dat-land/dat-desktop/darwin/${ release . name } `
49
- )
50
- t . equal ( res . status , 204 )
51
+
52
+ for ( let i = 0 ; i < cache ; i ++ ) {
53
+ res = await fetch (
54
+ `${ address } /dat-land/dat-desktop/darwin/${ release . name } `
55
+ )
56
+ t . equal ( res . status , 204 )
57
+ }
51
58
} )
52
59
53
60
await t . test ( 'exists but has no releases' , async t => {
54
- const res = await fetch (
55
- `${ address } /juliangruber/brace-expansion/darwin/0.0.0`
56
- )
57
- t . equal ( res . status , 404 )
61
+ for ( let i = 0 ; i < cache ; i ++ ) {
62
+ const res = await fetch (
63
+ `${ address } /juliangruber/brace-expansion/darwin/0.0.0`
64
+ )
65
+ t . equal ( res . status , 404 )
66
+ }
58
67
} )
59
68
60
69
await t . test ( "doesn't exist" , async t => {
61
- const res = await fetch ( `${ address } /doesnot/exist-123123123/darwin/0.0.0` )
62
- t . equal ( res . status , 404 )
70
+ for ( let i = 0 ; i < cache ; i ++ ) {
71
+ const res = await fetch (
72
+ `${ address } /doesnot/exist-123123123/darwin/0.0.0`
73
+ )
74
+ t . equal ( res . status , 404 )
75
+ }
63
76
} )
64
77
} )
65
78
66
79
await t . test ( 'Platforms' , async t => {
67
80
await t . test ( 'Darwin' , async t => {
68
- let res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
69
- t . equal ( res . status , 200 )
70
- let body = await res . json ( )
71
- t . match ( body . url , / - m a c \. z i p $ / )
72
-
73
- res = await fetch ( `${ address } /webtorrent/webtorrent-desktop/darwin/0.0.0` )
74
- t . equal ( res . status , 200 )
75
- body = await res . json ( )
76
- t . match ( body . url , / - d a r w i n \. z i p $ / )
81
+ for ( let i = 0 ; i < cache ; i ++ ) {
82
+ let res = await fetch ( `${ address } /dat-land/dat-desktop/darwin/1.0.0` )
83
+ t . equal ( res . status , 200 )
84
+ let body = await res . json ( )
85
+ t . match ( body . url , / - m a c \. z i p $ / )
86
+
87
+ res = await fetch (
88
+ `${ address } /webtorrent/webtorrent-desktop/darwin/0.0.0`
89
+ )
90
+ t . equal ( res . status , 200 )
91
+ body = await res . json ( )
92
+ t . match ( body . url , / - d a r w i n \. z i p $ / )
93
+ }
77
94
} )
78
95
79
96
await t . test ( 'Win32' , async t => {
80
- const res = await fetch ( `${ address } /zeit/hyper/win32/0.0.0` )
81
- t . equal ( res . status , 200 )
82
- const body = await res . json ( )
83
- t . match ( body . url , / \. e x e $ / )
84
- t . ok ( body . name )
85
-
86
- await t . test ( 'RELEASES' , async t => {
87
- let res = await fetch (
88
- `${ address } /zeit/hyper/win32/0.0.0/RELEASES?some-extra`
89
- )
97
+ for ( let i = 0 ; i < cache ; i ++ ) {
98
+ const res = await fetch ( `${ address } /zeit/hyper/win32/0.0.0` )
90
99
t . equal ( res . status , 200 )
91
- const body = await res . text ( )
92
- t . match (
93
- body ,
94
- / ^ [ ^ ] + h t t p s : \/ \/ g i t h u b .c o m \/ z e i t \/ h y p e r \/ r e l e a s e s \/ d o w n l o a d \/ [ ^ / ] + \/ h y p e r - [ ^ - ] + - f u l l .n u p k g [ ^ ] + $ /
95
- )
100
+ const body = await res . json ( )
101
+ t . match ( body . url , / \. e x e $ / )
102
+ t . ok ( body . name )
103
+ }
96
104
97
- res = await fetch (
98
- `${ address } /juliangruber/brace-expansion/win32/0.0.0/RELEASES`
99
- )
100
- t . equal ( res . status , 404 )
105
+ await t . test ( 'RELEASES' , async t => {
106
+ for ( let i = 0 ; i < cache ; i ++ ) {
107
+ let res = await fetch (
108
+ `${ address } /zeit/hyper/win32/0.0.0/RELEASES?some-extra`
109
+ )
110
+ t . equal ( res . status , 200 )
111
+ const body = await res . text ( )
112
+ t . match (
113
+ body ,
114
+ / ^ [ ^ ] + h t t p s : \/ \/ g i t h u b .c o m \/ z e i t \/ h y p e r \/ r e l e a s e s \/ d o w n l o a d \/ [ ^ / ] + \/ h y p e r - [ ^ - ] + - f u l l .n u p k g [ ^ ] + $ /
115
+ )
116
+
117
+ res = await fetch (
118
+ `${ address } /juliangruber/brace-expansion/win32/0.0.0/RELEASES`
119
+ )
120
+ t . equal ( res . status , 404 )
121
+ }
101
122
} )
102
123
} )
103
124
} )
0 commit comments