Skip to content

Commit

Permalink
tests: Adjust tests for new set-env syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrelg committed Oct 28, 2022
1 parent fcaa08e commit 6932b21
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions main_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
import os
import tempfile
from asyncio import Semaphore
from copy import deepcopy
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -37,6 +39,17 @@
mock_http_client.delete.return_value = mock_response


@pytest.fixture(autouse=True)
def github_env():
"""
Create a GITHUB_ENV env value to mock the Github actions equivalent.
"""
temp = tempfile.NamedTemporaryFile()
os.environ['GITHUB_ENV'] = temp.name
yield
temp.close()


@pytest.mark.asyncio
async def test_list_org_package_version():
await list_org_package_versions(org_name='test', image_name=ImageName('test', 'test'), http_client=mock_http_client)
Expand Down Expand Up @@ -540,7 +553,7 @@ def json(self):


@pytest.mark.asyncio
async def test_outputs_are_set(mocker, capsys):
async def test_outputs_are_set(mocker):
mock_list_response = Mock()
mock_list_response.is_error = True
mock_list_response.status_code = 200
Expand Down Expand Up @@ -572,11 +585,12 @@ async def test_outputs_are_set(mocker, capsys):
'token': 'test',
}
)
captured = capsys.readouterr()
out = captured.out
with open(os.environ['GITHUB_ENV']) as f:
env_vars = f.readlines()[0]

for i in [
'::set-output name=needs-github-assistance::',
'::set-output name=deleted::',
'::set-output name=failed::',
'needs-github-assistance=',
'deleted=',
'failed=',
]:
assert i in out
assert i in env_vars

0 comments on commit 6932b21

Please # to comment.