mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-08 10:23:54 +00:00
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
#include "osquery/core.h"
|
|
#include "osquery/core/sqlite_util.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "osquery/core/test_util.h"
|
|
|
|
namespace osquery {
|
|
namespace core {
|
|
|
|
class SQLiteUtilTests : public testing::Test {};
|
|
|
|
TEST_F(SQLiteUtilTests, test_simple_query_execution) {
|
|
int err;
|
|
auto db = createTestDB();
|
|
auto results = query(kTestQuery, err, db);
|
|
sqlite3_close(db);
|
|
EXPECT_EQ(err, 0);
|
|
EXPECT_EQ(results, getTestDBExpectedResults());
|
|
}
|
|
|
|
TEST_F(SQLiteUtilTests, test_passing_callback_no_data_param) {
|
|
char* err = nullptr;
|
|
auto db = createTestDB();
|
|
sqlite3_exec(db, kTestQuery.c_str(), query_data_callback, nullptr, &err);
|
|
sqlite3_close(db);
|
|
EXPECT_TRUE(err != nullptr);
|
|
if (err != nullptr) {
|
|
sqlite3_free(err);
|
|
}
|
|
}
|
|
|
|
TEST_F(SQLiteUtilTests, test_aggregate_query) {
|
|
int err;
|
|
auto db = createTestDB();
|
|
QueryData d = query(kTestQuery, err, db);
|
|
sqlite3_close(db);
|
|
EXPECT_EQ(err, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|