Skip to content

Commit

Permalink
Also fix tron schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jfongatyelp committed Dec 4, 2024
1 parent 0d26945 commit e94d9af
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions paasta_tools/cli/schemas/tron_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
"required": [
"command"
],
"allOf": [
{
"not": {
"required": [
"service_account_name",
"iam_role"
]
}
}
],
"properties": {
"name": {
"$ref": "#definitions/name"
Expand Down
34 changes: 34 additions & 0 deletions tests/cli/test_cmds_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,40 @@ def test_tron_validate_schema_iam_role(iam_role, expected, capsys):
assert expected_output in output


@pytest.mark.parametrize(
"iam_role, service_account_name, expected",
[
("arn:aws:iam::12345678:role/some_role", None, True),
("arn:aws:iam::12345678:role/some_role", "some_svc_account", False),
(None, "some_svc_account", True),
],
)
def test_tron_validate_schema_sa_and_iam_role(
iam_role,
service_account_name,
expected,
capsys,
):
tron_content = f"""
test_job:
node: paasta
schedule: "daily 04:00:00"
actions:
first:
{"iam_role: "+iam_role if iam_role else ""}
{"service_account_name: "+service_account_name if service_account_name else ""}
command: echo hello world
"""
with patch(
"paasta_tools.cli.cmds.validate.get_file_contents", autospec=True
) as mock_get_file_contents:
mock_get_file_contents.return_value = tron_content
assert validate_schema("unused_service_path.yaml", "tron") == expected
output, _ = capsys.readouterr()
expected_output = SCHEMA_VALID if expected else SCHEMA_INVALID
assert expected_output in output


@pytest.mark.parametrize(
"mock_content",
(
Expand Down

0 comments on commit e94d9af

Please sign in to comment.