Sha256: b4439e36df88692f31730bc1a58eafffc9da79b0af44e5aa5a35031403c5ec74

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

require 'test_helper'

module Shipit
  class CheckRunTest < ActiveSupport::TestCase
    setup do
      @commit = shipit_commits(:first)
      @stack = @commit.stack
      @check_run = shipit_check_runs(:second_pending_travis)
    end

    test ".create_or_update_from_github! is idempotent" do
      assert_difference -> { @commit.check_runs.count }, +1 do
        @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run)
      end

      assert_no_difference -> { @commit.check_runs.count } do
        @commit.check_runs.create_or_update_from_github!(@stack.id, github_check_run)
      end
    end

    {
      nil => 'pending',
      'success' => 'success',
      'failure' => 'failure',
      'neutral' => 'success',
      'cancelled' => 'failure',
      'timed_out' => 'error',
      'action_required' => 'pending',
    }.each do |conclusion, expected_status|
      test "#state is #{expected_status.inspect} when conclusion is #{conclusion.inspect}" do
        @check_run.update!(conclusion: conclusion)
        assert_equal expected_status, @check_run.state
      end
    end

    private

    def github_check_run
      @github_check_run ||= OpenStruct.new(
        id: 424_242,
        conclusion: 'success',
        output: OpenStruct.new(
          description: 'This is a description',
        ),
        name: 'Test Suite',
        html_url: 'http://example.com/run',
        details_url: 'http://example.com/details',
      )
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 test/models/shipit/check_run_test.rb
shipit-engine-0.30.0 test/models/shipit/check_run_test.rb
shipit-engine-0.29.0 test/models/shipit/check_run_test.rb
shipit-engine-0.28.1 test/models/shipit/check_run_test.rb
shipit-engine-0.28.0 test/models/shipit/check_run_test.rb
shipit-engine-0.27.1 test/models/shipit/check_run_test.rb
shipit-engine-0.27.0 test/models/shipit/check_run_test.rb
shipit-engine-0.26.0 test/models/shipit/check_run_test.rb