Skip to content
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

fix: Fixed errors in consumer.cpp #2

Merged
merged 1 commit into from Jul 10, 2021

Conversation

Talank
Copy link
Contributor

@Talank Talank commented Jul 9, 2021

Description

We can not compile the consumer.cpp mainly because of two errors:

  1. too few arguments to function ‘int32_t pact_mock_server_ffi::write_pact_file(int32_t, const char*, bool)’
  2. 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);

In this PR, I have set the overwrite to false.

Resolving error 2

The error is as follows:

error: invalid conversion from ‘char*’ to ‘const uint8_t*’ {aka ‘const unsigned char*’} [-fpermissive]
  153 |         buffer.data(), size);
      |         ~~~~~~~~~~~^~
      |                    |
      |                    char*

This error arrise because the declaration of the with_binary_file() method in the pact_mock_server_ffi_h is as follows:

bool with_binary_file(InteractionHandle interaction,
                      InteractionPart part,
                      const char *content_type,
                      const uint8_t *body,
                      size_t size);

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

@individual-it
Copy link

@Talank you have to change the commit message and the PR header to something like: fix: .... to pass the semantic PR check

@Talank Talank changed the title Fixed errors in consumer.cpp fix: Fixed errors in consumer.cpp Jul 9, 2021
@uglyog uglyog merged commit 0760ec2 into pact-foundation:master Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants