This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff.test.js
More file actions
47 lines (39 loc) · 1.28 KB
/
diff.test.js
File metadata and controls
47 lines (39 loc) · 1.28 KB
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
const test = require('ava')
const tutil = require('./util')
const pda = require('../index')
var daemon
test.before(async () => {
daemon = await tutil.createOneDaemon()
})
test.after(async () => {
await daemon.cleanup()
})
test('diff', async t => {
var changes
const archive = await tutil.createArchive(daemon, [
'foo.txt',
{ name: 'bar.data', content: Buffer.from([0x00, 0x01]) },
'subdir/',
'subdir/foo.txt',
{ name: 'subdir/bar.data', content: Buffer.from([0x00, 0x01]) }
])
changes = await pda.diff(archive)
t.is(changes.length, 5)
t.is(changes[0].type, 'put')
t.is(changes[0].name, 'subdir')
t.is(typeof changes[0].value.stat, 'object')
t.is(changes[0].value.stat.mode, 16877)
changes = await pda.diff(archive, 2)
t.is(changes.length, 4)
var oldArchive = await archive.checkout(2)
var changes2 = await pda.diff(archive, oldArchive)
t.deepEqual(changes, changes2)
changes = await pda.diff(archive, 0, 'subdir')
t.is(changes.length, 3)
var archive2 = await tutil.createArchive(daemon, ['bar'])
await pda.mount(archive, '/foo', archive2.key)
// TODO mounts
await pda.writeFile(archive, '/meta', '', {metadata: {foo: 'bar'}})
changes = await pda.diff(archive)
t.is(changes.find(c => c.name === 'meta').value.stat.metadata.foo, 'bar')
})