mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge branch '2018.3' into 50542_mysql_ensure_verify_login_uses_connection_host
This commit is contained in:
commit
6d2309da50
@ -84,12 +84,18 @@ def downloaded(name, artifact, target_dir='/tmp', target_file=None, use_literal_
|
|||||||
'changes': {},
|
'changes': {},
|
||||||
'comment': ''}
|
'comment': ''}
|
||||||
|
|
||||||
try:
|
if 'test' in __opts__ and __opts__['test'] is True:
|
||||||
fetch_result = __fetch_from_artifactory(artifact, target_dir, target_file, use_literal_group_id)
|
fetch_result = {}
|
||||||
except Exception as exc:
|
fetch_result['status'] = True
|
||||||
ret['result'] = False
|
fetch_result['comment'] = 'Artifact would be downloaded from URL: {0}'.format(artifact['artifactory_url'])
|
||||||
ret['comment'] = six.text_type(exc)
|
fetch_result['changes'] = {}
|
||||||
return ret
|
else:
|
||||||
|
try:
|
||||||
|
fetch_result = __fetch_from_artifactory(artifact, target_dir, target_file, use_literal_group_id)
|
||||||
|
except Exception as exc:
|
||||||
|
ret['result'] = False
|
||||||
|
ret['comment'] = six.text_type(exc)
|
||||||
|
return ret
|
||||||
|
|
||||||
log.debug('fetch_result = %s', fetch_result)
|
log.debug('fetch_result = %s', fetch_result)
|
||||||
|
|
||||||
|
@ -55,3 +55,34 @@ class ArtifactoryTestCase(TestCase, LoaderModuleMockMixin):
|
|||||||
ret = artifactory.downloaded(name, artifact)
|
ret = artifactory.downloaded(name, artifact)
|
||||||
self.assertEqual(ret['result'], False)
|
self.assertEqual(ret['result'], False)
|
||||||
self.assertEqual(ret['comment'], 'error')
|
self.assertEqual(ret['comment'], 'error')
|
||||||
|
|
||||||
|
# 'downloaded test=True' function tests: 1
|
||||||
|
|
||||||
|
def test_downloaded_test_true(self):
|
||||||
|
'''
|
||||||
|
Test to ensures that the artifact from artifactory exists at
|
||||||
|
given location.
|
||||||
|
'''
|
||||||
|
name = 'jboss'
|
||||||
|
arti_url = 'http://artifactory.intranet.example.com/artifactory'
|
||||||
|
artifact = {'artifactory_url': arti_url, 'artifact_id': 'module',
|
||||||
|
'repository': 'libs-release-local', 'packaging': 'jar',
|
||||||
|
'group_id': 'com.company.module', 'classifier': 'sources',
|
||||||
|
'version': '1.0'}
|
||||||
|
|
||||||
|
ret = {'name': name,
|
||||||
|
'result': True,
|
||||||
|
'changes': {},
|
||||||
|
'comment': 'Artifact would be downloaded from URL: http://artifactory.intranet.example.com/artifactory'}
|
||||||
|
|
||||||
|
mck = MagicMock(return_value={'status': False, 'changes': {},
|
||||||
|
'comment': ''})
|
||||||
|
with patch.dict(artifactory.__salt__, {'artifactory.get_release': mck}):
|
||||||
|
with patch.dict(artifactory.__opts__, {'test': True}):
|
||||||
|
self.assertDictEqual(artifactory.downloaded(name, artifact), ret)
|
||||||
|
|
||||||
|
with patch.object(artifactory, '__fetch_from_artifactory',
|
||||||
|
MagicMock(side_effect=Exception('error'))):
|
||||||
|
ret = artifactory.downloaded(name, artifact)
|
||||||
|
self.assertEqual(ret['result'], False)
|
||||||
|
self.assertEqual(ret['comment'], 'error')
|
||||||
|
Loading…
Reference in New Issue
Block a user