Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for isFakeRoot #4435

Merged
merged 2 commits into from
Sep 13, 2017
Merged

Add test for isFakeRoot #4435

merged 2 commits into from
Sep 13, 2017

Conversation

martinstuecklschwaiger
Copy link
Contributor

This adds a test for isFakeRoot() as proposed by @BYK in #4431.

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the quick follow up!


test('isRootUser', () => {
expect(isRootUser(null)).toBe(false);
expect(isRootUser(1001)).toBe(false);
expect(isRootUser(0)).toBe(true);
});

test('isFakeRoot', () => {
delete process.env.FAKEROOTKEY;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should explicitly set this to '' or something since deleting would just restore it to the default value if the system running this. So if the tests were run with fakreoot then deleting that env variable would just reset it to the system value.

Makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out, and delete process.env.FAKEROOTKEY removes the key from the object.
Running the tests with fakeroot actually works.

Copy link
Member

@BYK BYK Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. I've tested locally to see the same result. That said be advised that deleting it like this actually removes any existing value without any way for restoring it so your test is actually affecting the global state permanently.

Are you sure you want to do that?

@buildsize
Copy link

buildsize bot commented Sep 13, 2017

This change will increase the build size from 9.52 MB to 9.52 MB, an increase of 1.07 KB (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 819.76 KB 819.88 KB 128 bytes (0%)
yarn-[version].js 3.62 MB 3.62 MB 363 bytes (0%)
yarn-legacy-[version].js 3.67 MB 3.67 MB 444 bytes (0%)
yarn-v[version].tar.gz 823.92 KB 824.04 KB 125 bytes (0%)
yarn_[version]all.deb 626.71 KB 626.74 KB 38 bytes (0%)

1 similar comment
@buildsize
Copy link

buildsize bot commented Sep 13, 2017

This change will increase the build size from 9.52 MB to 9.52 MB, an increase of 1.07 KB (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 819.76 KB 819.88 KB 128 bytes (0%)
yarn-[version].js 3.62 MB 3.62 MB 363 bytes (0%)
yarn-legacy-[version].js 3.67 MB 3.67 MB 444 bytes (0%)
yarn-v[version].tar.gz 823.92 KB 824.04 KB 125 bytes (0%)
yarn_[version]all.deb 626.71 KB 626.74 KB 38 bytes (0%)

@BYK BYK merged commit 78a5f33 into yarnpkg:master Sep 13, 2017
joaolucasl pushed a commit to joaolucasl/yarn that referenced this pull request Oct 27, 2017
**Summary**

Follow up to yarnpkg#4431. `isFakeRoot` didn't have any tests and it was broken from the start. yarnpkg#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants