Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: only check part of schema. #153

Merged
merged 1 commit into from
Jun 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 4 additions & 43 deletions t/admin/schema.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,8 @@ __DATA__
=== TEST 1: get route schema
--- request
GET /apisix/admin/schema/route
--- response_body
{
"type": "object",
"properties": {
"methods": {
"type": "array",
"items": {
"description": "HTTP method",
"type": "string",
"enum": ["GET", "PUT", "POST", "DELETE"]
},
"uniqueItems": true
},
"plugins": {"type":"object"},
"upstream": {"type":"object","required":["nodes","type"],"additionalProperties":false,"properties":{"type":{"type":"string","enum":["chash","roundrobin"],"description":"algorithms of load balancing"},"nodes":{"type":"object","patternProperties":{".*":{"type":"integer","minimum":1,"description":"weight of node"}},"minProperties":1,"description":"nodes of upstream"},"key":{"type":"string","enum":["remote_addr"],"description":"the key of chash for dynamic load balancing"},"id":{"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]}}},
"uri": {
"type": "string"
},
"host": {
"type": "string",
"pattern": "^\\*?[0-9a-zA-Z-.]+$"
},
"remote_addr": {
"description": "client IP",
"type": "string",
"anyOf": [
{"pattern": "^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$"},
{"pattern": "^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/[0-9]{1,2}$"}
]
},
"service_id": {"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]},
"upstream_id": {"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]},
"id": {"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]} },
"anyOf": [
{"required": ["plugins", "uri"]},
{"required": ["upstream", "uri"]},
{"required": ["upstream_id", "uri"]},
{"required": ["service_id", "uri"]}
],
"additionalProperties": false
}
--- response_body eval
qr/"plugins": \{"type":"object"}/
--- no_error_log
[error]

Expand All @@ -62,8 +23,8 @@ GET /apisix/admin/schema/route
=== TEST 2: get service schema
--- request
GET /apisix/admin/schema/service
--- response_body
{"type":"object","additionalProperties":false,"anyOf":[{"required":["upstream"]},{"required":["upstream_id"]},{"required":["plugins"]}],"properties":{"upstream_id":{"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]},"upstream":{"type":"object","required":["nodes","type"],"additionalProperties":false,"properties":{"type":{"type":"string","enum":["chash","roundrobin"],"description":"algorithms of load balancing"},"nodes":{"type":"object","patternProperties":{".*":{"type":"integer","minimum":1,"description":"weight of node"}},"minProperties":1,"description":"nodes of upstream"},"key":{"type":"string","enum":["remote_addr"],"description":"the key of chash for dynamic load balancing"},"id":{"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]}}},"id":{"anyOf":[{"type":"string","pattern":"^[0-9]+$","maxLength":32,"minLength":1},{"type":"integer","minimum":1}]},"plugins":{"type":"object"}}}
--- response_body eval
qr/"upstream":\{"type":"object"/
--- no_error_log
[error]

Expand Down