We can not compile the consumer.cpp mainly because of two errors:
too few arguments to function ‘int32_t pact_mock_server_ffi::write_pact_file(int32_t, const char*, bool)’
invalid conversion from ‘char’ to ‘const uint8_t’ while calling pact_mock_server_ffi::with_binary_file()
The first error can be resolved by including the third argument in the pact_mock_server_ffi::write_pact_file function call. And the second error can be resolved by casting the buffer.data() to const uint8_t* while calling the pact_mock_server_ffi::with_binary_file function from consumer.cpp
Resolving error 1
The error is as follows:
error: too few arguments to function ‘int32_t pact_mock_server_ffi::write_pact_file(int32_t, const char*, bool)’
48 | _pact_file(mockServer.get_port(), this->pact_directory.data());
Here the last boolean argument determines if the file should be overrite or not. The declaration in the pact_mock_server_ffi.h for this function is as follows:
int32_t write_pact_file(int32_t mock_server_port, const char *directory, bool overwrite);
And while passing the argument body, a char* data is passed. And the solution is parsing the argument to const uint8_t* while calling from consumer.cpp
Description
We can not compile the consumer.cpp mainly because of two errors:
pact_mock_server_ffi::with_binary_file()
The first error can be resolved by including the third argument in the
pact_mock_server_ffi::write_pact_file
function call. And the second error can be resolved by casting thebuffer.data()
toconst uint8_t*
while calling thepact_mock_server_ffi::with_binary_file
function fromconsumer.cpp
Resolving error 1
The error is as follows:
Here the last boolean argument determines if the file should be overrite or not. The declaration in the
pact_mock_server_ffi.h
for this function is as follows:int32_t write_pact_file(int32_t mock_server_port, const char *directory, bool overwrite);
In this PR, I have set the overwrite to false.
Resolving error 2
The error is as follows:
This error arrise because the declaration of the
with_binary_file()
method in thepact_mock_server_ffi_h
is as follows:And while passing the argument
body
, achar*
data is passed. And the solution is parsing the argument toconst uint8_t*
while calling fromconsumer.cpp