def test_cleanup(jenkins, repo, config): config['cleanup'] = True config['namefmt'] = '{branch}' with repo.branches('branches/one', 'branches/two'): cmd(config) assert jenkins.job_exists('one') assert jenkins.job_exists('two') assert is_created_by_jenkinsautojobs(jenkins.job('one')) with repo.branch('branches/one'): cmd(config) assert not jenkins.job_exists('two')
def test_cleanup(config, jenkins, repo, tag_method): config['cleanup'] = True config['tag-method'] = tag_method with repo.branches('feature/one', 'feature/two'): cmd(config) assert jenkins.job_exists('feature-one') assert jenkins.job_exists('feature-two') assert is_created_by_jenkinsautojobs(jenkins.job('feature-one'), tag_method) with repo.branch('feature/one'): cmd(config) assert not jenkins.job_exists('feature-two')
def test_failing_git_cleanup(config, jenkins, repo, tag_method): config['cleanup'] = True config['tag-method'] = tag_method with repo.branches('feature/one', 'feature/two'): cmd(config) assert jenkins.job_exists('feature-one') assert jenkins.job_exists('feature-two') assert is_created_by_jenkinsautojobs(jenkins.job('feature-one'), tag_method) config['repo'] = '/tmp/should-never-exist-zxcv-123-zxcv-1asfmn' with pytest.raises(SystemExit): cmd(config) # feature-{one,two} should not be removed if command fails assert jenkins.job_exists('feature-one') assert jenkins.job_exists('feature-two')