<commit_before>require "spec_helper"

describe "openstack-common::logging" do
  describe "ubuntu" do
    before do
      @chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
      @chef_run.converge "openstack-common::logging"
    end

    describe "/etc/openstack" do
      before do
        @dir = @chef_run.directory "/etc/openstack"
      end 

      it "has proper owner" do
        expect(@dir).to be_owned_by "root", "root"
      end 

      it "has proper modes" do
        expect(sprintf("%o", @dir.mode)).to eq "755"
      end 
    end 

    describe "logging.conf" do
      before do
        @file = @chef_run.template "/etc/openstack/logging.conf"
      end

      it "has proper owner" do
        expect(@file).to be_owned_by "root", "root"
      end

      it "has proper modes" do
        expect(sprintf("%o", @file.mode)).to eq "644"
      end

      it "template contents" do
        pending "TODO: implement"
      end
    end
  end
end<commit_msg>Adding template test for logging.conf<commit_after>require "spec_helper"

describe "openstack-common::logging" do
  describe "ubuntu" do
    before do
      @chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
      @chef_run.converge "openstack-common::logging"
    end

    describe "/etc/openstack" do
      before do
        @dir = @chef_run.directory "/etc/openstack"
      end

      it "has proper owner" do
        expect(@dir).to be_owned_by "root", "root"
      end

      it "has proper modes" do
        expect(sprintf("%o", @dir.mode)).to eq "755"
      end
    end

    describe "logging.conf" do
      before do
        @file = "/etc/openstack/logging.conf"
      end

      it "has proper owner" do
        expect(@chef_run.template(@file)).to be_owned_by "root", "root"
      end

      it "has proper modes" do
        m = @chef_run.template(@file).mode
        expect(sprintf("%o", m)).to eq "644"
      end

      it "templates openstack.logging.ignore block" do
        chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
        chef_run.converge "openstack-common::logging"
        node = chef_run.node
        node.set["openstack"]["logging"]["ignore"] = {
          "test.nova.api.openstack.wsgi" => "WARNING"
        }

        tmp = [
          "[logger_test_nova_api_openstack_wsgi]",
          "level = WARNING",
          "handlers = prod,debug",
          "qualname = test.nova.api.openstack.wsgi"
        ]
        expect(chef_run).to create_file_with_content @file, tmp.join("\n")
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12126047068209014, 'fraction_numerical': 0.004786597526924611, 'mean_word_length': 2.2487046632124352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4970700', 'n_tokens_mistral': 845, 'n_tokens_neox': 817, 'n_words': 196}