diff options
author | Roland Reichwein <mail@reichwein.it> | 2023-02-12 11:54:05 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2023-02-12 11:54:05 +0100 |
commit | b0f8b28977e59b7fbfc1ce57ee5c102b8e4e0690 (patch) | |
tree | 926eb8dbd140d84ab0238ce7d671673056f12f56 /tests | |
parent | 7d5ca5cebfe3453aaa3c649bbc3e771e6d636ac9 (diff) |
Touch documents on read (i.e. reset timeout on read)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-connectionregistry.cpp | 3 | ||||
-rw-r--r-- | tests/test-storage.cpp | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/test-connectionregistry.cpp b/tests/test-connectionregistry.cpp index 282f397..dbc2b7e 100644 --- a/tests/test-connectionregistry.cpp +++ b/tests/test-connectionregistry.cpp @@ -114,14 +114,17 @@ TEST_F(ConnectionRegistryTest, test_iterators) EXPECT_THROW(cr.begin(""), std::exception); EXPECT_THROW(cr.end(""), std::exception); + EXPECT_EQ(std::distance(cr.begin(), cr.end()), 0); cr.addConnection(c); EXPECT_THROW(cr.begin(""), std::exception); EXPECT_THROW(cr.end(""), std::exception); + EXPECT_EQ(std::distance(cr.begin(), cr.end()), 1); cr.setId(c, "id1"); EXPECT_EQ(std::distance(cr.begin("id1"), cr.end("id1")), 1); + EXPECT_EQ(std::distance(cr.begin(), cr.end()), 1); } TEST_F(ConnectionRegistryTest, test_guard) diff --git a/tests/test-storage.cpp b/tests/test-storage.cpp index 51a6058..6239f8f 100644 --- a/tests/test-storage.cpp +++ b/tests/test-storage.cpp @@ -12,6 +12,7 @@ namespace fs = std::filesystem; using namespace Reichwein; +using namespace std::string_literals; namespace { const std::string testConfigFilename{"./test.conf"}; @@ -118,6 +119,16 @@ TEST_F(StorageTest, setDocument) EXPECT_EQ(storage.getDocument("0"), "abc"); } +TEST_F(StorageTest, touchDocument) +{ + Storage storage(*m_config); + EXPECT_THROW(storage.touchDocument("0"), std::exception); + storage.setDocument("0", "abc"); + storage.touchDocument("0"); + EXPECT_EQ(storage.getNumberOfDocuments(), 1UL); + EXPECT_EQ(storage.getDocument("0"), "abc"); +} + TEST_F(StorageTest, setRevision) { Storage storage(*m_config); @@ -126,6 +137,15 @@ TEST_F(StorageTest, setRevision) EXPECT_EQ(storage.getNumberOfDocuments(), 1UL); EXPECT_EQ(storage.getRevision("0"), 123); + + try { + storage.setRevision("1", 123); + FAIL(); + } catch(const std::exception& ex) { + EXPECT_EQ("Unable to set revision for id 1"s, ex.what()); + } catch(...) { + FAIL(); + } } TEST_F(StorageTest, setCursorPos) @@ -136,6 +156,15 @@ TEST_F(StorageTest, setCursorPos) EXPECT_EQ(storage.getNumberOfDocuments(), 1UL); EXPECT_EQ(storage.getCursorPos("0"), 1234); + + try { + storage.setCursorPos("1", 12345); + FAIL(); + } catch(const std::exception& ex) { + EXPECT_EQ("Unable to set cursor position for id 1"s, ex.what()); + } catch(...) { + FAIL(); + } } TEST_F(StorageTest, setRow) |