feat: add CMake build configuration and unit tests for XRabbitMQClient
This commit is contained in:
26
test/test_rabbitmq_client.cpp
Normal file
26
test/test_rabbitmq_client.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "RabbitMQClient.h"
|
||||
|
||||
// Note: A real RabbitMQ broker is needed to fully test this wrapper.
|
||||
// Since we might not have a broker running locally on the build server,
|
||||
// these tests will check for proper failure handling or basic instantiations.
|
||||
// For full integration tests, a mocked simpleamqpclient or a local broker is required.
|
||||
|
||||
TEST(RabbitMQClientTest, InvalidCredentialsFail) {
|
||||
RabbitMQClient client("localhost", 5672, "invalid_user", "invalid_password");
|
||||
// Connect should fail with incorrect credentials or no server
|
||||
EXPECT_FALSE(client.Connect());
|
||||
}
|
||||
|
||||
TEST(RabbitMQClientTest, DisconnectedPublish) {
|
||||
RabbitMQClient client("localhost", 5672, "guest", "guest");
|
||||
// Without a successful connection, publish must fail
|
||||
EXPECT_FALSE(client.Publish("test_queue", "Hello World"));
|
||||
}
|
||||
|
||||
TEST(RabbitMQClientTest, DisconnectedConsume) {
|
||||
RabbitMQClient client("localhost", 5672, "guest", "guest");
|
||||
// Consume without connection should probably throw or return empty
|
||||
std::string msg = client.Consume("test_queue");
|
||||
EXPECT_TRUE(msg.empty());
|
||||
}
|
||||
Reference in New Issue
Block a user