@@ -251,6 +251,48 @@ def test_build_dependabot_file_with_docker(self):
251
251
result = build_dependabot_file (repo , False , [], None )
252
252
self .assertEqual (result , expected_result )
253
253
254
+ def test_build_dependabot_file_with_terraform_with_files (self ):
255
+ """Test that the dependabot.yml file is built correctly with Terraform"""
256
+ repo = MagicMock ()
257
+ response = MagicMock ()
258
+ response .status_code = 404
259
+ repo .file_contents .side_effect = github3 .exceptions .NotFoundError (resp = response )
260
+ repo .directory_contents .side_effect = lambda path : (
261
+ [("main.tf" , None )] if path == "/" else []
262
+ )
263
+
264
+ expected_result = """---
265
+ version: 2
266
+ updates:
267
+ - package-ecosystem: 'terraform'
268
+ directory: '/'
269
+ schedule:
270
+ interval: 'weekly'
271
+ """
272
+ result = build_dependabot_file (repo , False , [], None )
273
+ self .assertEqual (result , expected_result )
274
+
275
+ def test_build_dependabot_file_with_terraform_without_files (self ):
276
+ """Test that the dependabot.yml file is built correctly with Terraform"""
277
+ repo = MagicMock ()
278
+ response = MagicMock ()
279
+ response .status_code = 404
280
+ repo .file_contents .side_effect = github3 .exceptions .NotFoundError (resp = response )
281
+
282
+ # Test absence of Terraform files
283
+ repo .directory_contents .side_effect = lambda path : [] if path == "/" else []
284
+ result = build_dependabot_file (repo , False , [], None )
285
+ self .assertIsNone (result )
286
+
287
+ # Test empty repository
288
+ response = MagicMock ()
289
+ response .status_code = 404
290
+ repo .directory_contents .side_effect = github3 .exceptions .NotFoundError (
291
+ resp = response
292
+ )
293
+ result = build_dependabot_file (repo , False , [], None )
294
+ self .assertIsNone (result )
295
+
254
296
def test_build_dependabot_file_with_groups (self ):
255
297
"""Test that the dependabot.yml file is built correctly with grouped dependencies"""
256
298
repo = MagicMock ()
0 commit comments