<commit_before>require 'fileutils'

describe MiqReport do
  describe "::Seeding" do
    include_examples(".seed called multiple times", 145)

    describe ".seed" do
      let(:tmpdir)      { Pathname.new(Dir.mktmpdir) }
      let(:reports_dir) { tmpdir.join("product/reports") }
      let(:compare_dir) { tmpdir.join("product/compare") }
      let(:report_yml)  { reports_dir.join("1_Testing Group/022_Testing Report.yaml") }
      let(:compare_yml) { compare_dir.join("testing.yaml") }
      let(:data_dir)    { Pathname.new(__dir__).join("data/product") }

      before do
        FileUtils.mkdir_p(reports_dir)
        FileUtils.cp_r(Rails.root.join("product/reports/520_Events - Policy"), reports_dir, preserve: true)
        FileUtils.cp_r(Rails.root.join("product/compare"), tmpdir.join("product"), preserve: true)

        stub_const("MiqReport::Seeding::REPORT_DIR", reports_dir)
        stub_const("MiqReport::Seeding::COMPARE_DIR", compare_dir)
      end

      after do
        FileUtils.rm_rf(tmpdir)
      end

      # This test is intentionally long winded instead of breaking it up into
      # multiple tests per concern because of how long a full seed takes.
      # Breaking it into individual tests would increase runtime a lot.
      it "creates, updates, and changes records" do
        described_class.seed<commit_msg>seeding_spec - adjust expected seed count up<commit_after>require 'fileutils'

describe MiqReport do
  describe "::Seeding" do
    include_examples(".seed called multiple times", 146)

    describe ".seed" do
      let(:tmpdir)      { Pathname.new(Dir.mktmpdir) }
      let(:reports_dir) { tmpdir.join("product/reports") }
      let(:compare_dir) { tmpdir.join("product/compare") }
      let(:report_yml)  { reports_dir.join("1_Testing Group/022_Testing Report.yaml") }
      let(:compare_yml) { compare_dir.join("testing.yaml") }
      let(:data_dir)    { Pathname.new(__dir__).join("data/product") }

      before do
        FileUtils.mkdir_p(reports_dir)
        FileUtils.cp_r(Rails.root.join("product/reports/520_Events - Policy"), reports_dir, preserve: true)
        FileUtils.cp_r(Rails.root.join("product/compare"), tmpdir.join("product"), preserve: true)

        stub_const("MiqReport::Seeding::REPORT_DIR", reports_dir)
        stub_const("MiqReport::Seeding::COMPARE_DIR", compare_dir)
      end

      after do
        FileUtils.rm_rf(tmpdir)
      end

      # This test is intentionally long winded instead of breaking it up into
      # multiple tests per concern because of how long a full seed takes.
      # Breaking it into individual tests would increase runtime a lot.
      it "creates, updates, and changes records" do
        described_class.seed
{'fraction_non_alphanumeric': 0.11315886472539624, 'fraction_numerical': 0.007371913011426466, 'mean_word_length': 3.3915857605177995, 'pattern_counts': {'":': 2, '<': 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': '4724752', 'n_tokens_mistral': 852, 'n_tokens_neox': 809, 'n_words': 190}