Skip to content

Commit c9388de

Browse files
committed
feat: http multiversion extension and pg_regress tests
1 parent 91a8313 commit c9388de

File tree

6 files changed

+253
-2
lines changed

6 files changed

+253
-2
lines changed

nix/ext/tests/http.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ self.inputs.nixpkgs.lib.nixos.runTest {
9898
requires = [ "postgresql-migrate.service" ];
9999
};
100100
};
101-
102101
};
103102
testScript =
104103
{ nodes, ... }:

nix/ext/versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"1.6": {
1010
"postgresql": [
1111
"15",
12-
"17"
12+
"17",
13+
"orioledb-17"
1314
],
1415
"hash": "sha256-C8eqi0q1dnshUAZjIsZFwa5FTYc7vmATF3vv2CReWPM="
1516
}

nix/tests/expected/http.out

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
-- Test for http extension
2+
-- Basic HTTP functionality tests
3+
-- Test basic HTTP GET request
4+
SELECT status FROM http_get('http://httpbingo.org/get');
5+
status
6+
--------
7+
200
8+
(1 row)
9+
10+
-- Test HTTP GET with headers
11+
SELECT status, content_type
12+
FROM http((
13+
'GET',
14+
'http://httpbingo.org/headers',
15+
ARRAY[http_header('User-Agent', 'pg_http_test')],
16+
NULL,
17+
NULL
18+
)::http_request);
19+
status | content_type
20+
--------+---------------------------------
21+
200 | application/json; charset=utf-8
22+
(1 row)
23+
24+
-- Test HTTP POST request with JSON body
25+
SELECT status FROM http_post(
26+
'http://httpbingo.org/post',
27+
'{"test": "data"}',
28+
'application/json'
29+
);
30+
status
31+
--------
32+
200
33+
(1 row)
34+
35+
-- Test HTTP PUT request
36+
SELECT status FROM http_put(
37+
'http://httpbingo.org/put',
38+
'{"update": "data"}',
39+
'application/json'
40+
);
41+
status
42+
--------
43+
200
44+
(1 row)
45+
46+
-- Test HTTP DELETE request
47+
SELECT status FROM http_delete('http://httpbingo.org/delete');
48+
status
49+
--------
50+
200
51+
(1 row)
52+
53+
-- Test HTTP PATCH request
54+
SELECT status FROM http_patch(
55+
'http://httpbingo.org/patch',
56+
'{"patch": "data"}',
57+
'application/json'
58+
);
59+
status
60+
--------
61+
200
62+
(1 row)
63+
64+
-- Test HTTP HEAD request
65+
SELECT status FROM http_head('http://httpbingo.org/get');
66+
status
67+
--------
68+
200
69+
(1 row)
70+
71+
-- Test response headers parsing
72+
WITH response AS (
73+
SELECT * FROM http_get('http://httpbingo.org/response-headers?Content-Type=text/plain')
74+
)
75+
SELECT
76+
status,
77+
content_type,
78+
headers IS NOT NULL as has_headers
79+
FROM response;
80+
status | content_type | has_headers
81+
--------+--------------+-------------
82+
200 | text/plain | t
83+
(1 row)
84+
85+
-- Test timeout handling (using a delay endpoint)
86+
-- This should complete successfully with reasonable timeout
87+
SELECT status FROM http((
88+
'GET',
89+
'http://httpbingo.org/delay/1',
90+
ARRAY[]::http_header[],
91+
'application/json',
92+
2000 -- 2 second timeout
93+
)::http_request);
94+
status
95+
--------
96+
200
97+
(1 row)
98+
99+
-- Test URL encoding
100+
SELECT status FROM http_get('http://httpbingo.org/anything?param=value%20with%20spaces&another=123');
101+
status
102+
--------
103+
200
104+
(1 row)
105+

