summaryrefslogtreecommitdiff
path: root/tests/test_db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_db.cpp')
-rw-r--r--tests/test_db.cpp147
1 files changed, 62 insertions, 85 deletions
diff --git a/tests/test_db.cpp b/tests/test_db.cpp
index 9649087..1f6541d 100644
--- a/tests/test_db.cpp
+++ b/tests/test_db.cpp
@@ -31,93 +31,70 @@
BOOST_FIXTURE_TEST_SUITE(DB_TEST, DBFixture)
-BOOST_AUTO_TEST_CASE(DB_app_positive) {
-
- std::list<app_t> buffer;
- app_t app1("app_1", "pkg_1", 5001, {});
-
- chain_t chain2 = {"cert2"};
- app_t app2("app_2", "pkg 2", 5002, {chain2});
-
- chain_t chain2r = {"cert2r"};
- app_t app2r("app_2_remove", "pkg 2", 5002, {chain2, chain2r});
-
- chain_t chain31 = {"cert_3.1", "cert 3.2"};
- chain_t chain32 = {"cert_3.1"};
- app_t app3("app 3", "pkg 3", 5003, {chain31, chain32});
-
- chain_t chain41 = {"cert_4.1", "cert 4.2"};
- chain_t chain42 = {"cert_4.2.1", "cert 4.2.2", "cert 4.2.3"};
- chain_t chain43 = {"cert_4.3.1"};
-
- app_t app4("app 4", "pkg 4", 5004, {chain41, chain42, chain43});
-
- BOOST_REQUIRE(add_app_to_check_list(app1)==true);
- BOOST_REQUIRE(add_app_to_check_list(app2)==true);
- BOOST_REQUIRE(add_app_to_check_list(app2r)==true);
- BOOST_REQUIRE(add_app_to_check_list(app3)==true);
- BOOST_REQUIRE(add_app_to_check_list(app4)==true);
-
- mark_as_verified(app2, app_t::verified_t::NO);
- mark_as_verified(app3, app_t::verified_t::YES);
- remove_app_from_check_list(app2r);
-
- app2.verified = app_t::verified_t::NO;
- app3.verified = app_t::verified_t::YES;
-
- std::list<app_t> buffer_ok = {app1, app2, app3, app4};
-
- get_app_list(buffer);
-
- // Need to sort buffer
- sort_buffer(buffer);
- sort_buffer(buffer_ok);
-
- BOOST_REQUIRE(buffer_ok == buffer);
+BOOST_AUTO_TEST_CASE(DB_app_positive)
+{
+ std::list<app_t> buffer;
+ app_t app1("app_1", "pkg_1", 5001, {});
+ chain_t chain2 = {"cert2"};
+ app_t app2("app_2", "pkg 2", 5002, {chain2});
+ chain_t chain2r = {"cert2r"};
+ app_t app2r("app_2_remove", "pkg 2", 5002, {chain2, chain2r});
+ chain_t chain31 = {"cert_3.1", "cert 3.2"};
+ chain_t chain32 = {"cert_3.1"};
+ app_t app3("app 3", "pkg 3", 5003, {chain31, chain32});
+ chain_t chain41 = {"cert_4.1", "cert 4.2"};
+ chain_t chain42 = {"cert_4.2.1", "cert 4.2.2", "cert 4.2.3"};
+ chain_t chain43 = {"cert_4.3.1"};
+ app_t app4("app 4", "pkg 4", 5004, {chain41, chain42, chain43});
+ BOOST_REQUIRE(add_app_to_check_list(app1) == true);
+ BOOST_REQUIRE(add_app_to_check_list(app2) == true);
+ BOOST_REQUIRE(add_app_to_check_list(app2r) == true);
+ BOOST_REQUIRE(add_app_to_check_list(app3) == true);
+ BOOST_REQUIRE(add_app_to_check_list(app4) == true);
+ mark_as_verified(app2, app_t::verified_t::NO);
+ mark_as_verified(app3, app_t::verified_t::YES);
+ remove_app_from_check_list(app2r);
+ app2.verified = app_t::verified_t::NO;
+ app3.verified = app_t::verified_t::YES;
+ std::list<app_t> buffer_ok = {app1, app2, app3, app4};
+ get_app_list(buffer);
+ // Need to sort buffer
+ sort_buffer(buffer);
+ sort_buffer(buffer_ok);
+ BOOST_REQUIRE(buffer_ok == buffer);
}
-BOOST_AUTO_TEST_CASE(DB_app_negative) {
-
- std::list<app_t> buffer;
- app_t app1("app_1", "pkg_1", 5001, {});
-
- chain_t chain2 = {"cert2"};
- app_t app2("app_2", "pkg 2", 5002, {chain2});
-
- chain_t chain2r = {"cert2r"};
- app_t app2r("app_2_remove", "pkg 2", 5002, {chain2, chain2r});
-
- chain_t chain31 = {"cert_3.1", "cert 3.2"};
- chain_t chain32 = {"cert_3.1"};
- app_t app3("app 3", "pkg 3", 5003, {chain31, chain32});
-
- chain_t chain41 = {"cert_4.1", "cert 4.2"};
- chain_t chain42 = {"cert_4.2.1", "cert 4.2.2", "cert 4.2.3"};
- chain_t chain43 = {"cert_4.3.1"};
-
- app_t app4("app 4", "pkg 4", 5004, {chain41, chain42, chain43});
-
- BOOST_REQUIRE(add_app_to_check_list(app1)==true);
- BOOST_REQUIRE(add_app_to_check_list(app2)==true);
- BOOST_REQUIRE(add_app_to_check_list(app2r)==true);
- // Skipp adding app3 to database
- BOOST_REQUIRE(add_app_to_check_list(app4)==true);
-
- mark_as_verified(app2, app_t::verified_t::NO);
- mark_as_verified(app3, app_t::verified_t::YES);
- remove_app_from_check_list(app2r);
-
- app2.verified = app_t::verified_t::NO;
- app3.verified = app_t::verified_t::YES;
-
- std::list<app_t> buffer_ok = {app1, app2, app3, app4};
-
- get_app_list(buffer);
-
- // list has to be sorted before comparison.
- sort_buffer(buffer);
- sort_buffer(buffer_ok);
- BOOST_REQUIRE(buffer_ok != buffer);
+BOOST_AUTO_TEST_CASE(DB_app_negative)
+{
+ std::list<app_t> buffer;
+ app_t app1("app_1", "pkg_1", 5001, {});
+ chain_t chain2 = {"cert2"};
+ app_t app2("app_2", "pkg 2", 5002, {chain2});
+ chain_t chain2r = {"cert2r"};
+ app_t app2r("app_2_remove", "pkg 2", 5002, {chain2, chain2r});
+ chain_t chain31 = {"cert_3.1", "cert 3.2"};
+ chain_t chain32 = {"cert_3.1"};
+ app_t app3("app 3", "pkg 3", 5003, {chain31, chain32});
+ chain_t chain41 = {"cert_4.1", "cert 4.2"};
+ chain_t chain42 = {"cert_4.2.1", "cert 4.2.2", "cert 4.2.3"};
+ chain_t chain43 = {"cert_4.3.1"};
+ app_t app4("app 4", "pkg 4", 5004, {chain41, chain42, chain43});
+ BOOST_REQUIRE(add_app_to_check_list(app1) == true);
+ BOOST_REQUIRE(add_app_to_check_list(app2) == true);
+ BOOST_REQUIRE(add_app_to_check_list(app2r) == true);
+ // Skipp adding app3 to database
+ BOOST_REQUIRE(add_app_to_check_list(app4) == true);
+ mark_as_verified(app2, app_t::verified_t::NO);
+ mark_as_verified(app3, app_t::verified_t::YES);
+ remove_app_from_check_list(app2r);
+ app2.verified = app_t::verified_t::NO;
+ app3.verified = app_t::verified_t::YES;
+ std::list<app_t> buffer_ok = {app1, app2, app3, app4};
+ get_app_list(buffer);
+ // list has to be sorted before comparison.
+ sort_buffer(buffer);
+ sort_buffer(buffer_ok);
+ BOOST_REQUIRE(buffer_ok != buffer);
}
BOOST_AUTO_TEST_SUITE_END()