|
@@ -139,7 +139,34 @@ async def assert_sqls():
|
|
|
}
|
|
|
],
|
|
|
)
|
|
|
- print(colored("all tests right!", 'green'))
|
|
|
+ await assert_sql(
|
|
|
+ """insert into tb1 values (1, 'foo');""",
|
|
|
+ [
|
|
|
+ {
|
|
|
+ "type": "insert",
|
|
|
+ "table_name": "tb1",
|
|
|
+ "values": [
|
|
|
+ {"type": "int", "value": 1},
|
|
|
+ {"type": "string", "value": "'foo'"},
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ await assert_sql(
|
|
|
+ """insert into tb1 values (2, 'foo', 'zxc', 1234.234);""",
|
|
|
+ [
|
|
|
+ {
|
|
|
+ "type": "insert",
|
|
|
+ "table_name": "tb1",
|
|
|
+ "values": [
|
|
|
+ {"type": "int", "value": 2},
|
|
|
+ {"type": "string", "value": "'foo'"},
|
|
|
+ {"type": "string", "value": "'zxc'"},
|
|
|
+ {"type": "float", "value": 1234.234},
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ )
|
|
|
|
|
|
|
|
|
async def on_modified(event):
|
|
@@ -156,7 +183,9 @@ async def on_modified(event):
|
|
|
await assert_sqls()
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
- print(datetime.now(), "-" * 40)
|
|
|
+ else:
|
|
|
+ print(datetime.now(), colored("all tests right!", "green"))
|
|
|
+
|
|
|
|
|
|
|
|
|
async def restart():
|
|
@@ -164,14 +193,10 @@ async def restart():
|
|
|
print("restart")
|
|
|
os.execl("/bin/python", Path(__file__).as_posix(), Path(__file__).as_posix())
|
|
|
|
|
|
- open("/tmp/restart-watch.sh", "w").write(
|
|
|
- f"kill {os.getpid()} && python {__file__}"
|
|
|
- )
|
|
|
- os.system(f"bash /tmp/restart-watch.sh")
|
|
|
-
|
|
|
|
|
|
async def watch_src():
|
|
|
async for changes in awatch("src"):
|
|
|
+ print(datetime.now(), "re run...")
|
|
|
await asyncio.wait_for(on_modified(changes), 20)
|
|
|
|
|
|
|