policy: Enhance testcase on bluetooth vtab
authorSangwan Kwon <sangwan.kwon@samsung.com>
Mon, 24 Feb 2020 09:14:53 +0000 (18:14 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Tue, 25 Feb 2020 05:08:55 +0000 (14:08 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
plugins/bluetooth/bluetooth-test.cpp
src/vist/client/schema/bluetooth.hpp

index c61ce4e..6a68d7b 100644 (file)
@@ -18,6 +18,7 @@
 #include "../test-util.hpp"
 
 #include <vist/client/query.hpp>
+#include <vist/client/schema/bluetooth.hpp>
 #include <vist/exception.hpp>
 
 #include <iostream>
 #include <gtest/gtest.h>
 
 using namespace vist;
-using namespace vist::policy::plugin;
 
 TEST(BluetoothTests, change_policy_state)
 {
+       using namespace vist::policy::plugin;
+
        try {
                test::change_policy_state<BluetoothState>();
                test::change_policy_state<DesktopConnectivity>();
@@ -65,3 +67,17 @@ TEST(BluetoothTests, set_policies)
 
        Query::Execute("DELETE FROM policy_admin WHERE name = 'vist-plugin-bluetooth-test'");
 }
+
+TEST(BluetoothTest, query_builder)
+{
+       using namespace vist::schema;
+
+       std::string query = BluetoothTable.selectAll();
+       EXPECT_EQ(query, "SELECT * FROM bluetooth");
+
+       query = BluetoothTable.update(Bluetooth::DesktopConnectivity = 3, Bluetooth::State = 7);
+       EXPECT_EQ(query, "UPDATE bluetooth SET desktopConnectivity = 3, state = 7");
+
+       query = BluetoothTable.update(Bluetooth::Pairing = 2, Bluetooth::Tethering = 9);
+       EXPECT_EQ(query, "UPDATE bluetooth SET pairing = 2, tethering = 9");
+}
index c44c393..dd8f3ad 100644 (file)
@@ -33,7 +33,7 @@ namespace schema {
                DECLARE_COLUMN(Tethering, "tethering", &Bluetooth::tethering);
        };
 
-       DECLARE_TABLE(bluetoothTable, "bluetooth", Bluetooth::State,
+       DECLARE_TABLE(BluetoothTable, "bluetooth", Bluetooth::State,
                                                                                           Bluetooth::DesktopConnectivity,
                                                                                           Bluetooth::Pairing,
                                                                                           Bluetooth::Tethering);