Skip to content

Commit

Permalink
Add a basic test for constraints using labels
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan committed Jul 27, 2020
1 parent 9e29687 commit eddf298
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_constraints.py
Expand Up @@ -1010,6 +1010,31 @@ async def test_constraints_ddl_08(self):
};
""")

async def test_constraints_ddl_09(self):
async with self._run_and_rollback():
await self.con.execute("""
CREATE TYPE test::Label {
CREATE PROPERTY text -> str;
};
CREATE TYPE test::ObjCnstr3 {
CREATE LINK label -> test::Label;
CREATE CONSTRAINT exclusive on (__subject__.label);
};
INSERT test::ObjCnstr3 {
label := (SELECT (INSERT test::Label {
text := "obj_test" }))
};
""")

with self.assertRaisesRegex(
edgedb.ConstraintViolationError,
"ObjCnstr3 violates exclusivity constraint"):
await self.con.execute("""
INSERT test::ObjCnstr3 {
label := (SELECT test::Label
FILTER .text = "obj_test" LIMIT 1) };
""")

async def test_constraints_ddl_function(self):
await self.con.execute('''\
CREATE FUNCTION test::comp_func(s: str) -> str {
Expand Down

0 comments on commit eddf298

Please sign in to comment.