require_relative "test_helper" class TrackerTest < Minitest::Test def test_accepts_planka_format assert Backlog::Tracker.valid?("planka:llf-schema") assert_equal :planka, Backlog::Tracker.kind("planka:llf-schema") end def test_accepts_forgejo_format assert Backlog::Tracker.valid?("forgejo:jared/cc-os") assert_equal :forgejo, Backlog::Tracker.kind("forgejo:jared/cc-os") end def test_accepts_github_format assert Backlog::Tracker.valid?("github:acme/widget") assert_equal :github, Backlog::Tracker.kind("github:acme/widget") end def test_accepts_repo_format assert Backlog::Tracker.valid?("repo:docs/issues") assert_equal :repo, Backlog::Tracker.kind("repo:docs/issues") end def test_rejects_garbage refute Backlog::Tracker.valid?("just some text") refute Backlog::Tracker.valid?("forgejo:missing-slash") refute Backlog::Tracker.valid?("") refute Backlog::Tracker.valid?(nil) end def test_rejects_unknown_prefix refute Backlog::Tracker.valid?("jira:PROJ-123") end def test_parse_remote_detects_forgejo_ssh_url output = "origin\tssh://git@forgejo.swansoncloud.com:2222/jared/cc-os.git (fetch)\n" \ "origin\tssh://git@forgejo.swansoncloud.com:2222/jared/cc-os.git (push)\n" info = Backlog::Tracker.parse_remote(output) assert_equal :forgejo, info[:kind] assert_equal "jared", info[:owner] assert_equal "cc-os", info[:repo] end def test_parse_remote_detects_github_https_url output = "origin\thttps://github.com/acme/widget.git (fetch)\n" info = Backlog::Tracker.parse_remote(output) assert_equal :github, info[:kind] assert_equal "acme", info[:owner] assert_equal "widget", info[:repo] end def test_parse_remote_detects_github_scp_url output = "origin\tgit@github.com:acme/widget.git (fetch)\n" info = Backlog::Tracker.parse_remote(output) assert_equal :github, info[:kind] assert_equal "acme", info[:owner] assert_equal "widget", info[:repo] end def test_parse_remote_classifies_other_hosts_as_unknown output = "origin\thttps://gitlab.com/acme/widget.git (fetch)\n" info = Backlog::Tracker.parse_remote(output) assert_equal :unknown, info[:kind] end def test_parse_remote_returns_nil_for_blank_output assert_nil Backlog::Tracker.parse_remote("") assert_nil Backlog::Tracker.parse_remote(nil) end end