Skip to content

Commit

Permalink
fix: map pactflow command to correct binary / add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 9, 2022
1 parent 405e9df commit 31f4df9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/pactflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import standalone from '../src/pact-standalone';
import childProcess = require('child_process');

const status = childProcess.spawnSync(
standalone.pactFullPath,
standalone.pactflowFullPath,
process.argv.slice(2),
{
stdio: 'inherit',
Expand Down
30 changes: 30 additions & 0 deletions src/pact-standalone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ describe('Pact Standalone', function () {
expect(pact.verifierFullPath).to.contain('pact-provider-verifier');
expect(pact.pactPath).to.contain('pact');
expect(pact.pactFullPath).to.contain('pact');
expect(pact.pactflowPath).to.contain('pactflow');
expect(pact.pactflowFullPath).to.contain('pactflow');
});

it("should return the base directory of the project with 'cwd' (where the package.json file is)", () => {
Expand Down Expand Up @@ -85,6 +87,14 @@ describe('Pact Standalone', function () {
it('pact full path', () => {
expect(fs.existsSync(pact.pactFullPath)).to.be.true;
});
it('pactflow relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactflowPath))).to.be
.true;
});

it('pactflow full path', () => {
expect(fs.existsSync(pact.pactflowFullPath)).to.be.true;
});
});

describe('Linux X64', () => {
Expand Down Expand Up @@ -134,6 +144,15 @@ describe('Pact Standalone', function () {
it('pact full path', () => {
expect(fs.existsSync(pact.pactFullPath)).to.be.true;
});

it('pactflow relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactflowPath))).to.be
.true;
});

it('pactflow full path', () => {
expect(fs.existsSync(pact.pactflowFullPath)).to.be.true;
});
});
}

Expand All @@ -151,6 +170,8 @@ describe('Pact Standalone', function () {
expect(pact.verifierFullPath).to.contain('pact-provider-verifier.bat');
expect(pact.pactPath).to.contain('pact.bat');
expect(pact.pactFullPath).to.contain('pact.bat');
expect(pact.pactflowPath).to.contain('pactflow.bat');
expect(pact.pactflowFullPath).to.contain('pactflow.bat');
});

it('broker relative path', () => {
Expand Down Expand Up @@ -195,6 +216,15 @@ describe('Pact Standalone', function () {
it('pact full path', () => {
expect(fs.existsSync(pact.pactFullPath)).to.be.true;
});

it('pactflow relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactflowPath))).to.be
.true;
});

it('pactflow full path', () => {
expect(fs.existsSync(pact.pactflowPath)).to.be.true;
});
});
});
});
7 changes: 7 additions & 0 deletions src/pact-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface PactStandalone {
messageFullPath: string;
pactPath: string;
pactFullPath: string;
pactflowPath: string;
pactflowFullPath: string;
}

export const standalone = (
Expand All @@ -32,6 +34,7 @@ export const standalone = (
const broker = binName('pact-broker');
const stub = binName('pact-stub-service');
const pact = binName('pact');
const pactflow = binName('pactflow');
const basePath = path.join(
'standalone',
getBinaryEntry(platform, arch).folderName,
Expand All @@ -55,6 +58,10 @@ export const standalone = (
stubFullPath: path.resolve(pactEnvironment.cwd, basePath, stub).trim(),
pactPath: path.join(basePath, pact),
pactFullPath: path.resolve(pactEnvironment.cwd, basePath, pact).trim(),
pactflowPath: path.join(basePath, pactflow),
pactflowFullPath: path
.resolve(pactEnvironment.cwd, basePath, pactflow)
.trim(),
verifierPath: path.join(basePath, verify),
verifierFullPath: path
.resolve(pactEnvironment.cwd, basePath, verify)
Expand Down

0 comments on commit 31f4df9

Please sign in to comment.