Fix test broken by changes to gpr case

This commit is contained in:
Zachary Eisinger 2019-11-26 15:08:48 -08:00
parent 09cc69fecb
commit dd19a56732
2 changed files with 29 additions and 11 deletions

View File

@ -115,7 +115,7 @@ exports[`authutil tests Existing config w/ two GPR sources, sets up a partial Nu
"<?xml version=\\"1.0\\"?> "<?xml version=\\"1.0\\"?>
<configuration> <configuration>
<config> <config>
<add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com/OwnerName/index.json\\"/> <add key=\\"defaultPushSource\\" value=\\"https://nuget.pkg.github.com\\"/>
</config> </config>
<packageSourceCredentials> <packageSourceCredentials>
<GPR-GitHub> <GPR-GitHub>

View File

@ -44,7 +44,7 @@ const gprNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
const twogprNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?> const twogprNuGetConfig: string = `<?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<packageSources> <packageSources>
<add key="GPR-GitHub" value="https://nuget.pkg.github.com/github/index.json" protocolVersion="3" /> <add key="GPR-GitHub" value="https://nuget.pkg.github.com/OwnerName/index.json" protocolVersion="3" />
<add key="GPR-Actions" value="https://nuget.pkg.github.com/actions/index.json" protocolVersion="3" /> <add key="GPR-Actions" value="https://nuget.pkg.github.com/actions/index.json" protocolVersion="3" />
</packageSources> </packageSources>
</configuration>`; </configuration>`;
@ -94,7 +94,9 @@ describe('authutil tests', () => {
it('No existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => { it('No existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
expect(fs.existsSync(nugetConfigFile)).toBe(true); expect(fs.existsSync(nugetConfigFile)).toBe(true);
expect( expect(
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'}) fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
@ -104,7 +106,9 @@ describe('authutil tests', () => {
it('No existing config, auth token environment variable not provided, throws', async () => { it('No existing config, auth token environment variable not provided, throws', async () => {
let thrown = false; let thrown = false;
try { try {
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
} catch { } catch {
thrown = true; thrown = true;
} }
@ -114,7 +118,9 @@ describe('authutil tests', () => {
it('No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => { it('No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => {
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN'; process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
process.env['INPUT_OWNER'] = 'otherorg'; process.env['INPUT_OWNER'] = 'otherorg';
await auth.configAuthentication('https://nuget.pkg.github.com/otherorg/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/otherorg/index.json'
);
expect(fs.existsSync(nugetConfigFile)).toBe(true); expect(fs.existsSync(nugetConfigFile)).toBe(true);
expect( expect(
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'}) fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
@ -130,7 +136,9 @@ describe('authutil tests', () => {
fs.writeFileSync(inputNuGetConfigPath, invalidNuGetConfig); fs.writeFileSync(inputNuGetConfigPath, invalidNuGetConfig);
let thrown = false; let thrown = false;
try { try {
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
} catch { } catch {
thrown = true; thrown = true;
} }
@ -144,7 +152,9 @@ describe('authutil tests', () => {
'nuget.config' 'nuget.config'
); );
fs.writeFileSync(inputNuGetConfigPath, emptyNuGetConfig); fs.writeFileSync(inputNuGetConfigPath, emptyNuGetConfig);
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
expect(fs.existsSync(nugetConfigFile)).toBe(true); expect(fs.existsSync(nugetConfigFile)).toBe(true);
expect( expect(
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'}) fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
@ -158,7 +168,9 @@ describe('authutil tests', () => {
'nuget.config' 'nuget.config'
); );
fs.writeFileSync(inputNuGetConfigPath, nugetorgNuGetConfig); fs.writeFileSync(inputNuGetConfigPath, nugetorgNuGetConfig);
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
expect(fs.existsSync(nugetConfigFile)).toBe(true); expect(fs.existsSync(nugetConfigFile)).toBe(true);
expect( expect(
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'}) fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
@ -172,7 +184,9 @@ describe('authutil tests', () => {
'nuget.config' 'nuget.config'
); );
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig); fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
expect(fs.existsSync(nugetConfigFile)).toBe(true); expect(fs.existsSync(nugetConfigFile)).toBe(true);
expect( expect(
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'}) fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
@ -186,7 +200,9 @@ describe('authutil tests', () => {
'nuget.config' 'nuget.config'
); );
fs.writeFileSync(inputNuGetConfigPath, gprnugetorgNuGetConfig); fs.writeFileSync(inputNuGetConfigPath, gprnugetorgNuGetConfig);
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
expect(fs.existsSync(nugetConfigFile)).toBe(true); expect(fs.existsSync(nugetConfigFile)).toBe(true);
expect( expect(
fs.readFileSync(nugetConfigFile, {encoding: 'utf8'}) fs.readFileSync(nugetConfigFile, {encoding: 'utf8'})
@ -216,7 +232,9 @@ describe('authutil tests', () => {
fs.writeFileSync(inputNuGetConfigPath, spaceNuGetConfig); fs.writeFileSync(inputNuGetConfigPath, spaceNuGetConfig);
let thrown = false; let thrown = false;
try { try {
await auth.configAuthentication('https://nuget.pkg.github.com/OwnerName/index.json'); await auth.configAuthentication(
'https://nuget.pkg.github.com/OwnerName/index.json'
);
} catch { } catch {
thrown = true; thrown = true;
} }