<commit_before># frozen_string_literal: true
require 'spec_helper'

describe 'jenkins_job_builder' do
  context 'supported operating systems' do
    %w(Debian RedHat).each do |osfamily|
      describe "jenkins_job_builder class without any parameters on #{osfamily}" do
        let(:params) { {} }
        let(:facts) do
          {
            osfamily: osfamily,
            operatingsystemrelease: '6'
          }
        end

        it { should compile.with_all_deps }

        it { should contain_class('jenkins_job_builder::params') }

        it { should contain_class('jenkins_job_builder::install').that_comes_before('jenkins_job_builder::config') }
        it { should contain_class('jenkins_job_builder::config') }

        it { should contain_package('jenkins-job-builder').with_ensure('latest') }

        it { should contain_file('/etc/jenkins_jobs').with_ensure('directory') }
        it { should contain_file('/etc/jenkins_jobs/jenkins_jobs.ini').with_ensure('present') }

        it do
          should contain_ini_setting('jenkins-jobs user').with(
            'ensure'  => 'present',
            'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
            'section' => 'jenkins',
            'setting' => 'user',
            'value'   => '',
            'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        )
        end

        it should contain_ini_setting('jenkins-jobs password').with(
          'ensure'  => 'present',
          'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
          'section' => 'jenkins',
          'setting' => 'password',
          'value'   => '',
          'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        )

        it do
          should contain_ini_setting('jenkins-jobs url').with(
            'ensure'  => 'present',
            'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
            'section' => 'jenkins',
            'setting' => 'url',
            'value'   => 'http://localhost:8080',
            'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        )
        end

        it do
          should contain_ini_setting('jenkins-jobs hipchat token').with(
            'ensure'  => 'present',
            'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
            'section' => 'hipchat',
            'setting' => 'authtoken',
            'value'   => '',
            'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        )
        end
      end
    end
    describe "jenkins_job_builder class without any parameters on a 'Debian' OS" do
      let(:params) { {} }
      let(:facts) do
        {
          osfamily: 'Debian',
          operatingsystemrelease: 'should_not_be_used'
        }
      end

      ['python', 'python-pip', 'python-yaml'].each do |dep|
        it { should contain_package(dep).with_ensure('present') }
      end
    end
    describe "jenkins_job_builder class without any parameters on a 'RedHat' OS version 6" do
      let(:params) { {} }
      let(:facts) do
        {
          osfamily: 'RedHat',
          operatingsystemrelease: '6'
        }
      end

      ['python', 'python-pip', 'PyYAML', 'python-argparse'].each do |dep|
        it { should contain_package(dep).with_ensure('present') }
      end
    end
    describe "jenkins_job_builder class without any parameters on a 'RedHat' OS" do
      let(:params) { {} }
      let(:facts) do
        {
          osfamily: 'RedHat',
          operatingsystemrelease: '7'
        }
      end

      ['python', 'python-pip', 'PyYAML'].each do |dep|
        it { should contain_package(dep).with_ensure('present') }
      end
    end
  end

  context 'install from git' do
    describe 'jenkins_job_builder installed from git' do
      let(:params) do
        {
          install_from_git: true
        }
      end
      let(:facts) do<commit_msg>fix ruby syntax errors<commit_after># frozen_string_literal: true
require 'spec_helper'

describe 'jenkins_job_builder' do
  context 'supported operating systems' do
    %w(Debian RedHat).each do |osfamily|
      describe "jenkins_job_builder class without any parameters on #{osfamily}" do
        let(:params) { {} }
        let(:facts) do
          {
            osfamily: osfamily,
            operatingsystemrelease: '6'
          }
        end

        it { should compile.with_all_deps }

        it { should contain_class('jenkins_job_builder::params') }

        it { should contain_class('jenkins_job_builder::install').that_comes_before('jenkins_job_builder::config') }
        it { should contain_class('jenkins_job_builder::config') }

        it { should contain_package('jenkins-job-builder').with_ensure('latest') }

        it { should contain_file('/etc/jenkins_jobs').with_ensure('directory') }
        it { should contain_file('/etc/jenkins_jobs/jenkins_jobs.ini').with_ensure('present') }

        it do
          should contain_ini_setting('jenkins-jobs user').with({
            'ensure'  => 'present',
            'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
            'section' => 'jenkins',
            'setting' => 'user',
            'value'   => '',
            'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        })
        end

        it do
          should contain_ini_setting('jenkins-jobs password').with({
          'ensure'  => 'present',
          'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
          'section' => 'jenkins',
          'setting' => 'password',
          'value'   => '',
          'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        })
        end

        it do
          should contain_ini_setting('jenkins-jobs url').with({
            'ensure'  => 'present',
            'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
            'section' => 'jenkins',
            'setting' => 'url',
            'value'   => 'http://localhost:8080',
            'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        })
        end

        it do
          should contain_ini_setting('jenkins-jobs hipchat token').with({
            'ensure'  => 'present',
            'path'    => '/etc/jenkins_jobs/jenkins_jobs.ini',
            'section' => 'hipchat',
            'setting' => 'authtoken',
            'value'   => '',
            'require' => 'File[/etc/jenkins_jobs/jenkins_jobs.ini]'
        })
        end
      end
    end

    describe "jenkins_job_builder class without any parameters on a 'Debian' OS" do
      let(:params) { {} }
      let(:facts) do
        {
          osfamily: 'Debian',
          operatingsystemrelease: 'should_not_be_used'
        }
      end

      ['python', 'python-pip', 'python-yaml'].each do |dep|
        it { should contain_package(dep).with_ensure('present') }
      end
    end

    describe "jenkins_job_builder class without any parameters on a 'RedHat' OS version 6" do
      let(:params) { {} }
      let(:facts) do
        {
          osfamily: 'RedHat',
          operatingsystemrelease: '6'
        }
      end

      ['python', 'python-pip', 'PyYAML', 'python-argparse'].each do |dep|
        it { should contain_package(dep).with_ensure('present') }
      end
    end

    describe "jenkins_job_builder class without any parameters on a 'RedHat' OS" do
      let(:params) { {} }
      let(:facts) do
        {
          osfamily: 'RedHat',
          operatingsystemrelease: '7'
        }
      end

      ['python', 'python-pip', 'PyYAML'].each do |dep|
        it { should contain_package(dep).with_ensure('present') }
      end
    end
  end

  context 'install from git' do
    describe 'jenkins_job_builder installed from git' do
      let(:params) do
        {
          install_from_git: true
        }
      end
      let(:facts) do
{'fraction_non_alphanumeric': 0.1328680367067339, 'fraction_numerical': 0.0020679850071086987, 'mean_word_length': 2.0645544554455446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4810777', 'n_tokens_mistral': 2430, 'n_tokens_neox': 2303, 'n_words': 472}