Siyuan shen
06/03/2023, 10:39 AMMatt (pactflow.io / pact-js / pact-go)
Siyuan shen
06/04/2023, 3:04 AMimport { LogLevel, Verifier } from '@pact-foundation/pact';
import * as getParent from './get-parent';
import sinon from 'sinon';
let sandbox: any;
const LOG_LEVEL = process.env.LOG_LEVEL || 'DEBUG';
const mockId = {
queryStringParameters: {
organisationId: '12345abcde',
},
};
describe('send organisation parent provider test', () => {
before(() => {
sandbox = sinon.createSandbox();
});
afterEach(() => {
sandbox.restore();
});
it('send organisation parent id', () => {
return new Verifier({
provider: 'getOrganisationParentProvider',
logLevel: LOG_LEVEL as LogLevel,
providerBaseUrl: '<http://localhost:8081>',
stateHandlers: {
'has the organisation id 12345abcde': () => {
const stubResponse = {
Items: [
{
id: '12345abcde',
name: 'Test Organisation',
parentId: 'TestParentId',
},
],
};
// Stub the send function of DynamoDBDocumentClient
const stub = sandbox.stub(getParent, 'send');
stub.returns({ promise: () => Promise.resolve(stubResponse) });
return Promise.resolve({
description: `state set get the organisation parent id`,
});
},
},
providerVersion: 'organisation-parent-id-1.0',
pactBrokerUsername: 'tap-pact-broker',
pactBrokerPassword: 'JGNqcsd3x2JESU1LHFSw',
pactBrokerUrl: '<https://pact-broker/>',
consumerVersionSelectors: [
{
matchingBranch: true,
},
],
publishVerificationResult: true,
enablePending: true,
})
.verifyProvider()
.then((output) => {
console.log('Pact Verification Complete!');
console.log(output);
});
});Siyuan shen
06/04/2023, 3:05 AMSiyuan shen
06/04/2023, 3:06 AMconst p = new MessageProviderPact({
messageProviders: {
'a organisation parent id': providerWithMetadata(
() => getParent(mockId),
{
'content-type': 'application/json',
}
),
},
stateHandlers: {
'has the organisation id 12345abcde': () => {
const stubResponse = {
Items: [
{
id: '12345abcde',
name: 'Test Organisation',
parentId: 'TestParentId',
},
],
};
// Stub the send function of DynamoDBDocumentClient
const stub = sandbox.stub(DynamoDBDocumentClient.prototype, 'send');
stub.returns({ promise: () => Promise.resolve(stubResponse) });
return Promise.resolve(`state set get the organisation parent id`);
},
},
logLevel: LOG_LEVEL as LogLevel,
provider: 'getOrganisationParentProvider',
providerVersion: 'organisation-parent-id-1.0',
pactBrokerUsername: 'tap-pact-broker',
pactBrokerPassword: 'JGNqcsd3x2JESU1LHFSw',
pactBrokerUrl: '<https://pact-broker/>',
consumerVersionSelectors: [
{
matchingBranch: true,
},
],
});
describe('send organisation parent id', () => {
it('sends valid organisation parent id', () => {
return p.verify();
});
});Siyuan shen
06/04/2023, 3:08 AMSiyuan shen
06/04/2023, 4:20 AM14:18:04.651] INFO (36059): pact@11.0.2: Verifying provider
[14:18:04.665] INFO (36059): pact-core@13.13.8: Verifying Pacts.
[14:18:04.666] INFO (36059): pact-core@13.13.8: Verifying Pact Files
[14:18:04.667] DEBUG (36059): pact-core@13.13.8: Initalising native core at log level 'DEBUG'
2023-06-04T04:18:04.672803Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_new_for_application FFI function invoked
2023-06-04T04:18:04.676468Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_provider_info FFI function invoked
[14:18:04.677] DEBUG (36059): pact-core@13.13.8: the optional ffi function 'pactffiVerifierSetFilterInfo' was not executed as it had non-fatal validation errors: None of PACT_DESCRIPTION, PACT_PROVIDER_STATE or PACT_PROVIDER_NO_STATE were set in the environment
2023-06-04T04:18:04.677706Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_provider_state FFI function invoked
2023-06-04T04:18:04.677868Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_verification_options FFI function invoked
2023-06-04T04:18:04.678127Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_set_publish_options FFI function invoked
[14:18:04.678] DEBUG (36059): pact-core@13.13.8: the optional ffi function 'pactffiVerifierSetConsumerFilters' was not executed as it had non-fatal validation errors: Either no consumerFilters option provided, or the array was empty
[14:18:04.678] DEBUG (36059): pact-core@13.13.8: the optional ffi function 'pactffiVerifierSetFailIfNoPactsFound' was not executed as it had non-fatal validation errors: No failIfNoPactsFound option provided
[14:18:04.678] DEBUG (36059): pact-core@13.13.8: the optional ffi function 'pactffiVerifierAddCustomHeader' was not executed as it had non-fatal validation errors: No customProviderHeaders option provided
[14:18:04.678] DEBUG (36059): pact-core@13.13.8: the optional ffi function 'pactffiVerifierAddDirectorySource' was not executed as it had non-fatal validation errors: No pactUrls option provided
2023-06-04T04:18:04.679144Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_broker_source_with_selectors FFI function invoked
[14:18:04.680] DEBUG (36059): pact-core@13.13.8: the optional ffi function 'pactffiVerifierAddProviderTransport' was not executed as it had non-fatal validation errors: No additional provider transports providedSiyuan shen
06/04/2023, 4:21 AMMatt (pactflow.io / pact-js / pact-go)
ERROR is for)Matt (pactflow.io / pact-js / pact-go)