-
-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pact.js fails to merge interactions to one file #150
Comments
What happens when you specify the path to the pact dir with forward slashes? |
I tried "/pacts" which resulted in a correctly merged file, but the file get created in C:\pacts instead of the current working directory. Every other type of path fails, even when I replace \ with / using regex. |
What if the path is "./pacts"? |
There may be some JavaScript logic in there modifying the path before it is passed to ruby. |
As you rightly theorised... |
I will try "./pacts" as soon as I get to back to the Windows terminal in my office in the morning. Everything works fine on my Mac though. |
I've put out a new version of the standalone, with code to replace backslashes with forward slashes when constructing the pact path. @mefellows can you update to 1.29.1 of the standalone when you have a moment? |
@bethesque Thank you very much for your quick response! Btw: running the code with "./pacts" did'nt work. |
@dervism |
@mefellows I am retesting again. Will let you know. |
Bugger. If you were interested, there is a branch set aside to create an appveyor build for Pact. It needs some work but would very much appreciate any Windows testing. |
@mefellows I get permission denied (might be something on my side):
|
Thanks @dervism. Does |
@mefellows Yes the directory exist and the initial file is being created. Problem seems to happen every time the RubyGem tries to do a File.read - when that fails it overwrites the existing file with the last pact test that was ran. |
There is already an appveyor build to test the standalone package. We
shouldn't really need the js to reproduce this (unless it is an artifact
of something in the js). I'll modify the test to exercise the merge
feature.
|
The good news is, I've reproduced it! https://ci.appveyor.com/project/MichelBoudreau/pact-ruby-standalone-windows-test/build/1.0.95#L85 Now to see if we can fix it. |
I wish there was some way to not automatically close an issue when you referenced it with the "fix:" notation! Ok, I have a passing windows build with v 1.29.2 of the ruby standalone. Update at will. On a side note Matt, I worked out how to lock and write to the same file on Windows, so there's no OS specific code. For great victory! |
Amazing work Beth. I'll see to upgrading shortly... time to get on the module release merry-go-round :) |
Ok have released the latest, let us know how you go @dervism |
It works :-) Thank you so much for the great work! 👍 |
🎉
|
Beth 1, Windows... um... I've lost count. |
Software versions
Expected behaviour
Be able to merge interactions into one pact file.
Actual behaviour
Only one interaction (the last ran test) get written out. The existing pact file is overwritten when the "pactfileWriteMode: 'merge'" option is specified. The log from the mock integration server has the following line:
I, [2018-02-15T16:34:37.887577 #37412] INFO -- : Merging interactions into pact for MyProvider at C:\nav\pus\pact-js\examples\mocha\pacts/myconsumer-myprovider.json W, [2018-02-15T16:34:37.887577 #37412] WARN -- : Could not load existing consumer contract from C:\nav\pus\pact-js\examples\mocha\pacts/myconsumer-myprovider.json due to bad URI(is not URI?): C:\nav\pus\pact-js\examples\mocha\pacts/myconsumer-myprovider.json. Creating a new file.
Notice the forward slash: \mocha\pacts/myconsumer-myprovider.json
This error message is thrown in consumer_contract_writer.rb in Ruby-gem pact-mock_service-2.6.3, on line 92. The pactfile_path variable seems to be set wrong somewhere. Trying to manually replace the illegal back slashes didnt work either:
dir: path.resolve(process.cwd(), 'pacts').replace(/\\/g, "/")
. I find uses of path.normalize in pact-node/src/server.js which could be the reason why pact-mock_service get a filepath with Windows-style back slashes.Path to gem:
node_modules/@pact-foundation/pact-standalone/platforms/win32/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.3/lib/pact/consumer_contract
It's important to note that everything works fine on Mac OS and Linux. This problem occurs only on Windows.
Steps to reproduce
Run the mocha example on Windows. I have upgraded the example to PactJS version 5.3.0. Unzip and run the example to reproduce. The same log statement should then be in the mockserver-integration.log. I have ran and attached the same file here.
Relevant log files
The reproduced mockserver log:
mockserver-integration.log
The text was updated successfully, but these errors were encountered: