Sha256: 4c8dd05a3a481c7fcd0faac5b775a00283d9078ed980ec665066804e61457ed5

Contents?: true

Size: 1.16 KB

Versions: 87

Compression:

Stored size: 1.16 KB

Contents

require 'foreman_tasks_test_helper'

class SummarizerTest < ActiveSupport::TestCase
  before do
    ::ForemanTasks::Task.delete_all
  end

  describe ForemanTasks::Task::Summarizer do
    before do
      @tasks_builder = HistoryTasksBuilder.new
      @tasks_builder.build
    end

    let :subject do
      ForemanTasks::Task::Summarizer.new(ForemanTasks::Task)
    end

    let :expected do
      @tasks_builder.distribution
    end

    it 'is able to group tasks counts by state and result' do
      summary = subject.summary
      expected.each do |(state, expected_state_vals)|
        assert_summary(expected_state_vals, summary[state], "summary[#{state}]")
        expected_state_vals.fetch(:by_result, {}).each do |result, expected_result_vals|
          assert_summary expected_result_vals, summary[state][:by_result][result], "summary[#{state}][#{result}]"
        end
      end
    end

    def assert_summary(expected_summary, summary, value_desc)
      %I[recent total].each do |key|
        assert_equal expected_summary[key], summary[key],
                     "#{value_desc}[#{key}] expected to be #{expected_summary[key]}, was #{summary[key]}"
      end
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
foreman-tasks-10.0.2 test/unit/summarizer_test.rb
foreman-tasks-10.0.1 test/unit/summarizer_test.rb
foreman-tasks-10.0.0 test/unit/summarizer_test.rb
foreman-tasks-9.2.3 test/unit/summarizer_test.rb
foreman-tasks-9.2.2 test/unit/summarizer_test.rb
foreman-tasks-9.2.1 test/unit/summarizer_test.rb
foreman-tasks-9.2.0 test/unit/summarizer_test.rb
foreman-tasks-9.1.1 test/unit/summarizer_test.rb
foreman-tasks-9.0.4 test/unit/summarizer_test.rb
foreman-tasks-9.1.0 test/unit/summarizer_test.rb
foreman-tasks-9.0.2 test/unit/summarizer_test.rb
foreman-tasks-9.0.1 test/unit/summarizer_test.rb
foreman-tasks-8.3.3 test/unit/summarizer_test.rb
foreman-tasks-9.0.0 test/unit/summarizer_test.rb
foreman-tasks-8.2.1 test/unit/summarizer_test.rb
foreman-tasks-8.1.4 test/unit/summarizer_test.rb
foreman-tasks-8.3.2 test/unit/summarizer_test.rb
foreman-tasks-8.3.1 test/unit/summarizer_test.rb
foreman-tasks-8.1.3 test/unit/summarizer_test.rb
foreman-tasks-8.3.0 test/unit/summarizer_test.rb