comparison spec/util_datamapper_spec.lua @ 12818:74ed772ff5fb

util.datamapper: Simplify test schema Don't need the function, more compact to just reference the same reference table.
author Kim Alvefur <zash@zash.se>
date Tue, 20 Dec 2022 18:55:47 +0100
parents a9dbf657c894
children
comparison
equal deleted inserted replaced
12817:176fd3ea505c 12818:74ed772ff5fb
13 local s, x, d 13 local s, x, d
14 local disco, disco_info, disco_schema 14 local disco, disco_info, disco_schema
15 setup(function() 15 setup(function()
16 16
17 -- a convenience function for simple attributes, there's a few of them 17 -- a convenience function for simple attributes, there's a few of them
18 local function attr() return {["$ref"]="#/$defs/attr"} end 18 local attr = {["$ref"]="#/$defs/attr"};
19 s = { 19 s = {
20 ["$defs"] = { attr = { type = "string"; xml = { attribute = true } } }; 20 ["$defs"] = { attr = { type = "string"; xml = { attribute = true } } };
21 type = "object"; 21 type = "object";
22 xml = {name = "message"; namespace = "jabber:client"}; 22 xml = {name = "message"; namespace = "jabber:client"};
23 properties = { 23 properties = {
24 to = attr(); 24 to = attr;
25 from = attr(); 25 from = attr;
26 type = attr(); 26 type = attr;
27 id = attr(); 27 id = attr;
28 body = true; -- should be assumed to be a string 28 body = true; -- should be assumed to be a string
29 lang = {type = "string"; xml = {attribute = true; prefix = "xml"}}; 29 lang = {type = "string"; xml = {attribute = true; prefix = "xml"}};
30 delay = { 30 delay = {
31 type = "object"; 31 type = "object";
32 xml = {namespace = "urn:xmpp:delay"; name = "delay"}; 32 xml = {namespace = "urn:xmpp:delay"; name = "delay"};
33 properties = {stamp = attr(); from = attr(); reason = {type = "string"; xml = {text = true}}}; 33 properties = {stamp = attr; from = attr; reason = {type = "string"; xml = {text = true}}};
34 }; 34 };
35 state = { 35 state = {
36 type = "string"; 36 type = "string";
37 enum = { 37 enum = {
38 "active", 38 "active",
64 type = "array"; 64 type = "array";
65 items = { 65 items = {
66 xml = {name = "stanza-id"; namespace = "urn:xmpp:sid:0"}; 66 xml = {name = "stanza-id"; namespace = "urn:xmpp:sid:0"};
67 type = "object"; 67 type = "object";
68 properties = { 68 properties = {
69 id = attr(); 69 id = attr;
70 by = attr(); 70 by = attr;
71 }; 71 };
72 }; 72 };
73 }; 73 };
74 }; 74 };
75 }; 75 };
118 xml = { 118 xml = {
119 name = "iq"; 119 name = "iq";
120 namespace = "jabber:client" 120 namespace = "jabber:client"
121 }; 121 };
122 properties = { 122 properties = {
123 to = attr(); 123 to = attr;
124 from = attr(); 124 from = attr;
125 type = attr(); 125 type = attr;
126 id = attr(); 126 id = attr;
127 disco = { 127 disco = {
128 type = "object"; 128 type = "object";
129 xml = { 129 xml = {
130 name = "query"; 130 name = "query";
131 namespace = "http://jabber.org/protocol/disco#info" 131 namespace = "http://jabber.org/protocol/disco#info"