-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
63 lines (57 loc) · 1.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* We want to make sure that fetch-remote-file is working with multi workers.
*/
const execa = require(`execa`)
const path = require(`path`)
const glob = require(`glob`)
const fs = require(`fs-extra`)
const md5File = require(`md5-file`)
const basePath = path.resolve(__dirname, `../../`)
const cleanDirs = () =>
Promise.all([
fs.emptyDir(`${basePath}/public`),
fs.emptyDir(`${basePath}/.cache`),
])
describe(`fetch-remote-file`, () => {
beforeAll(async () => {
await cleanDirs()
await execa(`yarn`, [`build`], {
cwd: basePath,
// we want to force 1 query per worker
env: { NODE_ENV: `production`, GATSBY_PARALLEL_QUERY_CHUNK_SIZE: `1` },
})
}, 60 * 1000)
it("should have the correct md5", async () => {
expect(
await md5File(
path.join(
__dirname,
"../..",
"public/images/50c58a791de3c2303e62084d731799eb/photoA.jpg"
)
)
).toEqual("a9e57a66a10b2d26a1999a4685d7c9ef")
expect(
await md5File(
path.join(
__dirname,
"../..",
"public/images/4910e745c3c453b8795d6ba65c79d99b/photoB.jpg"
)
)
).toEqual("c305dc5c5db45cc773231a507af5116d")
expect(
await md5File(
path.join(
__dirname,
"../..",
"public/images/fb673e75e9534b3cc2d2e24085386d48/photoC.jpg"
)
)
).toEqual("4ba953ba27236727d7abe7d5b8916432")
})
it("should have conflict between workers", async () => {
const files = await fs.readdir(path.join(__dirname, "../../.cache/workers"))
expect(files.length).toBe(4)
})
})