test: Add a test case for #343
This commit is contained in:
parent
778b424b3d
commit
9d391bff7c
|
@ -33,7 +33,7 @@ jobs:
|
|||
- run: pre-commit run --all-files
|
||||
working-directory: ./bindings/python
|
||||
|
||||
test-stable:
|
||||
test-drafts:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -55,6 +55,27 @@ jobs:
|
|||
- run: cargo test --no-fail-fast --features ${{ matrix.draft }}
|
||||
working-directory: ./jsonschema
|
||||
|
||||
test-stable:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
name: Test (stable) on ${{ matrix.os}}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- run: cargo test --no-fail-fast
|
||||
working-directory: ./jsonschema
|
||||
|
||||
coverage:
|
||||
name: Run test coverage
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "./schema.json",
|
||||
"people": [
|
||||
{
|
||||
"forename": "David",
|
||||
"surname": "Flanagan",
|
||||
"email": "david@rawkode.dev",
|
||||
"employers": [
|
||||
"Pulumi"
|
||||
]
|
||||
}
|
||||
],
|
||||
"organizations": [
|
||||
{
|
||||
"name": "Pulumi"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"people": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "https://schema.rawkode.dev/person"
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
"rel": "collection",
|
||||
"href": "#/organizations/{id}",
|
||||
"templateRequired": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"organizations": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "https://schema.rawkode.dev/organization"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -237,4 +237,19 @@ mod tests {
|
|||
let schema = json!({"pattern": "\\u"});
|
||||
assert!(JSONSchema::compile(&schema).is_err())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_343() {
|
||||
let file = std::fs::File::open("schema.json").unwrap();
|
||||
let reader = std::io::BufReader::new(file);
|
||||
let schema = serde_json::from_reader(reader).unwrap();
|
||||
|
||||
let file = std::fs::File::open("instance.json").unwrap();
|
||||
let reader = std::io::BufReader::new(file);
|
||||
let instance = serde_json::from_reader(reader).unwrap();
|
||||
|
||||
let compiled = JSONSchema::compile(&schema).expect("A valid schema");
|
||||
let result = compiled.validate(&instance);
|
||||
assert!(result.is_ok())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue