mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-22 16:35:30 +01:00
testing: update testing with products table and cross join test
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
This commit is contained in:
@@ -11,7 +11,9 @@ proc evaluate_sql {sqlite_exec sql} {
|
||||
proc run_test {sqlite_exec sql expected_output} {
|
||||
set actual_output [evaluate_sql $sqlite_exec $sql]
|
||||
if {$actual_output ne $expected_output} {
|
||||
puts "Test FAILED: '$sql' returned '$actual_output'"
|
||||
puts "Test FAILED: '$sql'"
|
||||
puts "returned '$actual_output'"
|
||||
puts "expected '$expected_output'"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
@@ -33,11 +35,11 @@ do_execsql_test select-const-2 {
|
||||
|
||||
do_execsql_test select-avg {
|
||||
SELECT avg(age) FROM users;
|
||||
} {50.4649}
|
||||
} {50.396}
|
||||
|
||||
do_execsql_test select-sum {
|
||||
SELECT sum(age) FROM users;
|
||||
} {504649}
|
||||
} {503960}
|
||||
|
||||
do_execsql_test select-limit {
|
||||
SELECT id FROM users LIMIT 1;
|
||||
@@ -62,3 +64,8 @@ do_execsql_test select-limit-0 {
|
||||
do_execsql_test pragma-cache-size {
|
||||
PRAGMA cache_size
|
||||
} {-2000}
|
||||
|
||||
|
||||
do_execsql_test cross-join {
|
||||
select * from users, products limit 1;
|
||||
} {1|Jamie|Foster|dylan00@example.com|496-522-9493|62375\ Johnson\ Rest\ Suite\ 322|West\ Lauriestad|IL|35865|94|1|hat|79}
|
||||
|
||||
@@ -22,6 +22,17 @@ cursor.execute('''
|
||||
)
|
||||
''')
|
||||
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS products (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT,
|
||||
price REAL
|
||||
)
|
||||
''')
|
||||
|
||||
product_list = ["hat", "cap", "shirt", "sweater", "sweatshirt",
|
||||
"shorts", "jeans", "sneakers", "boots", "coat", "accessories"]
|
||||
|
||||
fake = Faker()
|
||||
for _ in range(10000):
|
||||
first_name = fake.first_name()
|
||||
@@ -39,6 +50,13 @@ for _ in range(10000):
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''', (first_name, last_name, email, phone_number, address, city, state, zipcode, age))
|
||||
|
||||
for product in product_list:
|
||||
price = fake.random_int(min=1, max=100)
|
||||
cursor.execute('''
|
||||
INSERT INTO products (name, price)
|
||||
VALUES (?, ?)
|
||||
''', (product, price))
|
||||
|
||||
|
||||
|
||||
conn.commit()
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user