-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.js
43 lines (37 loc) · 888 Bytes
/
test.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
import process from 'node:process';
import {Buffer} from 'node:buffer';
import test from 'ava';
import Vinyl from 'vinyl';
import {pEvent} from 'p-event';
import chown from './index.js';
test('chown files', async t => {
const stream = chown(501, 20);
stream.end(new Vinyl({
stat: {
uid: 400,
gid: 10,
},
contents: Buffer.from(''),
}));
const file = await pEvent(stream, 'data');
t.is(file.stat.uid, 501);
t.is(file.stat.gid, 20);
});
if (!('CI' in process.env)) {
test.failing('chown files using a username', async t => {
const username = 'root';
const expectedUid = 0;
const expectedGid = 0;
const stream = chown(username);
stream.end(new Vinyl({
stat: {
uid: 400,
gid: 10,
},
contents: Buffer.from(''),
}));
const file = await pEvent(stream, 'data');
t.is(file.stat.uid, expectedUid);
t.is(file.stat.gid, expectedGid);
});
}