summaryrefslogtreecommitdiff
path: root/tests/files/fail/test_unique.yaml
diff options
context:
space:
mode:
authorJohan Fleury <jfleury@arcaik.net>2018-10-08 12:58:12 -0400
committerJohan Fleury <jfleury@arcaik.net>2018-10-08 12:58:12 -0400
commit735c78d3ecb695dd16cb37879880f522c4b29c72 (patch)
tree8bfb2ecbd0f03730efa1540cc65d8490b67e8ddd /tests/files/fail/test_unique.yaml
Import upstream version 1.7.0
Diffstat (limited to 'tests/files/fail/test_unique.yaml')
-rw-r--r--tests/files/fail/test_unique.yaml109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/files/fail/test_unique.yaml b/tests/files/fail/test_unique.yaml
new file mode 100644
index 0000000..0af5d7c
--- /dev/null
+++ b/tests/files/fail/test_unique.yaml
@@ -0,0 +1,109 @@
+---
+name: fail-unique-1
+desc: "NOTE: The reverse unique do not currently work proper # This will test the unique constraint but should fail"
+data:
+ - name: foo
+ email: admin@mail.com
+ groups:
+ - foo
+ - users
+ - admin
+ - foo
+ - name: bar
+ email: admin@mail.com
+ groups:
+ - admin
+ - users
+ - name: bar
+ email: baz@mail.com
+ groups:
+ - users
+schema:
+ type: seq
+ sequence:
+ - type: map
+ required: True
+ mapping:
+ name:
+ type: str
+ required: True
+ unique: True
+ email:
+ type: str
+ groups:
+ type: seq
+ sequence:
+ - type: str
+ unique: True
+errors:
+ - "Value 'bar' is not unique. Previous path: '/1/name'. Path: '/2/name'"
+ - "Value 'foo' is not unique. Previous path: '/0/groups/0'. Path: '/0/groups/3'"
+---
+name: fail-unique-2
+desc: unique constraint test with map
+schema:
+ type: seq
+ sequence:
+ - type: map
+ mapping:
+ "name":
+ unique: true
+ "age":
+ type: int
+data:
+ - name: foo
+ age: 10
+ - name: bar
+ age: 10
+ - age: 10
+ name: bar
+errors:
+ - "Value 'bar' is not unique. Previous path: '/1/name'. Path: '/2/name'"
+ ## Kwalify errors
+ # :value_notunique : 6:3:[/2/name] 'bar': is already used at '/1/name'.
+---
+name: fail-unique-3
+desc: unique constraint test with seq
+schema:
+ type: seq
+ sequence:
+ - type: str
+ unique: true
+data:
+ - foo
+ - ~
+ - bar
+ - ~
+ - bar
+errors:
+ - "Value 'bar' is not unique. Previous path: '/2'. Path: '/4'"
+ ## Kwalify errors
+ # :value_notunique : 5:1:[/4] 'bar': is already used at '/2'.
+---
+name: fail-unique-4
+desc: unique constraint and '<<' (merge)
+schema:
+ type: seq
+ sequence:
+ - type: map
+ mapping:
+ "name":
+ type: str
+ required: true
+ unique: true
+ "value":
+ type: any
+ required: true
+data:
+ - &a1
+ name: x1
+ value: 10
+ - <<: *a1
+ - <<: *a1 # wrong validation error
+ name: x3
+errors:
+ - "Value 'x1' is not unique. Previous path: '/0/name'. Path: '/1/name'"
+ # TODO: Possibly missing one error here...
+ ## Kwalify errors
+ # :value_notunique : 4:3:[/1/name] 'x1': is already used at '/0/name'.
+ # :value_notunique : 5:3:[/2/name] 'x1': is already used at '/0/name'.