#include <array>
#include <gmock/gmock-matchers.h>
#include <consume.hpp>
#include <produce.hpp>
#include <userver/kafka/utest/kafka_fixture.hpp>
UTEST_F(KafkaServiceTest, Produce) {
auto producer = MakeProducer("kafka-producer");
EXPECT_EQ(
kafka_sample::Produce(producer, kafka_sample::RequestMessage{"test-topic", "test-key", "test-message"}),
kafka_sample::SendStatus::kSuccess
);
}
UTEST_F(KafkaServiceTest, Consume) {
const std::string kTestTopic1{"test-topic-1"};
const std::string kTestTopic2{"test-topic-2"};
const std::array kTestMessages{
kTestTopic1,
"test-key-1",
"test-msg-1",
0},
kTestTopic2,
"test-key-2",
"test-msg-2",
0}};
SendMessages(kTestMessages);
auto consumer = MakeConsumer("kafka-consumer", {kTestTopic1, kTestTopic2});
const auto received_messages = ReceiveMessages(consumer, kTestMessages.size(), std::move(user_callback));
ASSERT_EQ(received_messages.size(), kTestMessages.size());
EXPECT_THAT(received_messages, ::testing::UnorderedElementsAreArray(kTestMessages));
}