11import chai = require( 'chai' ) ;
2+ import path = require( 'path' ) ;
23import chaiAsPromised = require( 'chai-as-promised' ) ;
34import * as rimraf from 'rimraf' ;
45import zlib = require( 'zlib' ) ;
@@ -16,26 +17,26 @@ const isOSX = process.platform === 'darwin';
1617const isCI = process . env . CI === 'true' ;
1718
1819describe ( 'FFI integration test for the Message Consumer API' , ( ) => {
19- setLogLevel ( 'trace ' ) ;
20+ setLogLevel ( 'error ' ) ;
2021
2122 let pact : ConsumerMessagePact ;
2223 const secret = 'this is an encoded string' ;
2324 const bytes : Buffer = zlib . gzipSync ( secret ) ;
2425
26+ before ( ( ) => {
27+ rimraf . sync ( path . join ( __dirname , '__testoutput__' , 'message-consumer*' ) )
28+ } ) ;
29+
2530 beforeEach ( ( ) => {
26- rimraf . sync ( '/tmp/pact/*.json' ) ;
31+ pact = makeConsumerMessagePact (
32+ 'message-consumer' ,
33+ 'message-provider' ,
34+ FfiSpecificationVersion . SPECIFICATION_VERSION_V4
35+ ) ;
2736 } ) ;
2837
2938 describe ( 'Asynchronous Messages' , ( ) => {
3039 describe ( 'with JSON data' , ( ) => {
31- beforeEach ( ( ) => {
32- pact = makeConsumerMessagePact (
33- 'message-consumer' ,
34- 'message-provider' ,
35- FfiSpecificationVersion . SPECIFICATION_VERSION_V3
36- ) ;
37- } ) ;
38-
3940 it ( 'generates a pact with success' , ( ) => {
4041 pact . addMetadata ( 'pact-node' , 'meta-key' , 'meta-val' ) ;
4142 const message = pact . newAsynchronousMessage ( '' ) ;
@@ -50,9 +51,9 @@ describe('FFI integration test for the Message Consumer API', () => {
5051
5152 const reified = message . reifyMessage ( ) ;
5253
53- expect ( JSON . parse ( reified ) . contents ) . to . have . property ( 'foo' , 'bar' ) ;
54+ expect ( JSON . parse ( reified ) . contents . content ) . to . have . property ( 'foo' , 'bar' ) ;
5455
55- pact . writePactFile ( '/tmp/pact' ) ;
56+ pact . writePactFile ( path . join ( __dirname , '__testoutput__' ) ) ;
5657 } ) ;
5758 } ) ;
5859
@@ -79,22 +80,16 @@ describe('FFI integration test for the Message Consumer API', () => {
7980 const contents = JSON . parse ( reified ) . contents ;
8081
8182 // Check the base64 encoded contents can be decoded, unzipped and equals the secret
82- const buf = Buffer . from ( contents , 'base64' ) ;
83+ const buf = Buffer . from ( contents . content , 'base64' ) ;
8384 const deflated = zlib . gunzipSync ( buf ) . toString ( 'utf8' ) ;
8485 expect ( deflated ) . to . equal ( secret ) ;
8586
86- pact . writePactFile ( '/tmp/pact' ) ;
87+ pact . writePactFile ( path . join ( __dirname , '__testoutput__' ) ) ;
8788 } ) ;
8889 } ) ;
8990 } ) ;
91+
9092 describe ( 'Synchronous Messages' , ( ) => {
91- beforeEach ( ( ) => {
92- pact = makeConsumerMessagePact (
93- 'message-consumer' ,
94- 'message-provider' ,
95- FfiSpecificationVersion . SPECIFICATION_VERSION_V4
96- ) ;
97- } ) ;
9893 describe ( 'with JSON data' , ( ) => {
9994 it ( 'generates a pact with success' , ( ) => {
10095 pact . addMetadata ( 'pact-node' , 'meta-key' , 'meta-val' ) ;
@@ -115,7 +110,7 @@ describe('FFI integration test for the Message Consumer API', () => {
115110
116111 // expect(JSON.parse(reified).contents).to.have.property('foo', 'bar');
117112
118- pact . writePactFile ( '/tmp/pact' ) ;
113+ pact . writePactFile ( path . join ( __dirname , '__testoutput__' ) ) ;
119114 } ) ;
120115 } ) ;
121116
@@ -152,14 +147,13 @@ describe('FFI integration test for the Message Consumer API', () => {
152147 pact . addMetadata ( 'pact-node' , 'meta-key' , 'meta-val' ) ;
153148 pact . addPlugin ( 'protobuf' , '0.1.14' ) ;
154149
155- const message = pact . newSynchronousMessage ( 'a grpc test' ) ;
156- message . given ( 'some state' ) ;
157- message . givenWithParam ( 'some state 2' , 'state2 key' , 'state2 val' ) ;
150+ const message = pact . newSynchronousMessage ( 'a grpc test 1' ) ;
151+ message . given ( 'some state 1' ) ;
158152 message . withPluginRequestResponseInteractionContents (
159153 'application/protobuf' ,
160154 grpcInteraction
161155 ) ;
162- message . withMetadata ( 'meta-key' , 'meta-val' ) ;
156+ message . withMetadata ( 'meta-key 1 ' , 'meta-val 2 ' ) ;
163157
164158 port = pact . pactffiCreateMockServerForTransport (
165159 '127.0.0.1' ,
@@ -178,7 +172,7 @@ describe('FFI integration test for the Message Consumer API', () => {
178172 const mismatches = pact . mockServerMismatches ( port ) ;
179173 expect ( mismatches . length ) . to . eq ( 0 ) ;
180174
181- pact . writePactFile ( '/tmp/pact' ) ;
175+ pact . writePactFile ( path . join ( __dirname , '__testoutput__' ) ) ;
182176 } ) ;
183177 } ) ;
184178 } ) ;
0 commit comments