chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import sqlalchemy
|
||||
import psycopg2
|
||||
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy import text
|
||||
|
||||
import sys
|
||||
|
||||
QUERY_RESPONSE = [
|
||||
{"create table test (pk int, \"value\" int, primary key(pk))": []},
|
||||
{"describe test": [
|
||||
('pk', 'integer', 'NO', 'PRI', None, ''),
|
||||
('value', 'integer', 'YES', '', None, '')
|
||||
]},
|
||||
{"insert into test (pk, value) values (0,0)": ()},
|
||||
{"select * from test": [(0, 0)]},
|
||||
{"select dolt_add('-A');": [(['0'],)]},
|
||||
{"select dolt_commit('-m', 'my commit')": [('',)]},
|
||||
{"select COUNT(*) FROM dolt_log": [(3,)]},
|
||||
{"select dolt_checkout('-b', 'mybranch')": [(['0', "Switched to branch 'mybranch'"],)]},
|
||||
{"insert into test (pk, value) values (1,1)": []},
|
||||
{"select dolt_commit('-a', '-m', 'my commit2')": [('',)]},
|
||||
{"select dolt_checkout('main')": [(['0', "Switched to branch 'main'"],)]},
|
||||
{"select dolt_merge('mybranch')": [('',1,0,)]},
|
||||
{"select COUNT(*) FROM dolt_log": [(4,)]},
|
||||
]
|
||||
|
||||
|
||||
def main():
|
||||
user = sys.argv[1]
|
||||
port = int(sys.argv[2])
|
||||
|
||||
conn_string_base = "postgresql+psycopg2://"
|
||||
|
||||
engine = create_engine(conn_string_base +
|
||||
"{user}:password@127.0.0.1:{port}/postgres".format(user=user,
|
||||
port=port)
|
||||
)
|
||||
|
||||
with engine.connect() as con:
|
||||
for query_response in QUERY_RESPONSE:
|
||||
query = list(query_response.keys())[0]
|
||||
exp_results = query_response[query]
|
||||
|
||||
result_proxy = con.execute(text(query))
|
||||
|
||||
try:
|
||||
results = result_proxy.fetchall()
|
||||
if (results != exp_results) and ("dolt_commit" not in query) and ("dolt_merge" not in query):
|
||||
print("Query:")
|
||||
print(query)
|
||||
print("Expected:")
|
||||
print(exp_results)
|
||||
print("Received:")
|
||||
print(results)
|
||||
sys.exit(1)
|
||||
# You can't call fetchall on an insert
|
||||
# so we'll just ignore the exception
|
||||
except sqlalchemy.exc.ResourceClosedError:
|
||||
pass
|
||||
|
||||
con.close()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user