nix/tests/expected/z_17_rum.out

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
This extension is excluded from oriole-17 because it uses an unsupported index type
3+
*/
4+
create schema v;
5+
create table v.test_rum(
6+
t text,
7+
a tsvector
8+
);
9+
create trigger tsvectorupdate
10+
before update or insert on v.test_rum
11+
for each row
12+
execute procedure
13+
tsvector_update_trigger(
14+
'a',
15+
'pg_catalog.english',
16+
't'
17+
);
18+
insert into v.test_rum(t)
19+
values
20+
('the situation is most beautiful'),
21+
('it is a beautiful'),
22+
('it looks like a beautiful place');
23+
create index rumidx on v.test_rum using rum (a rum_tsvector_ops);
24+
select
25+
t,
26+
round(a <=> to_tsquery('english', 'beautiful | place')) as rank
27+
from
28+
v.test_rum
29+
where
30+
a @@ to_tsquery('english', 'beautiful | place')
31+
order by
32+
a <=> to_tsquery('english', 'beautiful | place');
33+
t | rank
34+
---------------------------------+------
35+
it looks like a beautiful place | 8
36+
the situation is most beautiful | 16
37+
it is a beautiful | 16
38+
(3 rows)
39+
40+
drop schema v cascade;
41+
NOTICE: drop cascades to table v.test_rum

nix/tests/sql/http.sql

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
-- Test for http extension
2+
-- Basic HTTP functionality tests
3+
4+
-- Test basic HTTP GET request
5+
SELECT status FROM http_get('http://httpbingo.org/get');
6+
7+
-- Test HTTP GET with headers
8+
SELECT status, content_type
9+
FROM http((
10+
'GET',
11+
'http://httpbingo.org/headers',
12+
ARRAY[http_header('User-Agent', 'pg_http_test')],
13+
NULL,
14+
NULL
15+
)::http_request);
16+
17+
-- Test HTTP POST request with JSON body
18+
SELECT status FROM http_post(
19+
'http://httpbingo.org/post',
20+
'{"test": "data"}',
21+
'application/json'
22+
);
23+
24+
-- Test HTTP PUT request
25+
SELECT status FROM http_put(
26+
'http://httpbingo.org/put',
27+
'{"update": "data"}',
28+
'application/json'
29+
);
30+
31+
-- Test HTTP DELETE request
32+
SELECT status FROM http_delete('http://httpbingo.org/delete');
33+
34+
-- Test HTTP PATCH request
35+
SELECT status FROM http_patch(
36+
'http://httpbingo.org/patch',
37+
'{"patch": "data"}',
38+
'application/json'
39+
);
40+
41+
-- Test HTTP HEAD request
42+
SELECT status FROM http_head('http://httpbingo.org/get');
43+
44+
-- Test response headers parsing
45+
WITH response AS (
46+
SELECT * FROM http_get('http://httpbingo.org/response-headers?Content-Type=text/plain')
47+
)
48+
SELECT
49+
status,
50+
content_type,
51+
headers IS NOT NULL as has_headers
52+
FROM response;
53+
54+
-- Test timeout handling (using a delay endpoint)
55+
-- This should complete successfully with reasonable timeout
56+
SELECT status FROM http((
57+
'GET',
58+
'http://httpbingo.org/delay/1',
59+
ARRAY[]::http_header[],
60+
'application/json',
61+
2000 -- 2 second timeout
62+
)::http_request);
63+
64+
-- Test URL encoding
65+
SELECT status FROM http_get('http://httpbingo.org/anything?param=value%20with%20spaces&another=123');

nix/tests/sql/z_17_rum.sql

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
This extension is excluded from oriole-17 because it uses an unsupported index type
3+
*/
4+
create schema v;
5+
6+
create table v.test_rum(
7+
t text,
8+
a tsvector
9+
);
10+
11+
create trigger tsvectorupdate
12+
before update or insert on v.test_rum
13+
for each row
14+
execute procedure
15+
tsvector_update_trigger(
16+
'a',
17+
'pg_catalog.english',
18+
't'
19+
);
20+
21+
insert into v.test_rum(t)
22+
values
23+
('the situation is most beautiful'),
24+
('it is a beautiful'),
25+
('it looks like a beautiful place');
26+
27+
create index rumidx on v.test_rum using rum (a rum_tsvector_ops);
28+
29+
select
30+
t,
31+
round(a <=> to_tsquery('english', 'beautiful | place')) as rank
32+
from
33+
v.test_rum
34+
where
35+
a @@ to_tsquery('english', 'beautiful | place')
36+
order by
37+
a <=> to_tsquery('english', 'beautiful | place');
38+
39+
40+
drop schema v cascade;

0 commit comments

Comments
 (0)