Sha256: 6dd4089544dcfe8cf93ca69c8aa9744d3e9aa0130f5c743f5ce3d56b8c15f932

Contents?: true

Size: 1.99 KB

Versions: 21

Compression:

Stored size: 1.99 KB

Contents

require 'pathname'
require Pathname.new( File.dirname(__FILE__)).join( 'test_helper' ).cleanpath

require 'build-tool/repository'
require 'build-tool/server'
require 'build-tool/sshkey'

class TestRepository < Test::Unit::TestCase

  # Test a simple default created object
  def test_simple_creation
      repo = BuildTool::Repository.new('anonsvn.kde.org')
      # Check that all available properties are initialized correctly
      assert_nil repo.server
      assert_nil repo.path
      assert_equal repo.name, 'anonsvn.kde.org'

      assert_raise StandardError do
          BuildTool::Repository.new(nil)
      end
  end

  # Test all properties for required behaviour
  def test_properties
      repo = BuildTool::Repository.new('kde.org')
      server = BuildTool::Server.new('anonsvn.kde.org')

      # It's not allowed to change the name
      assert !repo.respond_to?( 'name=' )

      server.protocol = "http"
      assert_equal server.protocol, "http"

      repo.server = server
      assert_equal repo.server, server

      repo.path = "home/kde"
      assert_equal repo.path, "home/kde"

      sshkey = BuildTool::SshKey.new( "user@example.com", "~/.ssh/id_dsa" )
      assert_nil repo.sshkey
      repo.sshkey = sshkey
      assert_equal repo.sshkey, sshkey
  end

  def test_url
      repo = BuildTool::Repository.new "kde"
      server = BuildTool::Server.new('anonsvn.kde.org')

      assert_raises BuildTool::ConfigurationError do
          repo.url
      end

      repo.server = server
      assert_raises BuildTool::ConfigurationError do
          repo.url
      end
      server.host = "anonsvn.kde.org"
      assert_equal "anonsvn.kde.org", repo.url

      repo.user = "mjansen"
      assert_equal "mjansen@anonsvn.kde.org", repo.url

      server.protocol = "http"
      assert_equal "http://mjansen@anonsvn.kde.org", repo.url

      repo.user = nil
      assert_equal "http://anonsvn.kde.org", repo.url

      repo.path = "home/kde"
      assert_equal "http://anonsvn.kde.org/home/kde", repo.url
  end


end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
build-tool-0.5.3 test/test_repository.rb
build-tool-0.5.2 test/test_repository.rb
build-tool-0.4.6 test/test_repository.rb
build-tool-0.5.1 test/test_repository.rb
build-tool-0.4.5 test/test_repository.rb
build-tool-0.5.0 test/test_repository.rb
build-tool-0.4.4 test/test_repository.rb
build-tool-0.4.3 test/test_repository.rb
build-tool-0.4.2 test/test_repository.rb
build-tool-0.4.1 test/test_repository.rb
build-tool-0.4.0 test/test_repository.rb
build-tool-0.3.3 test/test_repository.rb
build-tool-0.3.2 test/test_repository.rb
build-tool-0.3.1 test/test_repository.rb
build-tool-0.3 test/test_repository.rb
build-tool-0.2 test/test_repository.rb
build-tool-0.1.4 test/test_repository.rb
build-tool-0.1.3 test/test_repository.rb
build-tool-0.1.2 test/test_repository.rb
build-tool-0.1.0 test/test_repository.rb