<commit_before><commit_msg>Add tests for rsync finalizer<commit_after>require "test_helper"
require "roger/testing/mock_release"

module Roger
  # Test for Roger Rsync finalizer
  class RsyncTest < ::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"

      # A target dir
      @target_path = setup_construct(chdir: false)
    end

    # called after every single test
    def teardown
      teardown_construct(@target_path)
      @release.destroy
      @release = nil
    end

    def test_basic_functionality
      finalizer = Roger::Release::Finalizers::Rsync.new(
        remote_path: @target_path.to_s,
        ask: false
      )

      finalizer.call(@release)

      assert File.exist?(@target_path + "index.html"), @release.target_path.inspect
    end

    def test_rsync_command_works
      finalizer = Roger::Release::Finalizers::Rsync.new(
        rsync: "rsync-0123456789", # Let's hope nobody actually has this command
        remote_path: @target_path.to_s,
        ask: false
      )

      assert_raise(RuntimeError) do
        finalizer.call(@release)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08940646130728776, 'fraction_numerical': 0.009767092411720512, 'mean_word_length': 2.8057142857142856, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6190929', 'n_tokens_mistral': 416, 'n_tokens_neox': 397, 'n_words': 97}