Files
sqlpage--sqlpage/tests/sql_test_files/it_works_fetch_post.sql
lovasoa e7951ee721 dynamic port choice
also: better error messages in tests
2025-05-26 00:46:04 +02:00

12 lines
642 B
SQL

set url = 'http://localhost:' || $echo_port || '/post';
set fetch_request = '{"method": "POST", "url": "' || $url || '", "headers": {"x-custom": "1"}, "body": {"hello": "world"}}';
set res = sqlpage.fetch($fetch_request);
set expected = 'POST /post|accept-encoding: br, gzip, deflate, zstd|content-length: 18|content-type: application/json|host: localhost:' || $echo_port || '|user-agent: sqlpage|x-custom: 1|{"hello": "world"}';
select 'text' as component,
case $res
when $expected then 'It works !'
else 'It failed ! Expected:
' || COALESCE($expected, 'null') || '
Got:
' || COALESCE($res, 'null')
end as contents;