Skip to content

Commit 9f2db88

Browse files
committed
fix ci
1 parent 66a0db5 commit 9f2db88

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

system_tests/test_basic_validation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def test_extension_files_exist():
2424
required_files = [
2525
f'{base_path}/extension_sql/pg_retry.sql',
2626
f'{base_path}/extension_sql/pg_retry--1.0.0.sql',
27-
f'{base_path}/extension_sql/pg_retry--1.0.sql',
2827
f'{base_path}/src/pg_retry.c',
2928
f'{base_path}/pg_retry.control',
3029
f'{base_path}/META.json',
@@ -169,7 +168,11 @@ def test_compilation():
169168
base_path = '..' if os.path.exists('../src/pg_retry.o') else '.'
170169
# Check that object files were created
171170
assert os.path.exists(f'{base_path}/src/pg_retry.o'), "C source not compiled (missing .o file)"
172-
assert os.path.exists(f'{base_path}/src/pg_retry.dylib'), "Extension not linked (missing .dylib file)"
171+
172+
# Check for platform-specific shared library (.so on Linux, .dylib on macOS)
173+
has_so = os.path.exists(f'{base_path}/src/pg_retry.so')
174+
has_dylib = os.path.exists(f'{base_path}/src/pg_retry.dylib')
175+
assert has_so or has_dylib, "Extension not linked (missing .so or .dylib file)"
173176

174177
print("✅ Compilation validation passed")
175178

system_tests/test_pgtap_integration.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77
import subprocess
88
import pytest
99
import os
10+
import psycopg
1011

1112

1213
@pytest.mark.pgtap
13-
def test_pgtap_setup_sql():
14+
def test_pgtap_setup_sql(pg_cluster):
1415
"""Run pgTAP setup.sql tests."""
1516
# Check if pgTAP is available by testing if we can create the extension and run a simple test
16-
check_result = subprocess.run(
17-
["psql", "-c", "CREATE EXTENSION IF NOT EXISTS pgtap; SELECT plan(1); SELECT pass('pgTAP is working'); SELECT * FROM finish();"],
18-
capture_output=True,
19-
text=True,
20-
timeout=10
21-
)
22-
23-
assert check_result.returncode == 0, f"pgTAP not available - pgTAP tests require pgTAP to be installed. Error: {check_result.stderr}"
17+
with psycopg.connect(pg_cluster.dsn()) as conn:
18+
try:
19+
conn.execute("CREATE EXTENSION IF NOT EXISTS pgtap")
20+
result = conn.execute("SELECT plan(1)")
21+
conn.execute("SELECT pass('pgTAP is working')")
22+
conn.execute("SELECT * FROM finish()")
23+
except psycopg.Error as e:
24+
pytest.fail(f"pgTAP not available - pgTAP tests require pgTAP to be installed. Error: {e}")
2425

2526
# Change to pgtap directory
2627
old_cwd = os.getcwd()
@@ -29,12 +30,17 @@ def test_pgtap_setup_sql():
2930
try:
3031
os.chdir(pgtap_dir)
3132

33+
# Set up environment for run_tests.sh to use the test cluster
34+
env = pg_cluster.client_env()
35+
env["PGDATABASE"] = pg_cluster.database
36+
3237
# Run the existing run_tests.sh script
3338
result = subprocess.run(
3439
["./run_tests.sh"],
3540
capture_output=True,
3641
text=True,
37-
timeout=60 # 60 second timeout
42+
timeout=60, # 60 second timeout
43+
env=env
3844
)
3945

4046
# Check that pgTAP ran successfully
@@ -52,15 +58,9 @@ def test_pgtap_setup_sql():
5258

5359

5460
@pytest.mark.pgtap
55-
def test_pgtap_basic_functionality():
61+
def test_pgtap_basic_functionality(pg_cluster):
5662
"""Test that pgTAP can run basic tests."""
5763
# Simple test to verify pgTAP is working
58-
result = subprocess.run(
59-
["psql", "-c", "SELECT 1 as test;"],
60-
capture_output=True,
61-
text=True,
62-
timeout=10
63-
)
64-
65-
assert result.returncode == 0, f"Basic psql test failed: {result.stderr}"
66-
assert "1" in result.stdout, f"Unexpected psql output: {result.stdout}"
64+
with psycopg.connect(pg_cluster.dsn()) as conn:
65+
result = conn.execute("SELECT 1 as test").fetchone()
66+
assert result[0] == 1, f"Unexpected query result: {result}"

0 commit comments

Comments
 (0)