Skip to content

Commit

Permalink
Fix the broken master by the upgrade of GTest (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
BewareMyPower authored Dec 1, 2022
1 parent 88d1f20 commit 91a97eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

unit-tests:
name: Run unit tests
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 120

steps:
Expand Down
14 changes: 9 additions & 5 deletions tests/KeyValueSchemaTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ using namespace pulsar;

static const std::string lookupUrl = "pulsar://localhost:6650";

class KeyValueSchemaTest : public ::testing::TestWithParam<KeyValueEncodingType> {
// NOTE: Here we use int instead of KeyValueEncodingType because of a bug of GTest with GCC 11, see
// https://github.com/google/googletest/issues/4079
class KeyValueSchemaTest : public ::testing::TestWithParam<int> {
public:
void TearDown() override { client.close(); }

KeyValueEncodingType getEncodingType() const { return static_cast<KeyValueEncodingType>(GetParam()); }

void createProducer(const std::string& topic, Producer& producer) {
ProducerConfiguration configProducer;
configProducer.setSchema(getKeyValueSchema());
Expand All @@ -45,7 +49,7 @@ class KeyValueSchemaTest : public ::testing::TestWithParam<KeyValueEncodingType>
SchemaInfo getKeyValueSchema() {
SchemaInfo keySchema(JSON, "key-json", jsonSchema);
SchemaInfo valueSchema(JSON, "value-json", jsonSchema);
return SchemaInfo(keySchema, valueSchema, GetParam());
return SchemaInfo(keySchema, valueSchema, getEncodingType());
}

private:
Expand All @@ -55,7 +59,7 @@ class KeyValueSchemaTest : public ::testing::TestWithParam<KeyValueEncodingType>
};

TEST_P(KeyValueSchemaTest, testKeyValueSchema) {
auto encodingType = GetParam();
auto encodingType = getEncodingType();
const std::string topicName =
"testKeyValueSchema-" + std::string(strEncodingType(encodingType)) + std::to_string(time(nullptr));

Expand Down Expand Up @@ -85,5 +89,5 @@ TEST_P(KeyValueSchemaTest, testKeyValueSchema) {
ASSERT_EQ(keyValueData.getValueAsString(), valueData);
}

INSTANTIATE_TEST_CASE_P(Pulsar, KeyValueSchemaTest,
::testing::Values(KeyValueEncodingType::INLINE, KeyValueEncodingType::SEPARATED));
INSTANTIATE_TEST_SUITE_P(Pulsar, KeyValueSchemaTest,
::testing::Values(KeyValueEncodingType::INLINE, KeyValueEncodingType::SEPARATED));

0 comments on commit 91a97eb

Please sign in to comment.