| 24 | } |
| 25 | |
| 26 | TEST_F(SystemConfigTest, testAccessMode) { |
| 27 | systemConfig->readOnly = false; |
| 28 | auto db = std::make_unique<Database>(databasePath, *systemConfig); |
| 29 | auto con = std::make_unique<Connection>(db.get()); |
| 30 | assertQuery( |
| 31 | *con->query("CREATE NODE TABLE Person1(name STRING, age INT64, PRIMARY KEY(name))")); |
| 32 | assertQuery(*con->query("CREATE (:Person1 {name: 'Alice', age: 25})")); |
| 33 | assertQuery(*con->query("MATCH (:Person1) RETURN COUNT(*)")); |
| 34 | db.reset(); |
| 35 | systemConfig->readOnly = true; |
| 36 | if (databasePath == "" || databasePath == ":memory:") { |
| 37 | EXPECT_THROW(auto db2 = std::make_unique<Database>("", *systemConfig), Exception); |
| 38 | EXPECT_THROW(auto db2 = std::make_unique<Database>(":memory:", *systemConfig), Exception); |
| 39 | return; |
| 40 | } |
| 41 | std::unique_ptr<Database> db2; |
| 42 | std::unique_ptr<Connection> con2; |
| 43 | EXPECT_NO_THROW(db2 = std::make_unique<Database>(databasePath, *systemConfig)); |
| 44 | EXPECT_NO_THROW(con2 = std::make_unique<Connection>(db2.get())); |
| 45 | ASSERT_FALSE(con2->query("DROP TABLE Person")->isSuccess()); |
| 46 | EXPECT_NO_THROW(con2->query("MATCH (:Person) RETURN COUNT(*)")); |
| 47 | } |
| 48 | |
| 49 | TEST_F(SystemConfigTest, testSpillToDisk) { |
| 50 | systemConfig->readOnly = false; |
nothing calls this directly
no test coverage detected