Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-mysqlbackend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-mysqlbackend
Commits
7ccdeb24
Verified
Commit
7ccdeb24
authored
5 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
TST: basic test cases for insert, update, delete
parent
f94515cf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_insert_update_delete.sql
+73
-0
73 additions, 0 deletions
tests/test_insert_update_delete.sql
with
73 additions
and
0 deletions
tests/test_insert_update_delete.sql
0 → 100644
+
73
−
0
View file @
7ccdeb24
USE
_caosdb_schema_unit_tests
;
BEGIN
;
CALL
tap
.
no_plan
();
-- SETUP
CALL
entityACL
(
@
ACLID1
,
"{acl1}"
);
CALL
entityACL
(
@
ACLID2
,
"{acl2}"
);
SELECT
id
into
@
TextDatatypeID
FROM
entities
WHERE
name
=
"TEXT"
and
role
=
"DATATYPE"
;
-- TESTS
-- TEST insertEntity
SELECT
COUNT
(
id
)
INTO
@
x
FROM
entities
WHERE
id
>
100
;
SELECT
tap
.
eq
(
@
x
,
0
,
"No entities"
);
CALL
insertEntity
(
"EntityName"
,
"EntityDesc"
,
"RECORDTYPE"
,
"{acl1}"
);
SELECT
COUNT
(
id
)
INTO
@
x
FROM
entities
WHERE
name
=
"EntityName"
;
SELECT
tap
.
eq
(
@
x
,
1
,
"Entity has been inserted"
);
SELECT
acl
INTO
@
x
FROM
entities
WHERE
name
=
"EntityName"
;
SELECT
tap
.
eq
(
@
x
,
@
ACLID1
,
"correct acl id had been assigned"
);
SELECT
id
INTO
@
EntityID
FROM
entities
WHERE
name
=
"EntityName"
;
SELECT
tap
.
ok
(
@
EntityID
>
100
,
"EntityID greater 100"
);
-- TEST insertEntityProperty
CALL
insertEntity
(
"AProperty"
,
"APropDesc"
,
"PROPERTY"
,
"{acl1}"
);
SELECT
id
INTO
@
PropID
FROM
entities
WHERE
name
=
"AProperty"
;
INSERT
INTO
data_type
(
domain_id
,
entity_id
,
property_id
,
datatype
)
VALUES
(
0
,
0
,
@
PropID
,
@
TextDatatypeID
);
SELECT
COUNT
(
*
)
INTO
@
x
FROM
null_data
;
SELECT
tap
.
eq
(
@
x
,
0
,
"No data in null_data table"
);
CALL
insertEntityProperty
(
0
,
@
EntityID
,
@
PropID
,
"null_data"
,
NULL
,
NULL
,
"RECOMMENDED"
,
NULL
,
NULL
,
NULL
,
NULL
,
0
);
SELECT
COUNT
(
*
)
INTO
@
x
FROM
null_data
;
SELECT
tap
.
eq
(
@
x
,
1
,
"One row in null_data table"
);
-- TEST updateEntity
CALL
updateEntity
(
@
EntityID
,
"NewEntityName"
,
"NewEntityDesc"
,
"RECORD"
,
NULL
,
NULL
,
"{acl2}"
);
SELECT
COUNT
(
id
)
INTO
@
x
FROM
entities
WHERE
name
=
"EntityName"
;
SELECT
tap
.
eq
(
@
x
,
0
,
"Old Entity name not present"
);
SELECT
COUNT
(
id
)
INTO
@
x
FROM
entities
WHERE
name
=
"NewEntityName"
;
SELECT
tap
.
eq
(
@
x
,
1
,
"Entity name has been updated"
);
SELECT
acl
INTO
@
x
FROM
entities
WHERE
name
=
"NewEntityName"
;
SELECT
tap
.
eq
(
@
x
,
@
ACLID2
,
"acl has been updated"
);
-- TEST deleteEntityProperties
CALL
deleteEntityProperties
(
@
EntityID
);
SELECT
COUNT
(
*
)
INTO
@
x
FROM
null_data
;
SELECT
tap
.
eq
(
@
x
,
0
,
"data removed from null_data table"
);
-- TEST deleteEntity
CALL
deleteEntity
(
@
EntityID
);
CALL
deleteEntity
(
@
PropID
);
SELECT
COUNT
(
id
)
INTO
@
x
FROM
entities
WHERE
id
>
100
;
SELECT
tap
.
eq
(
@
x
,
0
,
"entity deleted"
);
-- TESTS END
CALL
tap
.
finish
();
ROLLBACK
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment