diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 58037e1709c9c21bb889091a1fb62e0f92c73be0..085d3cdb9f155b75ad2272c8c62cb75fbd8bc053 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -11,7 +11,7 @@ COPY . /caosdb-octaveinttest WORKDIR /caosdb-octaveinttest RUN rm -rf .git -COPY .docker/caosdb-client.json /caosdb-client.json +COPY .docker/caosdb_client.json /caosdb_client.json # build and install octave-lib WORKDIR /caosdb-octavelib diff --git a/.docker/caosdb-client.json b/.docker/caosdb_client.json similarity index 100% rename from .docker/caosdb-client.json rename to .docker/caosdb_client.json diff --git a/.miss_hit b/.miss_hit new file mode 100644 index 0000000000000000000000000000000000000000..f15ccfe29ff4a2e193fb4ae51ca5a7bd1cc3a88d --- /dev/null +++ b/.miss_hit @@ -0,0 +1,7 @@ +# -*- mode:conf; -*- +# See https://florianschanda.github.io/miss_hit/style_checker.html + +line_length: 100 +regex_function_name: "[a-z]+(_[a-z]+)*" +suppress_rule: "whitespace_comments" +tab_width: 2 diff --git a/test/Run_Test.m b/test/Run_Test.m index b698325ef22744a7a468bf2059f6876b2211a8ce..702f75f29c159746613c17a6b4a5639713c63cd7 100644 --- a/test/Run_Test.m +++ b/test/Run_Test.m @@ -17,7 +17,10 @@ % along with this program. If not, see <https://www.gnu.org/licenses/>. pkg load caosdb; -test_result = moxunit_runtests("-verbose", "test_caosdb.m"); -if not(test_result) + +all_tests = true; +all_tests &= moxunit_runtests("-verbose", "test_caosdb.m"); + +if not(all_tests) exit(1); end diff --git a/test/test_caosdb.m b/test/test_caosdb.m index 15bab29c95f826d12aaac777ec272c0c36721378..0c0bf37e8ad1cb4e5ec9a36c71be17d4729cdc5d 100644 --- a/test/test_caosdb.m +++ b/test/test_caosdb.m @@ -63,7 +63,7 @@ function test_retrieve_single() c = Caosdb(); % Retrieve a single entity - violin = c.retrieve("120"){1}; + violin = c.retrieve_by_id("120"){1}; % Check content assertEqual(violin.name, "Sherlock Holmes' violin"); @@ -82,8 +82,8 @@ end function test_retrieve_multiple() % Retrieve two entities c = Caosdb(); - violin = c.retrieve("120"){1}; - collection = c.retrieve({"120", "119"}); + violin = c.retrieve_by_id("120"){1}; + collection = c.retrieve_by_id({"120", "119"}); assertEqual(length(collection), 2); assertEqual(numel(collection), 2); @@ -99,24 +99,36 @@ function test_retrieve_multiple() assertEqual(props{2}.value, 7.68315); end +%% Test query execution +function test_execute_query() + c = Caosdb(); + violin = c.query("FIND Record Violin WITH name=\"Sherlock Holmes' violin\""){1}; + props = violin.get_properties(); + assertEqual(props{1}.name, "price"); + assertEqual(props{1}.value, 814873.0); + assertEqual(props{2}.name, "Manufacturer"); + assertEqual(props{2}.value, "119"); +end + +% Error handling tests %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %% Test retrieval with errors function test_retrieve_failure() % Default connection configuration is sufficient. c = Caosdb(); % Retrieve a non-existing entity. - does_not_exist = c.retrieve("i-do-not-exist"){1}; + does_not_exist = c.retrieve_by_id("i-do-not-exist"){1}; assertTrue(does_not_exist.has_errors()); error = does_not_exist.get_errors(){1}; assertEqual(typeinfo(error.code), "int64 scalar"); assertEqual(error.code, int64(2)); assertEqual(error.description, "Entity does not exist."); +end - % Call retrieve with wrong arguments. - % (Only m file level, no invalid arguments should make it to the mex function.) - assertExceptionThrown(@()c.retrieve(120), "maox:InvalidArgument"); - assertExceptionThrown(@()c.retrieve({120}), "maox:InvalidArgument"); - assertExceptionThrown(@()c.retrieve({"120"}, {}), "maox:InvalidArgument"); - assertExceptionThrown(@()c.retrieve({"120"}, {120}), "maox:InvalidArgument"); - assertExceptionThrown(@()c.retrieve({"120"}, {"120", 120}), "maox:InvalidArgument"); +%% Test querying with errors +function test_execute_query_failure() + c = Caosdb(); + results = c.query("FIND Record I-Do-Not-Exist"); % Must not segfault. + assertTrue(isempty(results)); end