Skip to content

Commit 0dc720b

Browse files
committed
Fix test_run_action output check
1 parent e34d2ca commit 0dc720b

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

tests/integration/test_unit.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ async def run_action(unit):
116116
# wait for the action to complete
117117
return await action.wait()
118118

119+
def check_results(results, out):
120+
assert 'dir' in results
121+
assert 'stdout' in results or 'Stdout' in results
122+
assert 'Code' in results or 'return-code' in results
123+
if 'Code' in results:
124+
assert results['Code'] == 0
125+
else:
126+
assert results['return-code'] == 0
127+
128+
if 'stdout' in results:
129+
assert results['stdout'] == out
130+
else:
131+
assert results['Stdout'] == out
132+
assert results['dir'] == '/var/git/myrepo.git'
133+
119134
async with base.CleanModel() as model:
120135
app = await model.deploy(
121136
'git',
@@ -126,23 +141,13 @@ async def run_action(unit):
126141

127142
for unit in app.units:
128143
action = await run_action(unit)
129-
assert action.results == {
130-
'Code': '0',
131-
'Stdout': "Adding group `myrepo' (GID 1001) ...\n"
132-
'Done.\n'
133-
'Initialized empty Git repository in '
134-
'/var/git/myrepo.git/\n',
135-
'dir': '/var/git/myrepo.git',
136-
}
137-
out = await model.get_action_output(action.entity_id, wait=5)
138-
assert out == {
139-
'Code': '0',
140-
'Stdout': "Adding group `myrepo' (GID 1001) ...\n"
141-
'Done.\n'
142-
'Initialized empty Git repository in '
143-
'/var/git/myrepo.git/\n',
144-
'dir': '/var/git/myrepo.git',
145-
}
144+
out = "Adding group `myrepo' (GID 1001) ...\n" \
145+
'Done.\n' \
146+
'Initialized empty Git repository in ' \
147+
'/var/git/myrepo.git/\n'
148+
check_results(action.results, out)
149+
output = await model.get_action_output(action.entity_id, wait=5)
150+
check_results(output, out)
146151
status = await model.get_action_status(
147152
uuid_or_prefix=action.entity_id)
148153
assert status[action.entity_id] == 'completed'

0 commit comments

Comments
 (0)