Sha256: 3bcf70cf2dee35c34e1ebda9dc25d170f3194f31f49bc22e6526bfa0ef2f3757

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

require "test_helper"
require "roger/testing/mock_release"
require "shellwords"

module Roger
  # Test for Roger GitBranchFinalizer
  class GitBranchTest < ::Test::Unit::TestCase
    include TestConstruct::Helpers

    def setup
      @release = Testing::MockRelease.new

      # Create a file to release in the build dir
      @release.project.construct.file "build/index.html"

      # Set fixed version
      @release.scm.version = "1.0.0"
    end

    def teardown
      @release.destroy
      @release = nil
    end

    def test_basic_functionality
      git_branch_finalizers = Roger::Release::Finalizers::GitBranch.new

      output_dir = git_branch_finalizers.call(
        @release,
        remote: "http://we.aint.go/nna.push.git",
        push: false,
        cleanup: false
      )

      Dir.chdir(output_dir + "clone") do
        commit_msg = `git log --pretty=oneline --abbrev-commit`
        assert_match(/Release 1.0.0/, commit_msg)
      end

      FileUtils.rm_rf(output_dir)
    end

    def test_find_remote
      finalizer = Roger::Release::Finalizers::GitBranch.new
      remote_repo = setup_construct(chdir: false)

      `git init -q`

      Dir.chdir(remote_repo.to_s) do
        `git init -q --bare`
      end

      `git remote add origin #{Shellwords.escape(remote_repo.to_s)}`

      assert_nothing_raised do
        finalizer.call(
          @release,
          push: false,
          cleanup: false
        )
      end
    ensure
      teardown_construct(remote_repo)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roger-1.10.0 test/unit/release/finalizers/git_branch_test.rb
roger-1.9.1 test/unit/release/finalizers/git_branch_test.rb
roger-1.9.0 test/unit/release/finalizers/git_branch_test.rb
roger-1.8.0 test/unit/release/finalizers/git_branch_test.rb
roger-1.7.2 test/unit/release/finalizers/git_branch_test.rb
roger-1.7.1 test/unit/release/finalizers/git_branch_test.rb