Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
sql_utils_test.cc
1 #include <gtest/gtest.h>
2 
3 #include "storage/sql_utils.h"
4 #include "utilities/utils.h"
5 
6 TEST(sql_utils, PrepareRvalue) {
7  TemporaryDirectory temp_dir;
8  SQLite3Guard db((temp_dir.Path() / "test.db").c_str());
9 
10  db.exec("CREATE TABLE example(ex1 TEXT, ex2 TEXT);", NULL, NULL);
11  // the arguments used in prepareStatement should last for the subsequent
12  // sqlite calls (eg: `.step()`)
13  std::string s2 = "test";
14  auto statement =
15  db.prepareStatement<std::string>("INSERT INTO example(ex1, ex2) VALUES (?,?);", temp_dir.PathString(), s2);
16  EXPECT_EQ(statement.step(), SQLITE_DONE);
17 }
18 
19 #ifndef __NO_MAIN__
20 int main(int argc, char** argv) {
21  ::testing::InitGoogleTest(&argc, argv);
22  logger_init();
23  logger_set_threshold(boost::log::trivial::trace);
24 
25  return RUN_ALL_TESTS();
26 }
27 #endif
TemporaryDirectory
Definition: utils.h:82
SQLite3Guard
Definition: sql_utils.h:131