Skip to content

Commit b18aa27

Browse files
committed
Add asserts, use httpyac
1 parent 0cf0f8d commit b18aa27

2 files changed

Lines changed: 56 additions & 2 deletions

File tree

.github/workflows/build-and-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: |
3939
docker compose up --no-build --pull never -d
4040
sleep 5s
41-
npx rest-cli calls.http --show headers
41+
npx -y httpyac calls.http --all --output short --output-failed exchange
4242
docker compose down
4343
- name: Build all images
4444
run: |

calls.http

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,69 @@
22

33
### Index page
44
GET {{baseUrl}}/index.php
5+
?? status == 200
6+
?? header content-type == text/html; charset=UTF-8
7+
{{
8+
test.hasResponseBody();
9+
const assert = require('assert');
10+
test('response body has expected title', () => {
11+
assert(response.body.includes("<title>Full-Text RSS Feeds | from fivefilters.org</title>"));
12+
});
13+
}}
514

615

716
### Extract feed with max 1 article
817
GET {{baseUrl}}/makefulltextfeed.php
918
?url=sec%3A%2F%2Fwww.tagesschau.de%2Findex~rss2.xml
1019
&max=1
1120
&links=preserve
21+
?? status == 200
22+
?? header content-type == text/xml; charset=UTF-8
23+
{{
24+
test.hasResponseBody();
25+
const assert = require('assert');
26+
test('response body has expected content', () => {
27+
assert(response.body.includes("<link>https://www.tagesschau.de/</link>"));
28+
assert(response.body.includes('<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">'));
29+
});
30+
31+
const links = [];
32+
const re = /<link\b[^>]*>([\s\S]*?)<\/link>/gi;
33+
let m;
34+
while ((m = re.exec(response.body)) !== null) {
35+
links.push(m[1].trim());
36+
}
37+
test('response body has two links as expected', () => {
38+
assert(links.length === 2);
39+
$global.article=links[1];
40+
});
41+
}}
42+
1243

1344
### Extract article without images
1445
GET {{baseUrl}}/extract.php
15-
?url=https://en.wikipedia.org/wiki/Vincent_van_Gogh
46+
?url={{$global.article}}
1647
&images=0
48+
?? status == 200
49+
?? header content-type == application/json; charset=UTF-8
50+
?? body title exists
51+
?? body excerpt exists
52+
?? body date exists
53+
?? body author exists
54+
?? body language exists
55+
?? body url exists
56+
?? body effective_url exists
57+
?? body domain exists
58+
?? body word_count exists
59+
?? body og_url exists
60+
?? body og_title exists
61+
?? body og_description exists
62+
?? body og_image exists
63+
?? body og_type exists
64+
?? body twitter_card exists
65+
?? body twitter_site exists
66+
?? body twitter_creator exists
67+
?? body twitter_title exists
68+
?? body twitter_description exists
69+
?? body content exists
70+
?? js response.parsedBody.content.length > 100

0 commit comments

Comments
 (0)