<commit_before>require "chefspec"

describe "sol::default" do
  before { Chef::Recipe.any_instance.stub(:include_recipe) }

  describe "custom vendor" do
    before do
      @chef_run = ChefSpec::ChefRunner.new do |node|
        node.set['dmi'] = {}
        node.set['dmi']['system'] = {}
        node.set['dmi']['system']['manufacturer'] = "foo bar"
        node.set['sol'] = {}
        node.set['sol']['foo-bar'] = {}
        node.set['sol']['foo-bar']['grub'] = {}
        node.set['sol']['foo-bar']['grub']['hidden_timeout'] = "100"
      end
      @chef_run.converge "sol::default"
    end

    it "has custom GRUB_HIDDEN_TIMEOUT" do
      @chef_run.should create_file_with_content "/etc/default/grub",
        %Q{GRUB_HIDDEN_TIMEOUT=100}
    end
  end

  describe "quanta" do
    before do
      @chef_run = ChefSpec::ChefRunner.new do |node|
        node.set['dmi'] = {}
        node.set['dmi']['system'] = {}
        node.set['dmi']['system']['manufacturer'] = "Quanta " # Quanta has a trailing space
      end
      @chef_run.converge "sol::default"
    end

    describe "ttyS1" do
      it "has proper owner" do
        @chef_run.template("/etc/init/ttyS1.conf").should be_owned_by("root", "root")
      end

      it "has proper modes" do
        m = @chef_run.template("/etc/init/ttyS1.conf").mode

        sprintf("%o", m).should == "644"
      end

      it "has getty" do
        @chef_run.should create_file_with_content "/etc/init/ttyS1.conf",
          %Q{ttyS1 - getty}
      end

      it "has comment" do
        @chef_run.should create_file_with_content "/etc/init/ttyS1.conf",
          %Q{# This service maintains a getty on ttyS1 from the point the system is}
      end

      it "has getty exec" do
        @chef_run.should create_file_with_content "/etc/init/ttyS1.conf",
          %Q{exec /sbin/getty -8 38400 ttyS1}
      end
    end

    describe "grub" do
      it "has GRUB_CMDLINE_LINUX" do
        @chef_run.should create_file_with_content "/etc/default/grub",
          %Q{GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS1,115200n8"}
      end

      it "has GRUB_SERIAL_COMMAND" do
        @chef_run.should create_file_with_content "/etc/default/grub",
          %Q{GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"}
      end
    end
  end

  describe "dell" do
    before do
      @chef_run = ChefSpec::ChefRunner.new do |node|
        node.set['dmi'] = {}
        node.set['dmi']['system'] = {}
        node.set['dmi']['system']['manufacturer'] = "Dell Inc."
      end
      @chef_run.converge "sol::default"
    end

    describe "ttyS0" do
      it "has proper owner" do
        @chef_run.template("/etc/init/ttyS0.conf").should be_owned_by("root", "root")
      end

      it "has proper modes" do
        m = @chef_run.template("/etc/init/ttyS0.conf").mode
<commit_msg>Corrected tests -- nawtie me<commit_after>require "chefspec"

describe "sol::default" do
  before { Chef::Recipe.any_instance.stub(:include_recipe) }

  describe "custom vendor" do
    before do
      @chef_run = ChefSpec::ChefRunner.new do |node|
        node.set['dmi'] = {}
        node.set['dmi']['system'] = {}
        node.set['dmi']['system']['manufacturer'] = "foo bar"
        node.set['sol'] = {}
        node.set['sol']['foo-bar'] = {}
        node.set['sol']['foo-bar']['grub'] = {}
        node.set['sol']['foo-bar']['grub']['hidden_timeout'] = "100"
      end
      @chef_run.converge "sol::default"
    end

    it "has custom GRUB_HIDDEN_TIMEOUT" do
      @chef_run.should create_file_with_content "/etc/default/grub",
        %Q{GRUB_HIDDEN_TIMEOUT=100}
    end
  end

  describe "quanta" do
    before do
      @chef_run = ChefSpec::ChefRunner.new do |node|
        node.set['dmi'] = {}
        node.set['dmi']['system'] = {}
        node.set['dmi']['system']['manufacturer'] = "Quanta " # Quanta has a trailing space
      end
      @chef_run.converge "sol::default"
    end

    describe "ttyS1" do
      it "has proper owner" do
        @chef_run.template("/etc/init/ttyS1.conf").should be_owned_by("root", "root")
      end

      it "has proper modes" do
        m = @chef_run.template("/etc/init/ttyS1.conf").mode

        sprintf("%o", m).should == "644"
      end

      it "has getty" do
        @chef_run.should create_file_with_content "/etc/init/ttyS1.conf",
          %Q{ttyS1 - getty}
      end

      it "has comment" do
        @chef_run.should create_file_with_content "/etc/init/ttyS1.conf",
          %Q{# This service maintains a getty on ttyS1 from the point the system is}
      end

      it "has getty exec" do
        @chef_run.should create_file_with_content "/etc/init/ttyS1.conf",
          %Q{exec /sbin/getty -8 115200 ttyS1}
      end
    end

    describe "grub" do
      it "has GRUB_CMDLINE_LINUX" do
        @chef_run.should create_file_with_content "/etc/default/grub",
          %Q{GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS1,115200n8"}
      end

      it "has GRUB_SERIAL_COMMAND" do
        @chef_run.should create_file_with_content "/etc/default/grub",
          %Q{GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"}
      end
    end
  end

  describe "dell" do
    before do
      @chef_run = ChefSpec::ChefRunner.new do |node|
        node.set['dmi'] = {}
        node.set['dmi']['system'] = {}
        node.set['dmi']['system']['manufacturer'] = "Dell Inc."
      end
      @chef_run.converge "sol::default"
    end

    describe "ttyS0" do
      it "has proper owner" do
        @chef_run.template("/etc/init/ttyS0.conf").should be_owned_by("root", "root")
      end

      it "has proper modes" do
        m = @chef_run.template("/etc/init/ttyS0.conf").mode

{'fraction_non_alphanumeric': 0.1502363859219051, 'fraction_numerical': 0.015759061460339695, 'mean_word_length': 2.5194085027726434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3265899', 'n_tokens_mistral': 2089, 'n_tokens_neox': 2017, 'n_words': 405}