<commit_before>require "spec_helper"

describe MiqServer do
  describe "ConfigurationManagement" do
    describe "#get_config" do
      context "local server" do
        before do
          _guid, @local_server, _zone = EvmSpecHelper.local_guid_miq_server_zone
        end

        it "with no changes in the database" do
          expect(@local_server.get_config("vmdb").config).to be_kind_of(Hash)
        end

        it "with changes in the database" do
          c = YAML.load_file(Rails.root.join("config/vmdb.tmpl.yml"))
          c.store_path("server", "name", "XXX")
          FactoryGirl.create(:configuration, :miq_server => @local_server, :typ => "vmdb", :settings => c)

          actual = @local_server.get_config("vmdb").config.fetch_path(:server, :name)
          expect(actual).to eq "XXX"
        end
      end

      context "remote server" do
        before do
          _, @remote_server, = EvmSpecHelper.remote_guid_miq_server_zone
        end

        it "with no changes in the database" do
          expect(@remote_server.get_config("vmdb").config).to be_kind_of(Hash)
        end

        it "with changes in the database" do
          c = YAML.load_file(Rails.root.join("config/vmdb.tmpl.yml"))
          c.store_path("server", "name", "XXX")
          FactoryGirl.create(:configuration, :miq_server => @remote_server, :typ => "vmdb", :settings => c)

          actual = @remote_server.get_config("vmdb").config.fetch_path(:server, :name)
          expect(actual).to eq "XXX"
        end
      end
    end
  end
end<commit_msg>YAML.load is slow and unnecessary for this test<commit_after>require "spec_helper"

describe MiqServer do
  describe "ConfigurationManagement" do
    describe "#get_config" do
      context "local server" do
        before do
          _guid, @local_server, _zone = EvmSpecHelper.local_guid_miq_server_zone
        end

        it "with no changes in the database" do
          expect(@local_server.get_config("vmdb").config).to be_kind_of(Hash)
        end

        it "with changes in the database" do
          c = {"server" => {"name" => "XXX"}}
          FactoryGirl.create(:configuration, :miq_server => @local_server, :typ => "vmdb", :settings => c)

          actual = @local_server.get_config("vmdb").config.fetch_path(:server, :name)
          expect(actual).to eq "XXX"
        end
      end

      context "remote server" do
        before do
          _, @remote_server, = EvmSpecHelper.remote_guid_miq_server_zone
        end

        it "with no changes in the database" do
          expect(@remote_server.get_config("vmdb").config).to be_kind_of(Hash)
        end

        it "with changes in the database" do
          c = {"server" => {"name" => "XXX"}}
          FactoryGirl.create(:configuration, :miq_server => @remote_server, :typ => "vmdb", :settings => c)

          actual = @remote_server.get_config("vmdb").config.fetch_path(:server, :name)
          expect(actual).to eq "XXX"
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11440960640426952, 'fraction_numerical': 0.0, 'mean_word_length': 2.549112426035503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '6643475', 'n_tokens_mistral': 946, 'n_tokens_neox': 898, 'n_words': 224}