mirror of
https://github.com/zhigang1992/yarn.git
synced 2026-06-11 08:49:57 +08:00
**Summary** Follow up to #4431. `isFakeRoot` didn't have any tests and it was broken from the start. #4431 solved it and it was merged to be included in 1.0.2 without tests. This patch adds the missing tests for this function. **Test plan** Added new tests, duh :D
25 lines
590 B
JavaScript
25 lines
590 B
JavaScript
/* @flow */
|
|
|
|
import {isRootUser, isFakeRoot} from '../../src/util/root-user.js';
|
|
|
|
test('isRootUser', () => {
|
|
expect(isRootUser(null)).toBe(false);
|
|
expect(isRootUser(1001)).toBe(false);
|
|
expect(isRootUser(0)).toBe(true);
|
|
});
|
|
|
|
test('isFakeRoot', () => {
|
|
const hasFakerootPreviously = 'FAKEROOTKEY' in process.env;
|
|
const oldValue = process.env.FAKEROOTKEY;
|
|
delete process.env.FAKEROOTKEY;
|
|
|
|
expect(isFakeRoot()).toBe(false);
|
|
|
|
process.env.FAKEROOTKEY = '15574641';
|
|
expect(isFakeRoot()).toBe(true);
|
|
|
|
if (hasFakerootPreviously) {
|
|
process.env.FAKEROOTKEY = oldValue;
|
|
}
|
|
});
|