summaryrefslogtreecommitdiff
path: root/lib/configuration/tests/errors.t
blob: 58c15ed660a4878104d0ebd0a7df30851dbe59e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Differents invalid configuration. All of them shall report the error properly

Every content shall have an identifier

  $ tests --configuration <<EOF
  > {
  >   "content": [
  >     {
  >       "key": "",
  >     }
  >   ]
  > }
  > EOF
  in field "content":
    while decoding a list:
      element 0:
        Expected an object with an attribute "id", but got { "key": "" } 
 
The content ID cannot be empty:

  $ tests --configuration <<EOF
  > {
  >   "content": [
  >     {
  >       "id": "",
  >     }
  >   ]
  > }
  > EOF
  in field "content":
    while decoding a list:
      element 0: in field "id": Expected a non empty identifier, but got "" 

The content ID cannot be contains "." (this charater is used internaly):

  $ tests --configuration <<EOF
  > {
  >   "content": [
  >     {
  >       "id": "foo.bar",
  >     }
  >   ]
  > }
  > EOF
  in field "content":
    while decoding a list:
      element 0:
        in field "id":
          Expected an identifier with only the accepted characters, but got
          "foo.bar" 

A reference shall point to an existing content:

  $ tests --configuration <<EOF
  > {
  >   "content": [
  >     {
  >       "id": "content",
  >       "section": [
  >         {
  >           "field": [
  >             {
  >               "name": "name",
  >               "label": {},
  >               "type": {
  >                 "content": "yes_no"
  >               }
  >             }
  >           ]
  >         }
  >       ]
  >     }
  >   ]
  > }
  > EOF
  Undefined target "yes_no". Expected existing list or content, but got
  { "content": "yes_no" }

Cycles between required content are not accepted

  $ tests --configuration <<EOF
  > {
  >   "content": [
  >     {
  >       "id": "entity",
  >       "section": [
  >         {
  >           "field": [
  >             {
  >               "name": "user_type",
  >               "label": {},
  >               "required": true,
  >               "type": {
  >                 "content": "user",
  >                 "multivaluated": true,
  >               }
  >             }
  >           ]
  >         }
  >       ]
  >     },
  >     {
  >       "id": "user",
  >       "section": [
  >         {
  >           "field": [
  >             {
  >               "name": "entity",
  >               "label": {},
  >               "required": true,
  >               "type": { "content": "entity", }
  >             }
  >           ]
  >         }
  >       ]
  >     }
  >   ]
  > }
  Dependency circle found between: entity user