Sha256: 817dcaf3af37774869237402f36cffc515b31ffd60b67c3289b0b66442bb00ce

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'minitest/autorun'
require 'kanoko/configure'

class TestKanokoConfigure < Minitest::Test
  def setup
    @config = Kanoko::Configure.new
  end

  def test_kanoko_host
    assert_raises(Kanoko::ConfigureError) { @config.kanoko_host = "/example.com" }

    @config.kanoko_host = "example.com"
    assert_equal "http://example.com", @config.kanoko_host

    @config.kanoko_host = "http://example.com"
    assert_equal "http://example.com", @config.kanoko_host

    @config.kanoko_host = "https://example.com"
    assert_equal "https://example.com", @config.kanoko_host
  end

  def test_hash_proc_by_default_error
    @config.digest_func = nil
    @config.secret_key = nil
    assert_raises(Kanoko::ConfigureError){ @config.hash_proc.call }

    @config.digest_func = "sha1"
    @config.secret_key = nil
    assert_raises(Kanoko::ConfigureError){ @config.hash_proc.call }

    @config.digest_func = nil
    @config.secret_key = "test"
    assert_raises(Kanoko::ConfigureError){ @config.hash_proc.call }
  end

  def test_hash_proc_by_default
    @config.digest_func = "sha1"
    @config.secret_key = "test"
    assert_equal "yrYrwA2D_XJwEyaWOr3S8GPWtd8=", @config.hash_proc.call("aaa")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kanoko-0.0.3 test/test_configure.rb
kanoko-0.0.2 test/test_configure.rb