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
Branches
No related tags found
1 merge request!12DRAFT: ENH: file system: core
Pipeline #47486 failed
......@@ -46,6 +46,7 @@ Select
(Version)
*/
CREATE PROCEDURE db_5_0.insertEntity(
in EntityID VARCHAR(255),
in EntityName VARCHAR(255),
in EntityDesc TEXT,
in EntityRole VARCHAR(255),
......
......@@ -724,7 +724,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','entities','description'
-- COLUMN 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_default_is('_caosdb_schema_unit_tests','entities','role',NULL,'');
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_
SELECT tap.table_engine_is('_caosdb_schema_unit_tests','files','InnoDB','');
-- 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`','');
-- TODO COLUMN 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_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_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.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
--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_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_charset_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
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
-- TODO COLUMN 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_default_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,'
-- COLUMN 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_default_is('_caosdb_schema_unit_tests','files','path',NULL,'');
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
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_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_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
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','files','checked_timestamp',NULL,'');
-- 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
......@@ -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.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
......@@ -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_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
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();
-- #####################################################################
-- SETUP
-- switch off versioning
DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING";
DELETE FROM entity_version;
DELETE FROM transactions;
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;
DELETE FROM reference_data WHERE domain_id=0 AND entity_id=@InternalEntityID;
SET @VersionedValue=CONCAT(@Value, "@versionblub");
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data",
@VersionedValue, NULL, "FIX", NULL, NULL, NULL, NULL, 0);
SET @VALUE="50@versionblub";
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
NULL, "FIX", NULL, NULL, NULL, NULL, 0);
-- TODO switch expected/actual
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;
-- invalid values throw errors
SET @VersionedValue=CONCAT(@Value, "@");
SET @VALUE="50@";
CALL tap._assert_throws('
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data",
@VersionedValue, NULL, "FIX", NULL, NULL, NULL, NULL, 0)', "@ but no
version id");
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
NULL, "FIX", NULL, NULL, NULL, NULL, 0)', "@ but no version id");
SET @VersionedValue=CONCAT(@Value, "@non-existing-version");
SET @VALUE="50@non-existing-version";
CALL tap._assert_throws('
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data",
@VersionedValue, NULL, "FIX", NULL, NULL, NULL, NULL, 0)',
"non-existing-version id");
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
NULL, "FIX", NULL, NULL, NULL, NULL, 0)', "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