Skip to content

Commit

Permalink
ensure test does not leave git status changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tarilabs committed Sep 4, 2023
1 parent 093cd05 commit c5aae62
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/e2e/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ def test_hot_reload():
stdout=subprocess.PIPE,
)

fin = open(rulebook, "rt")
original_data = fin.read()
fin.close()
found_rule_1_in_out = False
found_rule_2_in_out = False

Expand All @@ -261,13 +264,10 @@ def test_hot_reload():

assert found_rule_1_in_out

fin = open(rulebook, "rt")
data = fin.read()
data = data.replace('- action: "value_a"', '- action: "value_b"')
fin.close()
fin = open(rulebook, "wt")
fin.write(data)
fin.close()
data = original_data.replace('- action: "value_a"', '- action: "value_b"')
fout1 = open(rulebook, "wt")
fout1.write(data)
fout1.close()

start = time.time()
while line := process.stdout.readline():
Expand All @@ -277,5 +277,9 @@ def test_hot_reload():
time.sleep(0.1)
if time.time() - start > DEFAULT_CMD_TIMEOUT:
process.kill()

fout2 = open(rulebook, "wt")
fout2.write(original_data)
fout2.close()

assert found_rule_2_in_out

0 comments on commit c5aae62

Please sign in to comment.