From 4ce6d5eec701b9300f2723eb941e380556c62327 Mon Sep 17 00:00:00 2001 From: Zack Koppert Date: Fri, 31 May 2024 10:53:56 -0700 Subject: [PATCH] ci: Add test for GitHub Actions dependabot configuration Signed-off-by: Zack Koppert --- test_dependabot_file.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test_dependabot_file.py b/test_dependabot_file.py index 61bdc94..2fa2fed 100644 --- a/test_dependabot_file.py +++ b/test_dependabot_file.py @@ -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()