Skip to content

Commit 32dd499

Browse files
authored
Merge pull request #157 from github/github-actions-tests
2 parents f4d83c1 + 4ce6d5e commit 32dd499

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test_dependabot_file.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,40 @@ def test_build_dependabot_file_with_terraform_without_files(self):
293293
result = build_dependabot_file(repo, False, [], None)
294294
self.assertIsNone(result)
295295

296+
def test_build_dependabot_file_with_github_actions(self):
297+
"""Test that the dependabot.yml file is built correctly with GitHub Actions"""
298+
repo = MagicMock()
299+
response = MagicMock()
300+
response.status_code = 404
301+
repo.file_contents.side_effect = github3.exceptions.NotFoundError(resp=response)
302+
repo.directory_contents.side_effect = lambda path: (
303+
[("test.yml", None)] if path == ".github/workflows" else []
304+
)
305+
306+
expected_result = """---
307+
version: 2
308+
updates:
309+
- package-ecosystem: 'github-actions'
310+
directory: '/'
311+
schedule:
312+
interval: 'weekly'
313+
"""
314+
result = build_dependabot_file(repo, False, [], None)
315+
self.assertEqual(result, expected_result)
316+
317+
def test_build_dependabot_file_with_github_actions_without_files(self):
318+
"""Test that the dependabot.yml file is None when no YAML files are found in the .github/workflows/ directory."""
319+
repo = MagicMock()
320+
response = MagicMock()
321+
response.status_code = 404
322+
repo.file_contents.side_effect = github3.exceptions.NotFoundError(resp=response)
323+
repo.directory_contents.side_effect = github3.exceptions.NotFoundError(
324+
resp=response
325+
)
326+
327+
result = build_dependabot_file(repo, False, [], None)
328+
self.assertEqual(result, None)
329+
296330
def test_build_dependabot_file_with_groups(self):
297331
"""Test that the dependabot.yml file is built correctly with grouped dependencies"""
298332
repo = MagicMock()

0 commit comments

Comments
 (0)