require_relative "test_helper"

class ResolverTest < Minitest::Test
  def test_configured_tracker_is_used
    resolver = Backlog::Resolver.new(
      repo_path: "/home/jared/dev/some-repo",
      config_contents: "tracker=forgejo:jared/some-repo\n"
    )

    assert_equal "use forgejo:jared/some-repo", resolver.resolve_string
  end

  def test_unconfigured_project_stops_and_discusses
    resolver = Backlog::Resolver.new(
      repo_path: "/home/jared/dev/some-repo",
      config_contents: nil
    )

    assert_equal "stop-and-discuss", resolver.resolve_string
  end

  def test_blank_config_contents_stops_and_discusses
    resolver = Backlog::Resolver.new(
      repo_path: "/home/jared/dev/some-repo",
      config_contents: ""
    )

    assert_equal "stop-and-discuss", resolver.resolve_string
  end

  def test_tolerates_legacy_boards_keyword_for_backward_compatibility
    resolver = Backlog::Resolver.new(
      repo_path: "/home/jared/dev/some-repo",
      config_contents: "tracker=github:jared/some-repo\n",
      boards: %w[unrelated-board]
    )

    assert_equal "use github:jared/some-repo", resolver.resolve_string
  end
end
