-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathindex.find.js
54 lines (50 loc) · 1.13 KB
/
index.find.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
'use strict'
const CacheIndex = require('../util/cache-index')
const Tacks = require('tacks')
const index = require('../../lib/entry-index')
module.exports = (suite, CACHE) => {
suite.add('index.find cache hit', {
defer: true,
fn (deferred) {
index.find(
CACHE, this.entry.key
).then(
() => deferred.resolve(),
err => deferred.reject(err)
)
},
onStart () {
const entry = {
key: 'whatever',
integrity: 'sha512-deadbeef',
time: 12345,
metadata: 'omgsometa'
}
const fixture = new Tacks(CacheIndex({
'whatever': entry
}))
fixture.create(CACHE)
this.fixture = fixture
this.entry = entry
}
})
suite.add('index.find cache miss', {
defer: true,
fn (deferred) {
index.find(
CACHE, 'whatever'
).then(
() => deferred.resolve(),
err => deferred.reject(err)
)
},
onStart () {
const fixture = new Tacks(CacheIndex({
'foo': { key: 'foo' },
'w/e': { key: 'w/e' }
}))
fixture.create(CACHE)
this.fixture = fixture
}
})
}