fix: 已有数据库再次安装时接上原库而不是报错
This commit is contained in:
@@ -43,6 +43,21 @@ def client():
|
||||
shutil.rmtree(TEST_DATA)
|
||||
|
||||
|
||||
def test_install_again_uses_existing_database(client: TestClient):
|
||||
from app.config import install_file
|
||||
from app.db import reset_engine
|
||||
|
||||
install_file().unlink()
|
||||
reset_engine()
|
||||
again = client.post("/api/install", json={"sqlite": True, "adminUsername": "other", "adminPassword": "other-pass"})
|
||||
assert again.status_code == 200
|
||||
assert again.json()["already"] is True
|
||||
logged = client.post("/api/auth/local", json={"username": "admin", "password": "admin-pass"})
|
||||
assert logged.status_code == 200
|
||||
rejected = client.post("/api/auth/local", json={"username": "other", "password": "other-pass"})
|
||||
assert rejected.status_code == 400
|
||||
|
||||
|
||||
def test_period_bounds():
|
||||
assert check_period(1) == 1
|
||||
assert check_period(31) == 31
|
||||
|
||||
Reference in New Issue
Block a user