mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-25 19:49:33 +01:00
cya snapshot
This commit is contained in:
parent
1c2f59fb67
commit
22c0aea623
2 changed files with 28 additions and 37 deletions
|
@ -1,31 +0,0 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`authutil tests Appends trailing slash to registry 1`] = `
|
|
||||||
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
|
|
||||||
registry=https://registry.npmjs.org/
|
|
||||||
always-auth=false"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`authutil tests Automatically configures GPR scope 1`] = `
|
|
||||||
"npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}
|
|
||||||
@ownername:registry=npm.pkg.github.com/
|
|
||||||
always-auth=false"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`authutil tests Configures scoped npm registries 1`] = `
|
|
||||||
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
|
|
||||||
@myscope:registry=https://registry.npmjs.org/
|
|
||||||
always-auth=false"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`authutil tests Sets up npmrc for always-auth true 1`] = `
|
|
||||||
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
|
|
||||||
registry=https://registry.npmjs.org/
|
|
||||||
always-auth=true"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`authutil tests Sets up npmrc for npmjs 1`] = `
|
|
||||||
"//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}
|
|
||||||
registry=https://registry.npmjs.org/
|
|
||||||
always-auth=false"
|
|
||||||
`;
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os = require('os');
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
@ -62,20 +63,35 @@ describe('authutil tests', () => {
|
||||||
}
|
}
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
|
function readRcFile(rcFile: string) {
|
||||||
|
let rc = {};
|
||||||
|
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
for (const line of contents.split(os.EOL)) {
|
||||||
|
let parts = line.split('=');
|
||||||
|
if (parts.length == 2) {
|
||||||
|
rc[parts[0].trim()] = parts[1].trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
it('Sets up npmrc for npmjs', async () => {
|
it('Sets up npmrc for npmjs', async () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/', 'false');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'false');
|
||||||
|
|
||||||
expect(fs.statSync(rcFile)).toBeDefined();
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
let contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
dbg(contents);
|
let rc = readRcFile(rcFile);
|
||||||
expect(contents).toMatchSnapshot();
|
expect(rc["registry"]).toBe("https://registry.npmjs.org/");
|
||||||
|
expect(rc["always-auth"]).toBe("false");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Appends trailing slash to registry', async () => {
|
it('Appends trailing slash to registry', async () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org', 'false');
|
await auth.configAuthentication('https://registry.npmjs.org', 'false');
|
||||||
|
|
||||||
expect(fs.statSync(rcFile)).toBeDefined();
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
|
let rc = readRcFile(rcFile);
|
||||||
|
expect(rc["registry"]).toBe("https://registry.npmjs.org/");
|
||||||
|
expect(rc["always-auth"]).toBe("false");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Configures scoped npm registries', async () => {
|
it('Configures scoped npm registries', async () => {
|
||||||
|
@ -83,19 +99,25 @@ describe('authutil tests', () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org', 'false');
|
await auth.configAuthentication('https://registry.npmjs.org', 'false');
|
||||||
|
|
||||||
expect(fs.statSync(rcFile)).toBeDefined();
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
|
let rc = readRcFile(rcFile);
|
||||||
|
expect(rc["@myscope:registry"]).toBe("https://registry.npmjs.org/");
|
||||||
|
expect(rc["always-auth"]).toBe("false");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Automatically configures GPR scope', async () => {
|
it('Automatically configures GPR scope', async () => {
|
||||||
await auth.configAuthentication('npm.pkg.github.com', 'false');
|
await auth.configAuthentication('npm.pkg.github.com', 'false');
|
||||||
|
|
||||||
expect(fs.statSync(rcFile)).toBeDefined();
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
|
let rc = readRcFile(rcFile);
|
||||||
|
expect(rc["@ownername:registry"]).toBe("npm.pkg.github.com/");
|
||||||
|
expect(rc["always-auth"]).toBe("false");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sets up npmrc for always-auth true', async () => {
|
it('Sets up npmrc for always-auth true', async () => {
|
||||||
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
|
||||||
expect(fs.statSync(rcFile)).toBeDefined();
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
expect(fs.readFileSync(rcFile, {encoding: 'utf8'})).toMatchSnapshot();
|
let rc = readRcFile(rcFile);
|
||||||
|
expect(rc["registry"]).toBe("https://registry.npmjs.org/");
|
||||||
|
expect(rc["always-auth"]).toBe("true");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue