Skip to content
Snippets Groups Projects
Commit 381f0fcd authored by Daniel Hornung's avatar Daniel Hornung Committed by Henrik tom Wörden
Browse files

ENH: Test with non-string property values.

parent 46daece6
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.13)
project(libcaosdb_inttests
DESCRIPTION "Integration tests for the C++ client libraries of the CaosDB project which run against the CaosDB server."
......
......@@ -301,7 +301,7 @@ TEST_F(test_transaction, insert_delete_with_property) {
const auto &connection =
caosdb::connection::ConnectionManager::GetDefaultConnection();
// Create and insert property
// Create and insert Text property
Entity prop_ent;
prop_ent.SetRole(Role::PROPERTY);
prop_ent.SetName("TestProperty");
......@@ -321,17 +321,43 @@ TEST_F(test_transaction, insert_delete_with_property) {
const auto &inserted_prop = prop_result_set.at(0);
EXPECT_FALSE(inserted_prop.GetId().empty());
// create and insert record type with the above property
// Create and insert Double property
Entity prop_double_ent;
prop_double_ent.SetRole(Role::PROPERTY);
prop_double_ent.SetName("TestDoubleProperty");
prop_double_ent.SetDataType(AtomicDataType::DOUBLE);
prop_insertion = connection->CreateTransaction();
prop_insertion->InsertEntity(&prop_double_ent);
prop_insertion->ExecuteAsynchronously();
prop_insert_status = prop_insertion->WaitForIt();
ASSERT_TRUE(prop_insert_status.IsTerminated());
ASSERT_FALSE(prop_insert_status.IsError());
const auto &prop_double_result_set = prop_insertion->GetResultSet();
const auto &inserted_prop_double = prop_double_result_set.at(0);
EXPECT_FALSE(inserted_prop_double.GetId().empty());
// create and insert record type with the above properties
Property prop_rt;
prop_rt.SetName(prop_ent.GetName());
prop_rt.SetId(inserted_prop.GetId());
prop_rt.SetImportance(Importance::SUGGESTED);
Property prop_double;
prop_double.SetName(prop_double_ent.GetName());
prop_double.SetId(inserted_prop_double.GetId());
prop_double.SetImportance(Importance::SUGGESTED);
Entity rt;
rt.SetRole(Role::RECORD_TYPE);
rt.SetName("TestRT");
rt.SetDescription("Some description");
rt.AppendProperty(prop_rt);
rt.AppendProperty(prop_double);
auto rt_insertion(connection->CreateTransaction());
rt_insertion->InsertEntity(&rt);
......@@ -364,11 +390,17 @@ TEST_F(test_transaction, insert_delete_with_property) {
EXPECT_EQ(rt.GetDescription(), retrieved_rt.GetDescription());
EXPECT_EQ(retrieved_rt.GetProperties().size(), 1);
const auto &retrieved_prop_rt = retrieved_rt.GetProperties().at(0);
EXPECT_EQ(retrieved_prop_rt.GetName(), prop_ent.GetName());
EXPECT_EQ(retrieved_prop_rt.GetId(), inserted_prop.GetId());
EXPECT_EQ(retrieved_prop_rt.GetDataType(), prop_ent.GetDataType());
EXPECT_EQ(retrieved_prop_rt.GetImportance(), prop_rt.GetImportance());
const Property *retrieved_prop_rt = nullptr;
// get by name is not possible yet
if (retrieved_rt.GetProperties().at(0).GetName() == prop_ent.GetName()) {
retrieved_prop_rt = &retrieved_rt.GetProperties().at(0);
} else {
retrieved_prop_rt = &retrieved_rt.GetProperties().at(1);
}
EXPECT_EQ(retrieved_prop_rt->GetName(), prop_ent.GetName());
EXPECT_EQ(retrieved_prop_rt->GetId(), inserted_prop.GetId());
EXPECT_EQ(retrieved_prop_rt->GetDataType(), prop_ent.GetDataType());
EXPECT_EQ(retrieved_prop_rt->GetImportance(), prop_rt.GetImportance());
// create and insert record of the above record type with a property
// with a value.
......@@ -381,11 +413,17 @@ TEST_F(test_transaction, insert_delete_with_property) {
prop_rec.SetId(inserted_prop.GetId());
prop_rec.SetValue(std::string("Test"));
Property prop_double_rec;
prop_double_rec.SetName(prop_double_ent.GetName());
prop_double_rec.SetId(inserted_prop_double.GetId());
prop_double_rec.SetValue(123456789.98700001);
Entity rec;
rec.SetName("TestRec");
rec.SetRole(Role::RECORD);
rec.AppendParent(parent);
rec.AppendProperty(prop_rec);
rec.AppendProperty(prop_double_rec);
auto rec_insertion(connection->CreateTransaction());
rec_insertion->InsertEntity(&rec);
......@@ -423,11 +461,30 @@ TEST_F(test_transaction, insert_delete_with_property) {
EXPECT_EQ(retrieved_parent_rec.GetId(), inserted_rt.GetId());
EXPECT_EQ(retrieved_parent_rec.GetDescription(), rt.GetDescription());
const auto &retrieved_prop_rec = retrieved_rec.GetProperties().at(0);
EXPECT_EQ(retrieved_prop_rec.GetName(), prop_ent.GetName());
EXPECT_EQ(retrieved_prop_rec.GetId(), inserted_prop.GetId());
EXPECT_EQ(retrieved_prop_rec.GetDataType(), prop_ent.GetDataType());
EXPECT_EQ(retrieved_prop_rec.GetValue(), prop_rec.GetValue());
const auto &retrieved_prop_0 = retrieved_rec.GetProperties().at(0);
const auto &retrieved_prop_1 = retrieved_rec.GetProperties().at(1);
const Property *retrieved_prop_rec = nullptr;
const Property *retrieved_prop_double = nullptr;
if (retrieved_prop_0.GetName() == prop_ent.GetName()) {
retrieved_prop_rec = &retrieved_prop_0;
retrieved_prop_double = &retrieved_prop_1;
} else {
retrieved_prop_rec = &retrieved_prop_1;
retrieved_prop_double = &retrieved_prop_0;
}
EXPECT_EQ(retrieved_prop_rec->GetName(), prop_ent.GetName());
EXPECT_EQ(retrieved_prop_rec->GetId(), inserted_prop.GetId());
EXPECT_EQ(retrieved_prop_rec->GetDataType(), prop_ent.GetDataType());
EXPECT_EQ(retrieved_prop_rec->GetValue(), prop_rec.GetValue());
EXPECT_EQ(retrieved_prop_double->GetName(), prop_double_ent.GetName());
EXPECT_EQ(retrieved_prop_double->GetId(), inserted_prop_double.GetId());
EXPECT_EQ(retrieved_prop_double->GetDataType(),
prop_double_ent.GetDataType());
EXPECT_TRUE(retrieved_prop_double->GetValue().IsDouble());
EXPECT_EQ(retrieved_prop_double->GetValue(), prop_double_rec.GetValue());
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment