mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\gh_7980_test.py: Checked on 6.0.0.386
This commit is contained in:
parent
db036c1661
commit
19514b3aea
62
tests/bugs/gh_7980_test.py
Normal file
62
tests/bugs/gh_7980_test.py
Normal file
@ -0,0 +1,62 @@
|
||||
#coding:utf-8
|
||||
|
||||
"""
|
||||
ID: issue-7980
|
||||
ISSUE: https://github.com/FirebirdSQL/firebird/issues/7980
|
||||
TITLE: Option for GEN_UUID to generate v7 UUID
|
||||
DESCRIPTION:
|
||||
Test verifies:
|
||||
* ability to call function GEN_UUID() with argument (value = 7);
|
||||
* orderliness of generated UUID values according to requirements of v7.
|
||||
|
||||
UUID v7 values have prefix (first 13 bytes) which monotonically grows.
|
||||
If we generate some number of such UUIDs and write them into the table with integer PK
|
||||
then this PK and value of row_number()over(order by left(uuid_v7,13)) must be EQUAL
|
||||
for all records.
|
||||
Otherwise generated UUID does not match to v7 requirement.
|
||||
NOTES:
|
||||
[10.07.2024] pzotov
|
||||
Checked on 6.0.0.386
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from firebird.qa import *
|
||||
|
||||
init_script = f"""
|
||||
recreate table test (
|
||||
id int generated by default as identity constraint pk_test primary key
|
||||
,uuid_v7 varchar(36) unique
|
||||
);
|
||||
|
||||
recreate view v_check as
|
||||
with
|
||||
a as (
|
||||
select id, row_number()over(order by left(uuid_v7,13)) rn, uuid_v7 from test
|
||||
)
|
||||
select * from a where id <> rn
|
||||
;
|
||||
|
||||
insert into test(uuid_v7) select uuid_to_char(gen_uuid(7)) from rdb$types rows 50;
|
||||
commit;
|
||||
"""
|
||||
|
||||
db = db_factory(init=init_script)
|
||||
act = python_act('db')
|
||||
|
||||
expected_stdout = f"""
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=6.0')
|
||||
def test_1(act: Action, capsys):
|
||||
with act.db.connect() as con:
|
||||
cur = con.cursor()
|
||||
cur.execute('select 1 from v_check')
|
||||
violates_v7 = cur.fetchone()
|
||||
if violates_v7:
|
||||
print('SOME UUIDs DO NOT MEET UUID v7 REQUIREMENTS:')
|
||||
cur.execute('select id, uuid_v7 from v_check')
|
||||
act.print_data(cur)
|
||||
|
||||
act.expected_stdout = expected_stdout
|
||||
act.stdout = capsys.readouterr().out # must be EMPTY!
|
||||
assert act.clean_stdout == act.clean_expected_stdout
|
Loading…
Reference in New Issue
Block a user