Skip to content

Commit

Permalink
Fully test schema and fix issues found
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
theory committed Jul 2, 2024
1 parent e1b1034 commit a9d3421
Show file tree
Hide file tree
Showing 17 changed files with 2,376 additions and 109 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ exclude = [ ".github", ".gitattributes", "target", ".vscode", ".gitignore" ]
[dev-dependencies]
boon = "0.6"
serde_json = "1.0"

[dependencies]
serde = { version = "1", features = ["derive"] }
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: test # Validate the JSON schema.
test:
@cargo test -- --show-output
@cargo test

.git/hooks/pre-commit:
@printf "#!/bin/sh\nmake lint\n" > $@
Expand Down
8 changes: 2 additions & 6 deletions schema/v1/bugtracker.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
"description": "An email address to which bug reports can be sent"
}
},
"anyOf": [
{ "required": ["web"] },
{ "required": ["mailto"] },
{ "required": ["web", "mailto"] }
],
"anyOf": [{ "required": ["web"] }, { "required": ["mailto"] }],
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand Down
2 changes: 1 addition & 1 deletion schema/v1/distribution.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"resources": { "$ref": "resources.schema.json" }
},
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand Down
2 changes: 1 addition & 1 deletion schema/v1/extension.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"required": ["file", "version"],
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand Down
4 changes: 2 additions & 2 deletions schema/v1/meta-spec.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"version": {
"type": "string",
"pattern": "^1[.]0[.][[:digit:]]+$",
"description": "The version of the PGXN Meta Spec against which the document was generated."
"description": "The version of the PGXN Meta Spec against which the document was generated. Must be 1.0.x."
},
"url": {
"type": "string",
Expand All @@ -18,7 +18,7 @@
},
"required": ["version"],
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand Down
46 changes: 25 additions & 21 deletions schema/v1/no_index.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,16 @@
"properties": {
"file": {
"description": "A list of relative paths to files. Paths **must be** specified with unix conventions.",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"description": "Relative path in unix convention to a file to ignore.",
"minLength": 1
}
"$ref": "#/$defs/fileList"
},
"directory": {
"description": "A list of relative paths to directories. Paths **must be** specified with unix conventions.",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"description": "Relative path in unix convention to a directory to ignore.",
"minLength": 1
}
"$ref": "#/$defs/fileList"
}
},
"anyOf": [
{ "required": ["file"] },
{ "required": ["directory"] },
{ "required": ["file", "directory"] }
],
"anyOf": [{ "required": ["file"] }, { "required": ["directory"] }],
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand All @@ -42,5 +26,25 @@
"file": ["src/file.sql"],
"directory": ["src/private"]
}
]
],
"$defs": {
"fileList": {
"oneOf": [
{
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"description": "Relative path in unix convention to a file to ignore.",
"minLength": 1
}
},
{
"type": "string",
"description": "Relative path in unix convention to a file to ignore.",
"minLength": 1
}
]
}
}
}
10 changes: 7 additions & 3 deletions schema/v1/prereq_phase.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
}
},
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
"additionalProperties": false,
"minProperties": 1,
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
"anyOf": [
{ "required": ["requires"] },
{ "required": ["recommends"] },
{ "required": ["suggests"] },
{ "required": ["conflicts"] }
],
"examples": [
{
"requires": {
Expand Down
11 changes: 8 additions & 3 deletions schema/v1/prereqs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@
"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."
}
},
"minProperties": 1,
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
"anyOf": [
{ "required": ["configure"] },
{ "required": ["build"] },
{ "required": ["test"] },
{ "required": ["runtime"] },
{ "required": ["develop"] }
],
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand Down
12 changes: 4 additions & 8 deletions schema/v1/repository.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@
},
"type": {
"type": "string",
"format": "email",
"description": "a lowercase string indicating the VCS used."
"pattern": "^\\p{lower}*$",
"description": "A lowercase string indicating the VCS used."
}
},
"anyOf": [
{ "required": ["url", "type"] },
{ "required": ["web"] },
{ "required": ["web", "url", "type"] }
],
"anyOf": [{ "required": ["url", "type"] }, { "required": ["web"] }],
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
Expand Down
9 changes: 6 additions & 3 deletions schema/v1/resources.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
"repository": { "$ref": "repository.schema.json" }
},
"patternProperties": {
"^[xX]_": {
"^[xX]_.": {
"description": "Custom key"
}
},
"additionalProperties": false,
"minProperties": 1,
"$comment": "Really should require at least one of the named properties; this allows for a single _x property. Good enough for now.",
"anyOf": [
{ "required": ["homepage"] },
{ "required": ["bugtracker"] },
{ "required": ["repository"] }
],
"examples": [
{
"homepage": "https://pgxn.org/",
Expand Down
2 changes: 1 addition & 1 deletion spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ are valid in the [List](#List) representation:
mozilla_1_0 | Mozilla Public License, Version 1.0
mozilla_1_1 | Mozilla Public License, Version 1.1
openssl | OpenSSL License
perl_5 | The Perl 5 License (Artistic 1 & GPL 1 or later)
perl_5 | The Perl 5 License (Artistic 1 & GPL 1 or later)
postgresql | The PostgreSQL License
qpl_1_0 | Q Public License, Version 1.0
ssleay | Original SSLeay License
Expand Down
1 change: 1 addition & 0 deletions tests/corpus/v1/invalid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"test":"no_version","error":"missing properties 'version'","meta":{"name":"pair","abstract":"A key/value pair data type","maintainer":"David E. Wheeler <david@justatheory.com>","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"}}}
3 changes: 3 additions & 0 deletions tests/corpus/v1/valid.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"test":"howto1","meta":{"name":"pair","abstract":"A key/value pair data type","version":"0.1.0","maintainer":"David E. Wheeler <david@justatheory.com>","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"}}}
{"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 <david@justatheory.com>"],"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"]}}
{"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 <theory@pgxn.org>"],"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"]}}
59 changes: 0 additions & 59 deletions tests/test.rs

This file was deleted.

Loading

0 comments on commit a9d3421

Please sign in to comment.