Skip to content

Commit e32058b

Browse files
committed
Fully test schema and fix issues found
Test each sub-schema to ensure things work as expected, and fix the things that do not. Also port the tests from the pgxn-meta-validator project and fix the additional issues.
1 parent e1b1034 commit e32058b

17 files changed

+2381
-109
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ exclude = [ ".github", ".gitattributes", "target", ".vscode", ".gitignore" ]
1515
[dev-dependencies]
1616
boon = "0.6"
1717
serde_json = "1.0"
18+
19+
[dependencies]
20+
serde = { version = "1", features = ["derive"] }

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: test # Validate the JSON schema.
22
test:
3-
@cargo test -- --show-output
3+
@cargo test
44

55
.git/hooks/pre-commit:
66
@printf "#!/bin/sh\nmake lint\n" > $@

schema/v1/bugtracker.schema.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
"description": "An email address to which bug reports can be sent"
1717
}
1818
},
19-
"anyOf": [
20-
{ "required": ["web"] },
21-
{ "required": ["mailto"] },
22-
{ "required": ["web", "mailto"] }
23-
],
19+
"anyOf": [{ "required": ["web"] }, { "required": ["mailto"] }],
2420
"patternProperties": {
25-
"^[xX]_": {
21+
"^[xX]_.": {
2622
"description": "Custom key"
2723
}
2824
},

schema/v1/distribution.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"resources": { "$ref": "resources.schema.json" }
5252
},
5353
"patternProperties": {
54-
"^[xX]_": {
54+
"^[xX]_.": {
5555
"description": "Custom key"
5656
}
5757
},

schema/v1/extension.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"required": ["file", "version"],
2929
"patternProperties": {
30-
"^[xX]_": {
30+
"^[xX]_.": {
3131
"description": "Custom key"
3232
}
3333
},

schema/v1/meta-spec.schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"version": {
99
"type": "string",
1010
"pattern": "^1[.]0[.][[:digit:]]+$",
11-
"description": "The version of the PGXN Meta Spec against which the document was generated."
11+
"description": "The version of the PGXN Meta Spec against which the document was generated. Must be 1.0.x."
1212
},
1313
"url": {
1414
"type": "string",
@@ -18,7 +18,7 @@
1818
},
1919
"required": ["version"],
2020
"patternProperties": {
21-
"^[xX]_": {
21+
"^[xX]_.": {
2222
"description": "Custom key"
2323
}
2424
},

schema/v1/no_index.schema.json

+25-21
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,16 @@
77
"properties": {
88
"file": {
99
"description": "A list of relative paths to files. Paths **must be** specified with unix conventions.",
10-
"type": "array",
11-
"minItems": 1,
12-
"items": {
13-
"type": "string",
14-
"description": "Relative path in unix convention to a file to ignore.",
15-
"minLength": 1
16-
}
10+
"$ref": "#/$defs/fileList"
1711
},
1812
"directory": {
1913
"description": "A list of relative paths to directories. Paths **must be** specified with unix conventions.",
20-
"type": "array",
21-
"minItems": 1,
22-
"items": {
23-
"type": "string",
24-
"description": "Relative path in unix convention to a directory to ignore.",
25-
"minLength": 1
26-
}
14+
"$ref": "#/$defs/fileList"
2715
}
2816
},
29-
"anyOf": [
30-
{ "required": ["file"] },
31-
{ "required": ["directory"] },
32-
{ "required": ["file", "directory"] }
33-
],
17+
"anyOf": [{ "required": ["file"] }, { "required": ["directory"] }],
3418
"patternProperties": {
35-
"^[xX]_": {
19+
"^[xX]_.": {
3620
"description": "Custom key"
3721
}
3822
},
@@ -42,5 +26,25 @@
4226
"file": ["src/file.sql"],
4327
"directory": ["src/private"]
4428
}
45-
]
29+
],
30+
"$defs": {
31+
"fileList": {
32+
"oneOf": [
33+
{
34+
"type": "array",
35+
"minItems": 1,
36+
"items": {
37+
"type": "string",
38+
"description": "Relative path in unix convention to a file to ignore.",
39+
"minLength": 1
40+
}
41+
},
42+
{
43+
"type": "string",
44+
"description": "Relative path in unix convention to a file to ignore.",
45+
"minLength": 1
46+
}
47+
]
48+
}
49+
}
4650
}

