Files
yarn/__tests__/util/root-user.js
Martin 78a5f3379f Chore: Add test for isFakeRoot (#4435)
**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
2017-09-13 22:16:34 +01:00

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;
}
});