def setUp(self): """ We don't want to check in another .git dir into GH because that just gets messy. Instead, we'll create a temporary repo on the fly for the tests to examine. Also ensure we A) don't re-use the singleton, and B) that the cachedirs are cleared. This keeps these performance enhancements from affecting the results of subsequent tests. """ if not gitfs.__virtual__(): self.skipTest("GitFS could not be loaded. Skipping GitFS tests!") _clear_instance_map() for subdir in ("gitfs", "file_lists"): try: salt.utils.files.rm_rf(os.path.join(self.tmp_cachedir, subdir)) except OSError as exc: if exc.errno == errno.EACCES: log.warning( "Access error removeing file %s", os.path.join(self.tmp_cachedir, subdir), ) continue if exc.errno != errno.ENOENT: raise if salt.ext.six.PY3 and salt.utils.platform.is_windows(): self.setUpClass() self.setup_loader_modules()
def setUp(self): ''' We don't want to check in another .git dir into GH because that just gets messy. Instead, we'll create a temporary repo on the fly for the tests to examine. ''' if not gitfs.__virtual__(): self.skipTest("GitFS could not be loaded. Skipping GitFS tests!") self.tmp_cachedir = tempfile.mkdtemp(dir=TMP) gitfs.update()
def setUp(self): ''' We don't want to check in another .git dir into GH because that just gets messy. Instead, we'll create a temporary repo on the fly for the tests to examine. Also ensure we A) don't re-use the singleton, and B) that the cachedirs are cleared. This keeps these performance enhancements from affecting the results of subsequent tests. ''' if not gitfs.__virtual__(): self.skipTest("GitFS could not be loaded. Skipping GitFS tests!") _clear_instance_map() for subdir in ('gitfs', 'file_lists'): try: shutil.rmtree(os.path.join(self.tmp_cachedir, subdir)) except OSError as exc: if exc.errno != errno.ENOENT: raise
def setUp(self): ''' We don't want to check in another .git dir into GH because that just gets messy. Instead, we'll create a temporary repo on the fly for the tests to examine. ''' if not gitfs.__virtual__(): self.skipTest("GitFS could not be loaded. Skipping GitFS tests!") self.integration_base_files = os.path.join(FILES, 'file', 'base') # Create the dir if it doesn't already exist try: shutil.copytree(self.integration_base_files, self.tmp_repo_dir + '/') except OSError: # We probably caught an error because files already exist. Ignore pass try: repo = git.Repo(self.tmp_repo_dir) except git.exc.InvalidGitRepositoryError: repo = git.Repo.init(self.tmp_repo_dir) if 'USERNAME' not in os.environ: try: if salt.utils.platform.is_windows(): os.environ[ 'USERNAME'] = salt.utils.win_functions.get_current_user( ) else: os.environ['USERNAME'] = pwd.getpwuid(os.geteuid()).pw_name except AttributeError: log.error('Unable to get effective username, falling back to ' '\'root\'.') os.environ['USERNAME'] = '******' repo.index.add( [x for x in os.listdir(self.tmp_repo_dir) if x != '.git']) repo.index.commit('Test') gitfs.update()
'gitfs_privkey': '', 'gitfs_pubkey': '', 'gitfs_passphrase': '' } LOAD = {'saltenv': 'base'} log = logging.getLogger(__name__) try: import git GITFS_AVAILABLE = True except ImportError: GITFS_AVAILABLE = False if not gitfs.__virtual__(): GITFS_AVAILABLE = False @skipIf(not GITFS_AVAILABLE, "GitFS could not be loaded. Skipping GitFS tests!") @skipIf(NO_MOCK, NO_MOCK_REASON) class GitFSTest(integration.ModuleCase): maxDiff = None def setUp(self): ''' We don't want to check in another .git dir into GH because that just gets messy. Instead, we'll create a temporary repo on the fly for the tests to examine. ''' self.integration_base_files = os.path.join(integration.FILES, 'file', 'base') self.tmp_repo_dir = os.path.join(integration.TMP, 'gitfs_root')
['+refs/heads/*:refs/remotes/origin/*', '+refs/tags/*:refs/tags/*'], 'gitfs_ssl_verify': True } LOAD = {'saltenv': 'base'} log = logging.getLogger(__name__) try: import git GITFS_AVAILABLE = True except ImportError: GITFS_AVAILABLE = False if not gitfs.__virtual__(): GITFS_AVAILABLE = False @skipIf(not GITFS_AVAILABLE, "GitFS could not be loaded. Skipping GitFS tests!") @skipIf(NO_MOCK, NO_MOCK_REASON) class GitFSTest(integration.ModuleCase): maxDiff = None def setUp(self): ''' We don't want to check in another .git dir into GH because that just gets messy. Instead, we'll create a temporary repo on the fly for the tests to examine. ''' self.integration_base_files = os.path.join(integration.FILES, 'file',