<#289 publish with multiple Consumers appends Tags...
# pact-js-development
g
#289 publish with multiple Consumers appends Tags to last Consumer's pacts only Issue created by FilipSwiatczak Software versions • OS: Windows 10 Pro, v1803, build: 17134.590 • Consumer Pact library: "@pact-foundation/pact": "^8.0.5", • Node Version: 8.12.0 • DiUS pact broker docker: 2.29.0-1 Expected behaviour When publishing an array of Pacts given set of tags is expected to be appended to all pact files Actual behaviour Only last item in the Pacts array gets the Tags. Result? Without tags attached, running tagged test against provider is not possible. Steps to reproduce Here is my publish.js file. Please note the readdirSync which populates array from local pacts dir with absolute paths, since you don't support wildcards (desirable improvement). In log snippet in log files you can see the three pact files expected to be appended with "prod" and "test" tags. publish.js:
Copy code
const pact = require("@pact-foundation/pact-node")
const path = require("path")
const data = require("../data/pactConfig.json")
const fs = require("fs")
const pactPath = path.join(__dirname, '../pacts');
const pacts = [];
fs.readdirSync(pactPath).forEach(file => {
  pacts.push(path.join(pactPath, file));
});
console.log(pacts);
const opts = Object.assign(data, {
  pactFilesOrDirs: pacts,
  tags: ["prod", "test"],
  consumerVersion:
    "1.0." +
    (process.env.TRAVIS_BUILD_NUMBER
      ? process.env.TRAVIS_BUILD_NUMBER
      : Math.floor(new Date() / 1000)),
});

pact
  .publishPacts(opts)
  .then(() => {
    console.log("Pact contract publishing complete!")
    console.log("")
    console.log("Head over to " + data.pactBrokerUrl + " and login with")
    console.log("=> Username: " + data.pactBrokerUsername)
    console.log("=> Password: " + data.pactBrokerPassword)
    console.log("to see your published contracts.")
  })
  .catch(e => {
    console.log("Pact contract publishing failed: ", e)
  })
Relevant log files Please note that only "Half consumer" is tagged, "Double" and "Greeting" are missed. There is a workaround of running this several times for each file but this is so basic I believe it should work out of the box, unless I'm missing something obvious.
Copy code
> node utility/publish.js

[ 'C:\\p\\pacts\\double_consumer-multi_provider.json',
  'C:\\p\\pacts\\greeting_consumer-multi_provider.json',
  'C:\\p\\pacts\\half_consumer-multi_provider.json' ]
[2019-03-29T10:49:21.860Z]  INFO: pact-node@6.21.4/13884 on UKMANLT-0007136: Publishing Pacts to Broker
[2019-03-29T10:49:21.863Z]  INFO: pact-node@6.21.4/13884 on UKMANLT-0007136: Publishing pacts to broker at: <http://XXXXXX>:
8008/
[2019-03-29T10:49:21.872Z]  INFO: pact-node@6.21.4/13884 on UKMANLT-0007136: Created 'standalone\win32-1.63.0\bin\pact-broker.bat
publish 'C:\p\pacts\half_consumer-multi_provider.json' 'C:\p\pacts\greeting_consumer-multi_provider.json' 'C:\p\pacts\double_consu
mer-multi_provider.json' --broker-base-url '<http://XXXXXXX:8008/>' --broker-username 'pactbroker' --broker-password 'Passwor
d10' --tag 'prod' --tag 'test' --consumer-app-version '1.0.1553856561'' process with PID: 10040
[2019-03-29T10:49:23.915Z]  INFO: pact-node@6.21.4/13884 on UKMANLT-0007136:
    
    Tagging version 1.0.1553856561 of Half consumer as "prod"
    Tagging version 1.0.1553856561 of Half consumer as "test"
    Publishing Half consumer/Multi Provider pact to pact broker at <http://XXXXXX:8008/>
    The latest version of this pact can be accessed at the following URL (use this to configure the provider verification):
    <http://XXXXXX:8008/pacts/provider/Multi%20Provider/consumer/Half%20consumer/latest>
    Publishing Greeting consumer/Multi Provider pact to pact broker at <http://XXXXXX:8008/>
    The latest version of this pact can be accessed at the following URL (use this to configure the provider verification):
    <http://XXXXXX:8008/pacts/provider/Multi%20Provider/consumer/Greeting%20consumer/latest>
    Publishing Double consumer/Multi Provider pact to pact broker at <http://XXXXXX:8008/>
    The latest version of this pact can be accessed at the following URL (use this to configure the provider verification):
    <http://XXXXX:8008/pacts/provider/Multi%20Provider/consumer/Double%20consumer/latest>


Pact contract publishing complete!

Head over to <http://XXXXX:8008/> and login with
=> Username: pactbroker
=> Password: Password10
to see your published contracts.
Debug log file is perfectly clean, so a non-factor: mockserver-integration.log pact-foundation/pact-js