Skip to content

Commit 949e45e

Browse files
committed
Add URL to badges
1 parent 620b785 commit 949e45e

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

schema/v2/badges.schema.json

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"minLength": 4,
1919
"maxLength": 4048,
2020
"description": "Alternate text for accessability."
21+
},
22+
"url": {
23+
"type": "string",
24+
"format": "uri",
25+
"description": "The URL the badge links to."
2126
}
2227
},
2328
"required": ["src", "alt"],

tests/v2_schema_test.rs

+38-6
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,7 @@ fn test_v2_badges() -> Result<(), Box<dyn Error>> {
21842184
json!([{
21852185
"src": "https://github.com/theory/kv-pair/workflows/CI/badge.svg",
21862186
"alt": "CI/CD Test Status",
2187+
"url": "https://github.com/theory/pgtap/actions/workflows/ci.yml"
21872188
}]),
21882189
),
21892190
(
@@ -2245,6 +2246,39 @@ fn test_v2_badges() -> Result<(), Box<dyn Error>> {
22452246
("alt null", json!([{"src": "x:y", "alt": null}])),
22462247
("alt empty", json!([{"src": "x:y", "alt": "xyz"}])),
22472248
("alt too short", json!([{"src": "x:y", "alt": "xyz"}])),
2249+
// url
2250+
(
2251+
"url array",
2252+
json!([{"src": "x:y", "alt": "abcd", "url": []}]),
2253+
),
2254+
(
2255+
"url object",
2256+
json!([{"src": "x:y", "alt": "abcd", "url": {}}]),
2257+
),
2258+
(
2259+
"url empty",
2260+
json!([{"src": "x:y", "alt": "abcd", "url": ""}]),
2261+
),
2262+
(
2263+
"url bool",
2264+
json!([{"src": "x:y", "alt": "abcd", "url": true}]),
2265+
),
2266+
(
2267+
"url number",
2268+
json!([{"src": "x:y", "alt": "abcd", "url": 42}]),
2269+
),
2270+
(
2271+
"url null",
2272+
json!([{"src": "x:y", "alt": "abcd", "url": null}]),
2273+
),
2274+
(
2275+
"url empty",
2276+
json!([{"src": "x:y", "alt": "abcd", "url": "xyz"}]),
2277+
),
2278+
(
2279+
"url too short",
2280+
json!([{"src": "x:y", "alt": "abcd", "url": "xyz"}]),
2281+
),
22482282
] {
22492283
if schemas.validate(&invalid.1, idx).is_ok() {
22502284
panic!("{} unexpectedly passed!", invalid.0)
@@ -2281,16 +2315,14 @@ fn test_v2_resources() -> Result<(), Box<dyn Error>> {
22812315
"support": "https://github.com/theory/pgtap",
22822316
"badges": [
22832317
{
2284-
"src": "https://camo.githubusercontent.com/6552afb9038154d801c50b6e55a76db78a6787a8d6e2b5252a44864503c52887/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667",
2285-
"alt": "MIT License",
2318+
"src": "https://img.shields.io/badge/License-PostgreSQL-blue.svg",
2319+
"alt": "PostgreSQL License",
2320+
"url": "https://www.postgresql.org/about/licence/"
22862321
},
22872322
{
22882323
"src": "https://github.com/theory/pgtap/actions/workflows/test.yml/badge.svg",
22892324
"alt": "Test Status",
2290-
},
2291-
{
2292-
"src": "https://camo.githubusercontent.com/20f036be4bac5e4326d17cfd98a55b7753a6619ce463ed7482f7a1bd98978135/68747470733a2f2f636f6465636f762e696f2f67682f74656d626f2d696f2f70672d6a736f6e736368656d612d626f6f6e2f67726170682f62616467652e7376673f746f6b656e3d44494645443332345a59",
2293-
"alt": "Code Coverage",
2325+
"url": "https://github.com/theory/pgtap/actions/workflows/ci.yml"
22942326
},
22952327
]
22962328
}),

0 commit comments

Comments
 (0)