Sha256: 9781f4873ae42af20cdb25375f16c99b3cf08973ea805a882967efd4b1b2eb6e

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

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

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

    @janky = DeepThought::CIService::Janky.new
  end

  def teardown
    DatabaseCleaner.clean
  end

  def test_janky_setup_success
    @janky.setup({"CI_SERVICE_ENDPOINT" => "endpoint", "CI_SERVICE_USERNAME" => "username", "CI_SERVICE_PASSWORD" => "password"})

    assert @janky.endpoint == 'endpoint'
    assert @janky.username == 'username'
    assert @janky.password == 'password'
  end

  def test_janky_is_branch_green_success
    json = stub(:body => '[{"sha1":"hash","green":true}]')
    HTTParty.expects(:get).with("#{@janky.endpoint}/_hubot/app/branch", {:basic_auth => {:username => @janky.username, :password => @janky.password}}).returns(json)

    assert @janky.is_branch_green?('app', 'branch', 'hash')
  end

  def test_janky_is_branch_green_failed
    json = stub(:body => '[{"sha1":"different-hash","green":false}]')
    HTTParty.expects(:get).with("#{@janky.endpoint}/_hubot/app/branch", {:basic_auth => {:username => @janky.username, :password => @janky.password}}).returns(json)

    assert !@janky.is_branch_green?('app', 'branch', 'hash')
  end

  def test_janky_is_branch_green_missing
    json = stub(:body => '[{"sha1":"different-hash"}]')
    HTTParty.expects(:get).with("#{@janky.endpoint}/_hubot/app/branch", {:basic_auth => {:username => @janky.username, :password => @janky.password}}).returns(json)

    assert !@janky.is_branch_green?('app', 'branch', 'hash')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deep_thought-0.1.0 test/deep_thought_janky_test.rb