summaryrefslogtreecommitdiff
path: root/lib/value/tests/load.t
blob: dee6d0f7511990d8352f790469d9dc4b83ddd102 (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
High level test of [Value.load]: two rows are inserted in the table of the
content given as argument (the configuration is read on the standard input),
loaded as values with [Value.load] and printed with [Value.pp] — the primary
key and every field, as read back as typed data with [Value.get]. The first row
is then loaded again with [~multivalued:false]: only the row itself is read, so
the multivalued field [aliases] is missing from the output.

  $ tests --load "entity" <<EOF
  > {
  >   "list": [
  >     {
  >       "id": "country_list",
  >       "field": [
  >         { "name": "code", "label": {}, "type": "text" }
  >       ]
  >     }
  >   ],
  >   "content": [
  >     {
  >       "id": "entity",
  >       "section": [
  >         {
  >           "field": [
  >             { "name": "name", "label": {}, "type": "text" },
  >             { "name": "year", "label": {}, "type": "integer" },
  >             { "name": "country", "label": {}, "type": { "content": "country_list" } },
  >             {
  >               "name": "aliases",
  >               "label": {},
  >               "type": { "content": "country_list", "multivaluated": true }
  >             }
  >           ]
  >         }
  >       ]
  >     }
  >   ]
  > }
  > EOF
  row 1:
  {id = 1; aliases = [1, 2]; country = 1; name = "name-1"; year = 1}
  row 2:
  {id = 2; aliases = [2]; country = 1; name = "name-2"; year = 2}
  row 1 (without multivalued fields):
  {id = 1; country = 1; name = "name-1"; year = 1}