Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
lubennikovaav committed Sep 17, 2024
1 parent ab590d1 commit 0122201
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion test_runner/regress/test_extensions_stats.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from logging import info

from fixtures.neon_fixtures import NeonEnv


# basic test for the endpoint that returns the list of installed extensions
def test_extensions_stats(neon_simple_env: NeonEnv):
env = neon_simple_env
env.neon_cli.create_branch("test_extensions_stats", "empty")

endpoint = env.endpoints.create_start("test_extensions_stats")
endpoint.safe_psql("CREATE DATABASE test_extensions_stats")
endpoint.safe_psql("CREATE DATABASE test_extensions_stats_2")

client = endpoint.http_client()
res = client.extensions()
Expand All @@ -28,12 +31,40 @@ def test_extensions_stats(neon_simple_env: NeonEnv):
with pg_conn.cursor() as cur:
cur.execute("CREATE EXTENSION neon_test_utils")

with pg_conn.cursor() as cur:
cur.execute("CREATE EXTENSION neon version '1.1'")

pg_conn_2 = endpoint.connect(dbname="test_extensions_stats_2")
with pg_conn_2.cursor() as cur:
cur.execute("CREATE EXTENSION neon version '1.2'")

res = client.extensions()

info("Extensions list: %s", res)
info("Extensions: %s", res["extensions"])

# check that the neon_test_utils extension is installed
assert any(
ext["extname"] == "neon_test_utils" and ext["highest_version"] == "1.3" for ext in res["extensions"]
ext["extname"] == "neon_test_utils" and ext["highest_version"] == "1.3"
for ext in res["extensions"]
), "The 'neon_test_utils' extension is missing"

assert any(
ext["extname"] == "neon"
and ext["lowest_version"] == "1.1"
and ext["highest_version"] == "1.2"
for ext in res["extensions"]
), "The 'neon' extension is missing"

with pg_conn.cursor() as cur:
cur.execute("ALTER EXTENSION neon UPDATE TO '1.3'")

res = client.extensions()

info("Extensions list: %s", res)
info("Extensions: %s", res["extensions"])

# check that the neon_test_utils extension is installed
assert any(
ext["extname"] == "neon" and ext["highest_version"] == "1.3" for ext in res["extensions"]
), "The 'neon' extension is missing"

0 comments on commit 0122201

Please sign in to comment.