Pass SonarState into SonarWebSocketImpl
Summary: Allowing the connection code to update trigger diagnostic events Reviewed By: danielbuechele Differential Revision: D9150554 fbshipit-source-id: 5fe0a08edc2f3b0ccae43b4dc2c7b087c6404c58
This commit is contained in:
committed by
Facebook Github Bot
parent
531a47535b
commit
55ca14ee41
@@ -19,6 +19,8 @@ namespace test {
|
||||
|
||||
using folly::dynamic;
|
||||
|
||||
auto state = std::make_shared<SonarState>();
|
||||
|
||||
TEST(SonarClientTests, testSaneMocks) {
|
||||
SonarWebSocketMock socket;
|
||||
socket.start();
|
||||
@@ -32,7 +34,7 @@ TEST(SonarClientTests, testSaneMocks) {
|
||||
|
||||
TEST(SonarClientTests, testGetPlugins) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
client.start();
|
||||
|
||||
client.addPlugin(std::make_shared<SonarPluginMock>("Cat"));
|
||||
@@ -48,7 +50,7 @@ TEST(SonarClientTests, testGetPlugins) {
|
||||
|
||||
TEST(SonarClientTests, testGetPlugin) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
const auto catPlugin = std::make_shared<SonarPluginMock>("Cat");
|
||||
client.addPlugin(catPlugin);
|
||||
@@ -61,7 +63,7 @@ TEST(SonarClientTests, testGetPlugin) {
|
||||
|
||||
TEST(SonarClientTests, testGetPluginWithDowncast) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
const auto catPlugin = std::make_shared<SonarPluginMock>("Cat");
|
||||
client.addPlugin(catPlugin);
|
||||
@@ -70,7 +72,7 @@ TEST(SonarClientTests, testGetPluginWithDowncast) {
|
||||
|
||||
TEST(SonarClientTests, testRemovePlugin) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
client.start();
|
||||
|
||||
auto plugin = std::make_shared<SonarPluginMock>("Test");
|
||||
@@ -87,7 +89,7 @@ TEST(SonarClientTests, testRemovePlugin) {
|
||||
|
||||
TEST(SonarClientTests, testStartStop) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
client.start();
|
||||
EXPECT_TRUE(socket->isOpen());
|
||||
@@ -98,7 +100,7 @@ TEST(SonarClientTests, testStartStop) {
|
||||
|
||||
TEST(SonarClientTests, testConnectDisconnect) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
bool pluginConnected = false;
|
||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||
@@ -121,7 +123,7 @@ TEST(SonarClientTests, testConnectDisconnect) {
|
||||
|
||||
TEST(SonarClientTests, testInitDeinit) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
bool pluginConnected = false;
|
||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||
@@ -159,7 +161,7 @@ TEST(SonarClientTests, testInitDeinit) {
|
||||
|
||||
TEST(SonarClientTests, testRemovePluginWhenConnected) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
bool pluginConnected = false;
|
||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||
@@ -180,7 +182,7 @@ TEST(SonarClientTests, testRemovePluginWhenConnected) {
|
||||
|
||||
TEST(SonarClientTests, testUnhandleableMethod) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
auto plugin = std::make_shared<SonarPluginMock>("Test");
|
||||
client.addPlugin(plugin);
|
||||
@@ -200,7 +202,7 @@ TEST(SonarClientTests, testUnhandleableMethod) {
|
||||
|
||||
TEST(SonarClientTests, testExecute) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
client.start();
|
||||
|
||||
const auto connectionCallback = [](std::shared_ptr<SonarConnection> conn) {
|
||||
@@ -230,7 +232,7 @@ TEST(SonarClientTests, testExecute) {
|
||||
|
||||
TEST(SonarClientTests, testExecuteWithParams) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
|
||||
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
|
||||
const auto receiver = [](const dynamic ¶ms,
|
||||
@@ -263,7 +265,7 @@ TEST(SonarClientTests, testExecuteWithParams) {
|
||||
|
||||
TEST(SonarClientTests, testExceptionUnknownPlugin) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
client.start();
|
||||
|
||||
dynamic messageInit = dynamic::object("method", "init")(
|
||||
@@ -276,7 +278,7 @@ TEST(SonarClientTests, testExceptionUnknownPlugin) {
|
||||
|
||||
TEST(SonarClientTests, testExceptionUnknownApi) {
|
||||
auto socket = new SonarWebSocketMock;
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket});
|
||||
SonarClient client(std::unique_ptr<SonarWebSocketMock>{socket}, state);
|
||||
client.start();
|
||||
|
||||
dynamic messageInit = dynamic::object("method", "execute")(
|
||||
|
||||
Reference in New Issue
Block a user