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 c09fdd0
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 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,16 @@
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.
"""
with tempfile.NamedTemporaryFile() as temp:
os.environ['GITHUB_ENV'] = temp.name
yield


@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 +552,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 +584,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 c09fdd0

Please # to comment.