Skip to content
Snippets Groups Projects
Verified Commit 03ceca3b authored by Timm Fitschen's avatar Timm Fitschen
Browse files

TST: fix unit tests

parent 3e8ebe04
No related branches found
No related tags found
1 merge request!12DRAFT: ENH: file system: core
Pipeline #47486 failed
...@@ -46,6 +46,7 @@ Select ...@@ -46,6 +46,7 @@ Select
(Version) (Version)
*/ */
CREATE PROCEDURE db_5_0.insertEntity( CREATE PROCEDURE db_5_0.insertEntity(
in EntityID VARCHAR(255),
in EntityName VARCHAR(255), in EntityName VARCHAR(255),
in EntityDesc TEXT, in EntityDesc TEXT,
in EntityRole VARCHAR(255), in EntityRole VARCHAR(255),
......
...@@ -724,7 +724,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','entities','description' ...@@ -724,7 +724,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','entities','description'
-- COLUMN entities.role -- COLUMN entities.role
SELECT tap.has_column('_caosdb_schema_unit_tests','entities','role',''); SELECT tap.has_column('_caosdb_schema_unit_tests','entities','role','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','entities','role','enum(\'RECORDTYPE\',\'RECORD\',\'FILE\',\'_REPLACEMENT\',\'PROPERTY\',\'DATATYPE\',\'ROLE\',\'QUERYTEMPLATE\',\'DIRECTORY\')',''); SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','entities','role','enum(\'RECORDTYPE\',\'RECORD\',\'FILE\',\'_REPLACEMENT\',\'PROPERTY\',\'DATATYPE\',\'ROLE\',\'QUERYTEMPLATE\')','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','entities','role','',''); SELECT tap.col_extra_is('_caosdb_schema_unit_tests','entities','role','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','entities','role',NULL,''); SELECT tap.col_default_is('_caosdb_schema_unit_tests','entities','role',NULL,'');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','entities','role','utf8',''); SELECT tap.col_charset_is('_caosdb_schema_unit_tests','entities','role','utf8','');
...@@ -909,15 +909,23 @@ SELECT tap.table_collation_is('_caosdb_schema_unit_tests','files','utf8_unicode_ ...@@ -909,15 +909,23 @@ SELECT tap.table_collation_is('_caosdb_schema_unit_tests','files','utf8_unicode_
SELECT tap.table_engine_is('_caosdb_schema_unit_tests','files','InnoDB',''); SELECT tap.table_engine_is('_caosdb_schema_unit_tests','files','InnoDB','');
-- COLUMNS -- COLUMNS
SELECT tap.columns_are('_caosdb_schema_unit_tests','files','`file_id`,`path`,`size`,`hash`,`checked_timestamp`,`parent_directory`,`mimetype`,`file_storage_id`,`file_key`',''); SELECT tap.columns_are('_caosdb_schema_unit_tests','files','`file_id`,`path`,`size`,`hash`,`hash_algorithm`,`checked_timestamp`,`mimetype`,`file_storage_id`,`file_key`','');
-- TODO COLUMN files.parent_directory ---- TODO COLUMN files.parent_directory
SELECT tap.has_column('_caosdb_schema_unit_tests','files','parent_directory',''); --SELECT tap.has_column('_caosdb_schema_unit_tests','files','parent_directory','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','parent_directory','int(10) unsigned',''); --SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','parent_directory','int(10) unsigned','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','parent_directory','',''); --SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','parent_directory','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','parent_directory','NULL',''); --SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','parent_directory','NULL','');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','parent_directory',NULL,''); --SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','parent_directory',NULL,'');
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','parent_directory',NULL,''); --SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','parent_directory',NULL,'');
-- TODO COLUMN files.hash_algorithm
SELECT tap.has_column('_caosdb_schema_unit_tests','files','hash_algorithm','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','hash_algorithm','varbinary(255)','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','hash_algorithm','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','hash_algorithm','\'SHA-512\'','');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','hash_algorithm',NULL,'');
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','hash_algorithm',NULL,'');
-- TODO COLUMN files.mimetype -- TODO COLUMN files.mimetype
SELECT tap.has_column('_caosdb_schema_unit_tests','files','mimetype',''); SELECT tap.has_column('_caosdb_schema_unit_tests','files','mimetype','');
...@@ -937,7 +945,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','file_storage_id ...@@ -937,7 +945,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','file_storage_id
-- TODO COLUMN files.file_key -- TODO COLUMN files.file_key
SELECT tap.has_column('_caosdb_schema_unit_tests','files','file_key',''); SELECT tap.has_column('_caosdb_schema_unit_tests','files','file_key','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','file_key','varbinary(16175)',''); SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','file_key','varbinary(16000)','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','file_key','',''); SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','file_key','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','file_key',NULL,''); SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','file_key',NULL,'');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','file_key',NULL,''); SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','file_key',NULL,'');
...@@ -955,7 +963,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','file_id',NULL,' ...@@ -955,7 +963,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','file_id',NULL,'
-- COLUMN files.path -- COLUMN files.path
SELECT tap.has_column('_caosdb_schema_unit_tests','files','path',''); SELECT tap.has_column('_caosdb_schema_unit_tests','files','path','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','path','varchar(16175)',''); SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','path','varchar(16000)','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','path','',''); SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','path','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','path',NULL,''); SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','path',NULL,'');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','path','utf8',''); SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','path','utf8','');
...@@ -966,7 +974,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','path','utf8_uni ...@@ -966,7 +974,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','path','utf8_uni
SELECT tap.has_column('_caosdb_schema_unit_tests','files','size',''); SELECT tap.has_column('_caosdb_schema_unit_tests','files','size','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','size','bigint(20) unsigned',''); SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','files','size','bigint(20) unsigned','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','size','',''); SELECT tap.col_extra_is('_caosdb_schema_unit_tests','files','size','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','size','NULL',''); SELECT tap.col_default_is('_caosdb_schema_unit_tests','files','size',NULL,'');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','size',NULL,''); SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','size',NULL,'');
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','size',NULL,''); SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','size',NULL,'');
...@@ -989,7 +997,7 @@ SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','checked_timestamp ...@@ -989,7 +997,7 @@ SELECT tap.col_charset_is('_caosdb_schema_unit_tests','files','checked_timestamp
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','checked_timestamp',NULL,''); SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','checked_timestamp',NULL,'');
-- CONSTRAINTS -- CONSTRAINTS
SELECT tap.constraints_are('_caosdb_schema_unit_tests','files','`PRIMARY`,`fil_file_id_entity`,`path`,`files_ibfk_1`',''); SELECT tap.constraints_are('_caosdb_schema_unit_tests','files','`PRIMARY`,`fil_file_id_entity`,`path`','');
-- CONSTRAINT files.fil_file_id_entity -- CONSTRAINT files.fil_file_id_entity
...@@ -1009,13 +1017,6 @@ SELECT tap.col_is_pk('_caosdb_schema_unit_tests','files','`file_id`',''); ...@@ -1009,13 +1017,6 @@ SELECT tap.col_is_pk('_caosdb_schema_unit_tests','files','`file_id`','');
SELECT tap.has_constraint('_caosdb_schema_unit_tests','files','path',''); SELECT tap.has_constraint('_caosdb_schema_unit_tests','files','path','');
SELECT tap.constraint_type_is('_caosdb_schema_unit_tests','files','path','UNIQUE',''); SELECT tap.constraint_type_is('_caosdb_schema_unit_tests','files','path','UNIQUE','');
-- CONSTRAINT files.files_ibfk_1
SELECT tap.has_constraint('_caosdb_schema_unit_tests','files','files_ibfk_1','');
SELECT tap.constraint_type_is('_caosdb_schema_unit_tests','files','files_ibfk_1','FOREIGN KEY','');
SELECT tap.fk_on_delete('_caosdb_schema_unit_tests','files','files_ibfk_1','RESTRICT','');
SELECT tap.fk_on_update('_caosdb_schema_unit_tests','files','files_ibfk_1','RESTRICT','');
-- *************************************************************** -- ***************************************************************
-- TABLE _caosdb_schema_unit_tests.integer_data -- TABLE _caosdb_schema_unit_tests.integer_data
...@@ -2547,13 +2548,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getChildren', ...@@ -2547,13 +2548,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getChildren',
SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getChildren','DEFINER',''); SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getChildren','DEFINER','');
SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getChildren','CONTAINS SQL',''); SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getChildren','CONTAINS SQL','');
-- PROCEDURES _caosdb_schema_unit_tests.getFileIdByPath
SELECT tap.has_procedure('_caosdb_schema_unit_tests','getFileIdByPath','');
SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getFileIdByPath','NO','');
SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getFileIdByPath','DEFINER','');
SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getFileIdByPath','CONTAINS SQL','');
-- PROCEDURES _caosdb_schema_unit_tests.initBackReference -- PROCEDURES _caosdb_schema_unit_tests.initBackReference
SELECT tap.has_procedure('_caosdb_schema_unit_tests','initBackReference',''); SELECT tap.has_procedure('_caosdb_schema_unit_tests','initBackReference','');
......
USE _caosdb_schema_unit_tests;
BEGIN;
CALL tap.no_plan();
-- SETUP
INSERT INTO entities (id, role, acl) VALUES
(52, "FILE", 0),
(53, "FILE", 0),
(54, "FILE", 0),
(55, "FILE", 0),
(56, "FILE", 0),
(57, "FILE", 0);
INSERT INTO files (file_id, path, size, file_key) VALUES
(52, "file_at_root_a", 256, "file_at_root_a"),
(53, "file_at_root_b", 256, "file_at_root_b"),
(54, "level1/file_at_level1_a", 256, "level1/file_at_level1_a"),
(55, "level1/file_at_level1_b", 256, "level1/file_at_level1_b"),
(56, "level1/level2/file_at_level2_a", 256, "level1/level2/file_at_level2_a"),
(57, "level1/level2/file_at_level2_b", 256, "level1/level2/file_at_level2_b");
SELECT tap.eq(COUNT(*), 7, "7 rows in test_files") FROM files;
-- TEST _create_dirs
CALL _create_dirs();
SELECT tap.eq(COUNT(*), 9, "9 rows in test_files") FROM files;
SELECT tap.eq(COUNT(*), 1, "one dir level1") FROM files WHERE path="level1";
SELECT tap.eq(COUNT(*), 1, "one dir level1/level2") FROM files WHERE path="level1/level2";
CALL tap.finish();
ROLLBACK;
...@@ -28,9 +28,6 @@ CALL tap.no_plan(); ...@@ -28,9 +28,6 @@ CALL tap.no_plan();
-- ##################################################################### -- #####################################################################
-- SETUP -- SETUP
-- switch off versioning
DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING";
DELETE FROM entity_version; DELETE FROM entity_version;
DELETE FROM transactions; DELETE FROM transactions;
INSERT INTO transactions (srid,seconds,nanos,username,realm) VALUES INSERT INTO transactions (srid,seconds,nanos,username,realm) VALUES
...@@ -112,9 +109,9 @@ SELECT tap.eq(value_iversion, "1", "value_iversion ok 3") FROM reference_data; ...@@ -112,9 +109,9 @@ SELECT tap.eq(value_iversion, "1", "value_iversion ok 3") FROM reference_data;
DELETE FROM reference_data WHERE domain_id=0 AND entity_id=@InternalEntityID; DELETE FROM reference_data WHERE domain_id=0 AND entity_id=@InternalEntityID;
SET @VersionedValue=CONCAT(@Value, "@versionblub"); SET @VALUE="50@versionblub";
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
@VersionedValue, NULL, "FIX", NULL, NULL, NULL, NULL, 0); NULL, "FIX", NULL, NULL, NULL, NULL, 0);
-- TODO switch expected/actual -- TODO switch expected/actual
SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data; SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data;
...@@ -127,17 +124,15 @@ SELECT tap.eq(value_iversion, "2", "value_iversion ok 4") FROM reference_data; ...@@ -127,17 +124,15 @@ SELECT tap.eq(value_iversion, "2", "value_iversion ok 4") FROM reference_data;
-- invalid values throw errors -- invalid values throw errors
SET @VersionedValue=CONCAT(@Value, "@"); SET @VALUE="50@";
CALL tap._assert_throws(' CALL tap._assert_throws('
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
@VersionedValue, NULL, "FIX", NULL, NULL, NULL, NULL, 0)', "@ but no NULL, "FIX", NULL, NULL, NULL, NULL, 0)', "@ but no version id");
version id");
SET @VersionedValue=CONCAT(@Value, "@non-existing-version"); SET @VALUE="50@non-existing-version";
CALL tap._assert_throws(' CALL tap._assert_throws('
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
@VersionedValue, NULL, "FIX", NULL, NULL, NULL, NULL, 0)', NULL, "FIX", NULL, NULL, NULL, NULL, 0)', "non-existing-version id");
"non-existing-version id");
-- ##################################################################### -- #####################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment