<commit_before>require "spec_helper"

describe "MiqServer" do
  context "RhnMirror" do
    before do
      ServerRole.seed
      _, @server1, = EvmSpecHelper.create_guid_miq_server_zone
      @server1.update_attribute(:ipaddress, "192.168.3.11")
      @server2 = FactoryGirl.create(:miq_server, :zone => @server1.zone, :ipaddress => "192.168.127.12")
    end

    context "#configure_rhn_mirror_client" do
      it "should configure when not hosting content" do
        @server2.assign_role("rhn_mirror")

        FileUtils.should_not_receive(:rm_f)
        File.should_receive(:read).with("/etc/hosts").and_return("\n #Some Comment\n127.0.0.1\tlocalhost")
        File.should_receive(:write).with("/etc/hosts", "\n#Some Comment\n127.0.0.1        localhost\n#{@server1.ipaddress}          #{@server1.guid}\n#{@server2.ipaddress}          #{@server2.guid}")
        MiqServer.any_instance.should_receive(:write_yum_repo_file).with([@server2])

        @server1.configure_rhn_mirror_client
      end

      it "should not configure when hosting content" do
        @server1.assign_role("rhn_mirror")

        FileUtils.should_receive(:rm_f).once

        @server1.configure_rhn_mirror_client
      end
    end

    it "#resync_rhn_mirror" do
      rpm_file_list       = ["/repo/mirror/abc-1.2.3-1.el6_0.2.i686.rpm", "/repo/mirror/abc-4.5.6-7.el6_4.x86_64.rpm", "/repo/mirror/def-B.02abc.1r6-4.el6cf.x86_64.rpm", "/repo/mirror/ghi-2013c-2.el6.noarch.rpm"]
      parsed_package_list = {"abc" => {"1.2.3.1" => "/repo/mirror/abc-1.2.3-1.el6_0.2.i686.rpm", "4.5.6.7" => "/repo/mirror/abc-4.5.6-7.el6_4.x86_64.rpm"}, "def-B" => {"02.1.6.4" => "/repo/mirror/def-B.02abc.1r6-4.el6cf.x86_64.rpm"}, "ghi" => {"2013.2" => "/repo/mirror/ghi-2013c-2.el6.noarch.rpm"}}<commit_msg>Updated spec to deal with new LinuxAdmin gem behavior<commit_after>require "spec_helper"

describe "MiqServer" do
  context "RhnMirror" do
    before do
      ServerRole.seed
      _, @server1, = EvmSpecHelper.create_guid_miq_server_zone
      @server1.update_attribute(:ipaddress, "192.168.3.11")
      @server2 = FactoryGirl.create(:miq_server, :zone => @server1.zone, :ipaddress => "192.168.127.12")
    end

    context "#configure_rhn_mirror_client" do
      it "should configure when not hosting content" do
        @server2.assign_role("rhn_mirror")

        FileUtils.should_not_receive(:rm_f)
        File.should_receive(:read).with("/etc/hosts").and_return("\n #Some Comment\n127.0.0.1\tlocalhost")
        File.should_receive(:write).with("/etc/hosts", "\n#Some Comment\n127.0.0.1        localhost\n#{@server1.ipaddress}          #{@server1.guid}\n#{@server2.ipaddress}          #{@server2.guid}\n")
        MiqServer.any_instance.should_receive(:write_yum_repo_file).with([@server2])

        @server1.configure_rhn_mirror_client
      end

      it "should not configure when hosting content" do
        @server1.assign_role("rhn_mirror")

        FileUtils.should_receive(:rm_f).once

        @server1.configure_rhn_mirror_client
      end
    end

    it "#resync_rhn_mirror" do
      rpm_file_list       = ["/repo/mirror/abc-1.2.3-1.el6_0.2.i686.rpm", "/repo/mirror/abc-4.5.6-7.el6_4.x86_64.rpm", "/repo/mirror/def-B.02abc.1r6-4.el6cf.x86_64.rpm", "/repo/mirror/ghi-2013c-2.el6.noarch.rpm"]
      parsed_package_list = {"abc" => {"1.2.3.1" => "/repo/mirror/abc-1.2.3-1.el6_0.2.i686.rpm", "4.5.6.7" => "/repo/mirror/abc-4.5.6-7.el6_4.x86_64.rpm"}, "def-B" => {"02.1.6.4" => "/repo/mirror/def-B.02abc.1r6-4.el6cf.x86_64.rpm"}, "ghi" => {"2013.2" => "/repo/mirror/ghi-2013c-2.el6.noarch.rpm"}}
{'fraction_non_alphanumeric': 0.1733893557422969, 'fraction_numerical': 0.07563025210084033, 'mean_word_length': 3.1814988290398127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 14, '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': '5702352', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1422, 'n_words': 167}