def test_it_cannot_add_an_existing_git_module(): github_repository = MagicMock() content = github_repository.get_file_contents() content.decoded_content.decode.return_value = ('') puppetfile = Puppetfile(github_repository, 'env', sha='shasha', git_modules=[GIT_MODULE_APACHE]) with pytest.raises(ModuleAlreadyPresentException): puppetfile.add_git_module('apache', 'https://url/git/apache')
def test_it_add_a_git_module_to_the_puppetfile(): github_repository = MagicMock() content = github_repository.get_file_contents() content.decoded_content.decode.return_value = ('') puppetfile = Puppetfile(github_repository, 'env', sha='shasha', git_modules=[GIT_MODULE_NGINX]) assert puppetfile.git_modules == [GIT_MODULE_NGINX] puppetfile.add_git_module('apache', 'https://url/git/apache', reference_type='ref', reference='ed19f') assert GIT_MODULE_APACHE in puppetfile.git_modules github_repository.update_file.assert_called_once_with( "Puppetfile", "Puppetfile - Add git module apache", (f'{str(GIT_MODULE_NGINX)}' "mod 'apache',\n" " :git => 'https://url/git/apache',\n" " :ref => 'ed19f'\n"), "shasha")