Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add test for GitHub Actions dependabot configuration #157

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions test_dependabot_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,40 @@ def test_build_dependabot_file_with_terraform_without_files(self):
result = build_dependabot_file(repo, False, [], None)
self.assertIsNone(result)

def test_build_dependabot_file_with_github_actions(self):
"""Test that the dependabot.yml file is built correctly with GitHub Actions"""
repo = MagicMock()
response = MagicMock()
response.status_code = 404
repo.file_contents.side_effect = github3.exceptions.NotFoundError(resp=response)
repo.directory_contents.side_effect = lambda path: (
[("test.yml", None)] if path == ".github/workflows" else []
)

expected_result = """---
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
"""
result = build_dependabot_file(repo, False, [], None)
self.assertEqual(result, expected_result)

def test_build_dependabot_file_with_github_actions_without_files(self):
"""Test that the dependabot.yml file is None when no YAML files are found in the .github/workflows/ directory."""
repo = MagicMock()
response = MagicMock()
response.status_code = 404
repo.file_contents.side_effect = github3.exceptions.NotFoundError(resp=response)
repo.directory_contents.side_effect = github3.exceptions.NotFoundError(
resp=response
)

result = build_dependabot_file(repo, False, [], None)
self.assertEqual(result, None)

def test_build_dependabot_file_with_groups(self):
"""Test that the dependabot.yml file is built correctly with grouped dependencies"""
repo = MagicMock()
Expand Down