schema/v1/prereq_phase.schema.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@
2323
}
2424
},
2525
"patternProperties": {
26-
"^[xX]_": {
26+
"^[xX]_.": {
2727
"description": "Custom key"
2828
}
2929
},
3030
"additionalProperties": false,
31-
"minProperties": 1,
32-
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
31+
"anyOf": [
32+
{ "required": ["requires"] },
33+
{ "required": ["recommends"] },
34+
{ "required": ["suggests"] },
35+
{ "required": ["conflicts"] }
36+
],
3337
"examples": [
3438
{
3539
"requires": {

schema/v1/prereqs.schema.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
"description": "The develop phase’s prereqs are extensions needed to work on the distribution’s source code as its maintainer does. These tools might be needed to build a release tarball, to run maintainer-only tests, or to perform other tasks related to developing new versions of the distribution."
2727
}
2828
},
29-
"minProperties": 1,
30-
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
29+
"anyOf": [
30+
{ "required": ["configure"] },
31+
{ "required": ["build"] },
32+
{ "required": ["test"] },
33+
{ "required": ["runtime"] },
34+
{ "required": ["develop"] }
35+
],
3136
"patternProperties": {
32-
"^[xX]_": {
37+
"^[xX]_.": {
3338
"description": "Custom key"
3439
}
3540
},

schema/v1/repository.schema.json

+4-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
},
1818
"type": {
1919
"type": "string",
20-
"format": "email",
21-
"description": "a lowercase string indicating the VCS used."
20+
"pattern": "^\\p{lower}+$",
21+
"description": "A lowercase string indicating the VCS used."
2222
}
2323
},
24-
"anyOf": [
25-
{ "required": ["url", "type"] },
26-
{ "required": ["web"] },
27-
{ "required": ["web", "url", "type"] }
28-
],
24+
"anyOf": [{ "required": ["url", "type"] }, { "required": ["web"] }],
2925
"patternProperties": {
30-
"^[xX]_": {
26+
"^[xX]_.": {
3127
"description": "Custom key"
3228
}
3329
},

schema/v1/resources.schema.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
"repository": { "$ref": "repository.schema.json" }
1515
},
1616
"patternProperties": {
17-
"^[xX]_": {
17+
"^[xX]_.": {
1818
"description": "Custom key"
1919
}
2020
},
2121
"additionalProperties": false,
22-
"minProperties": 1,
23-
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
22+
"anyOf": [
23+
{ "required": ["homepage"] },
24+
{ "required": ["bugtracker"] },
25+
{ "required": ["repository"] }
26+
],
2427
"examples": [
2528
{
2629
"homepage": "https://pgxn.org/",

spec.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ are valid in the [List](#List) representation:
349349
mozilla_1_0 | Mozilla Public License, Version 1.0
350350
mozilla_1_1 | Mozilla Public License, Version 1.1
351351
openssl | OpenSSL License
352-
perl_5 | The Perl 5 License (Artistic 1 & GPL 1 or later)
352+
perl_5 | The Perl 5 License (Artistic 1 & GPL 1 or later)
353353
postgresql | The PostgreSQL License
354354
qpl_1_0 | Q Public License, Version 1.0
355355
ssleay | Original SSLeay License

tests/corpus/v1/invalid.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"test":"no_version","error":"missing properties 'version'","meta":{"name":"pair","abstract":"A key/value pair data type","maintainer":"David E. Wheeler <[email protected]>","license":"postgresql","provides":{"pair":{"abstract":"A key/value pair data type","file":"sql/pair.sql","docfile":"doc/pair.md","version":"0.1.0"}},"meta-spec":{"version":"1.0.0","url":"https://pgxn.org/meta/spec.txt"}}}

tests/corpus/v1/valid.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"test":"howto1","meta":{"name":"pair","abstract":"A key/value pair data type","version":"0.1.0","maintainer":"David E. Wheeler <[email protected]>","license":"postgresql","provides":{"pair":{"abstract":"A key/value pair data type","file":"sql/pair.sql","docfile":"doc/pair.md","version":"0.1.0"}},"meta-spec":{"version":"1.0.0","url":"https://pgxn.org/meta/spec.txt"}}}
2+
{"test":"howto2","meta":{"name":"pair","abstract":"A key/value pair data type","description":"This library contains a single PostgreSQL extension, a key/value pair data type called “pair”, along with a convenience function for constructing key/value pairs.","version":"0.1.4","maintainer":["David E. Wheeler <[email protected]>"],"license":"postgresql","provides":{"pair":{"abstract":"A key/value pair data type","file":"sql/pair.sql","docfile":"doc/pair.md","version":"0.1.0"}},"resources":{"bugtracker":{"web":"https://github.com/theory/kv-pair/issues/"},"repository":{"url":"git://github.com/theory/kv-pair.git","web":"https://github.com/theory/kv-pair/","type":"git"}},"generated_by":"David E. Wheeler","meta-spec":{"version":"1.0.0","url":"https://pgxn.org/meta/spec.txt"},"tags":["variadic function","ordered pair","pair","key value","key value pair","data type"]}}
3+
{"test":"widget","meta":{"name":"widget","abstract":"Widget for PostgreSQL","description":"¿A widget is just thing thing, yoŭ know?","version":"0.2.5","maintainer":["David E. Wheeler <[email protected]>"],"license":{"PostgreSQL":"https://www.postgresql.org/about/licence"},"prereqs":{"runtime":{"requires":{"plpgsql":0,"PostgreSQL":"8.0.0"},"recommends":{"PostgreSQL":"8.4.0"}}},"provides":{"widget":{"file":"sql/widget.sql.in","version":"0.2.5"}},"resources":{"homepage":"http://widget.example.org/"},"generated_by":"theory","meta-spec":{"version":"1.0.0","url":"https://pgxn.org/meta/spec.txt"},"tags":["widget","gadget","full text search"]}}

tests/test.rs

-59
This file was deleted.

0 commit comments

Comments
 (0)