Sha256: 76ee27145058650fe2543ff4ac2214805e0e09f86ab1fba6ae59426225551402

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

require File.expand_path '../test_helper.rb', __FILE__

class DeepThoughtCIServiceTest < MiniTest::Unit::TestCase
  def setup
    DatabaseCleaner.start

    DeepThought::CIService.adapters = {}
    DeepThought::CIService.ci_service = nil
  end

  def teardown
    DatabaseCleaner.clean
  end

  def test_no_ci_service
    DeepThought::CIService.setup({})

    assert !DeepThought::CIService.ci_service
  end

  def test_ci_service_not_found
    assert_raises(DeepThought::CIService::CIServiceNotFoundError) { DeepThought::CIService.setup({"CI_SERVICE" => "no-service"}) }
  end

  def test_ci_service_is_branch_green_success
    ci_service = mock('class')
    ci_service.expects(:new).returns(ci_service)
    ci_service.expects(:setup).with({"CI_SERVICE" => "mock"})
    ci_service.expects(:is_branch_green?).with('app', 'master', 'hash').returns(true)
    DeepThought::CIService.register_adapter('mock', ci_service)
    DeepThought::CIService.setup({"CI_SERVICE" => "mock"})
    assert DeepThought::CIService.is_branch_green?('app', 'master', 'hash')
  end

  def test_ci_service_is_branch_green_failed
    ci_service = mock('class')
    ci_service.expects(:new).returns(ci_service)
    ci_service.expects(:setup).with({"CI_SERVICE" => "mock"})
    ci_service.expects(:is_branch_green?).with('app', 'master', 'hash').returns(false)
    DeepThought::CIService.register_adapter('mock', ci_service)
    DeepThought::CIService.setup({"CI_SERVICE" => "mock"})
    assert !DeepThought::CIService.is_branch_green?('app', 'master', 'hash')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deep_thought-0.1.0 test/deep_thought_ci_service_test.rb