Skip to content

Commit

Permalink
Merge pull request #9 from pablopalacios/supported-hardwares
Browse files Browse the repository at this point in the history
metadata: simplified supported-hardware metadata property
  • Loading branch information
otavio authored Jul 3, 2017
2 parents f1a18eb + 3936b38 commit 80f7ebd
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 124 deletions.
6 changes: 3 additions & 3 deletions pkgschema/schemas/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"type": "string",
"minLength": 1
},
"supported-hardware": {
"description": "A list of objects describing the update hardware targets",
"supported-hardwares": {
"description": "A list of strings describing the targeted hardwares. If not presentd, all hardwares are targeted",
"type": "array",
"items": {
"$ref": "supported-hardware.json"
"type": "string"
},
"minItems": 1,
"uniqueItems": true
Expand Down
23 changes: 0 additions & 23 deletions pkgschema/schemas/supported-hardware.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"target": "/dev/sda"
}
],
"supported-hardware": [1]
"supported-hardwares": []
}
5 changes: 5 additions & 0 deletions tests/schemas/fixtures/metadata/expected-document.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"product": "4cfebce216b03875300835de00f483e3de7b1c6f150e8dec7fa19a0d41c36722",
"version": "2.0",
"supported-hardwares": [
"hardware 1",
"hardware 2",
"hardware 3"
],
"objects": [
[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"target": "/dev/sda"
}
],
"supported-hardware": 1
"supported-hardwares": [1]
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"target": "/dev/sda"
}
],
"supported-hardware": []
"supported-hardwares": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@
"target": "/dev/sda"
}
],
"supported-hardware": [
{
"hardware": "Super Board",
"hardware-rev": "Rev. 1"
},
{
"hardware": "Super Board",
"hardware-rev": "Rev. 1"
}
"supported-hardwares": [
"Super Board",
"Super Board"
]
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

75 changes: 15 additions & 60 deletions tests/schemas/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1019,51 +1019,6 @@ runner "install-if-different custom-pattern with only required values is valid"
VALID


# SCHEMA: supported-hardware.json
runner "supported-hardware expected document is valid" \
supported-hardware.json \
supported-hardware/expected-document.json \
VALID

runner "supported-hardware with additional properties is invalid" \
supported-hardware.json \
supported-hardware/with-additional-properties.json \
INVALID \
"additionalProperties: Additional properties are not allowed ('extra' was unexpected)"

## PROPERTY: hardware
runner "supported-hardware hardware property is required" \
supported-hardware.json \
supported-hardware/without-hardware-property.json \
INVALID \
"required: 'hardware' is a required property"

runner "supported-hardware hardware type must be a string" \
supported-hardware.json \
supported-hardware/invalid-hardware-property-type.json \
INVALID \
"properties/hardware/type: 1 is not of type 'string'"

runner "supported-hardware empty hardware property is invalid" \
supported-hardware.json \
supported-hardware/empty-hardware-property.json \
INVALID \
"properties/hardware/minLength: '' is too short"

## PROPERTY: hardware-rev
runner "supported-hardware hardware-rev property type must be a string" \
supported-hardware.json \
supported-hardware/invalid-hardware-rev-property-type.json \
INVALID \
"properties/hardware-rev/type: 1 is not of type 'string'"

runner "supported-hardware empty hardware-rev property is invalid" \
supported-hardware.json \
supported-hardware/empty-hardware-rev-property.json \
INVALID \
"properties/hardware-rev/minLength: '' is too short"


# SCHEMA: metadata.json
runner "metadata expected document is valid" \
metadata.json \
Expand Down Expand Up @@ -1117,35 +1072,35 @@ runner "metadata empty version is invalid" \
INVALID \
"properties/version/minLength: '' is too short"

## PROPERTY: supported-hardware
runner "metadata supported-hardware property is not required" \
## PROPERTY: supported-hardwares
runner "metadata supported-hardwares property is not required" \
metadata.json \
metadata/without-supported-hardware-property.json \
metadata/without-supported-hardwares-property.json \
VALID

runner "metadata supported-hardware property type must be an array" \
runner "metadata supported-hardwares property type must be an array" \
metadata.json \
metadata/invalid-supported-hardware-type.json \
metadata/invalid-supported-hardwares-type.json \
INVALID \
"properties/supported-hardware/type: 1 is not of type 'array'"
"properties/supported-hardwares/type: 1 is not of type 'array'"

runner "metadata empty supported-hardware property is invalid" \
runner "metadata empty supported-hardwares property is invalid" \
metadata.json \
metadata/empty-supported-hardware-property.json \
metadata/empty-supported-hardwares-property.json \
INVALID \
"properties/supported-hardware/minItems: [] is too short"
"properties/supported-hardwares/minItems: [] is too short"

runner "metadata supported-hardware items type must be an object" \
runner "metadata supported-hardwares items type must be an string" \
metadata.json \
metadata/invalid-supported-hardware-item-type.json \
metadata/invalid-supported-hardwares-item-type.json \
INVALID \
"properties/supported-hardware/items/type: 1 is not of type 'object'"
"properties/supported-hardwares/items/type: 1 is not of type 'string'"

runner "metadata supported-hardware items must be unique" \
runner "metadata supported-hardwares items must be unique" \
metadata.json \
metadata/repeated_supported_hardware.json \
metadata/repeated-supported-hardwares-items.json \
INVALID \
"properties/supported-hardware/uniqueItems: [OrderedDict([('hardware', 'Super Board'), ('hardware-rev', 'Rev. 1')]), OrderedDict([('hardware', 'Super Board'), ('hardware-rev', 'Rev. 1')])] has non-unique elements"
"properties/supported-hardwares/uniqueItems: ['Super Board', 'Super Board'] has non-unique elements"

## PROPERTY: objects
runner "metadata objects property is required" \
Expand Down

0 comments on commit 80f7ebd

Please sign in to comment.