Files
XRabbitMQClient/test/test_rabbitmq_client.cpp

27 lines
1.1 KiB
C++

#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());
}