diff --git a/__tests__/util/root-user.js b/__tests__/util/root-user.js index 4e214261bc..e06a4d2140 100644 --- a/__tests__/util/root-user.js +++ b/__tests__/util/root-user.js @@ -1,9 +1,24 @@ /* @flow */ -import {isRootUser} from '../../src/util/root-user.js'; +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; + } +});