Skip to content

Commit

Permalink
fix new test for sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnybod committed Jan 31, 2024
1 parent 112e633 commit 49ff3a3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions empire/test/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def test_update_dir_list(session_local, models, agent, main: MainMenu):


def test_update_dir_list_with_existing_joined_file(
session_local, models, agent, main: MainMenu
session_local, models, agent, main: MainMenu, empire_config
):
with session_local.begin() as db:
message = {
Expand Down Expand Up @@ -286,7 +286,7 @@ def test_update_dir_list_with_existing_joined_file(
download_path = Path("empire/test/avatar.png")
file.downloads.append(
models.Download(
location=download_path.absolute(),
location=str(download_path.absolute()),
filename=download_path.name,
size=download_path.stat().st_size,
)
Expand All @@ -299,8 +299,13 @@ def test_update_dir_list_with_existing_joined_file(
db, agent, "C:\\Users\\vinnybod\\Desktop\\test.txt"
)

assert file.id != file2.id
assert len(file2.downloads) == 0
if empire_config.database.use != "sqlite":
# sqlite reuses ids and apparently doesn't cascade the delete to the
# association table. This can result in files being linked to the wrong
# download after refreshing a directory for sqlite.
assert file.id != file2.id
assert len(file2.downloads) == 0

assert file.name == file2.name

db.query(models.AgentFile).delete()

0 comments on commit 49ff3a3

Please sign in to comment.