require_relative "test_helper" # Card #1818501985909868001: a mistaken flag-style invocation like # `os-backlog board-ensure --board apprise-api` must fail loudly with a # usage error instead of silently creating a Planka board literally named # "--board". These are CLI-contract tests (shell out to bin/os-backlog) # because the bug is about what the positional NAME arg parsing accepts # BEFORE any Planka client/network call is made — no PLANKA_* env vars are # set, so if validation didn't happen first, these would instead fail on # network auth with a different message. class BoardNameValidationCliTest < Minitest::Test BIN = File.expand_path("../bin/os-backlog", __dir__) # Strip any live Planka credentials from the child's env: these tests # assert that flag-like names are rejected BEFORE build_client ever runs, # so no test here may be allowed to reach the network even accidentally. def run_cli(*args) env = { "PLANKA_BASE_URL" => "", "PLANKA_USERNAME" => "", "PLANKA_PASSWORD" => "" } out = IO.popen(env, [RbConfig.ruby, BIN, *args], err: [:child, :out], &:read) [out, $?.exitstatus] end def test_board_ensure_rejects_flag_like_name out, status = run_cli("board-ensure", "--board", "apprise-api") refute_equal 0, status assert_match(/board name.*must not start with/i, out) end def test_activate_rejects_flag_like_name out, status = run_cli("activate", "--board") refute_equal 0, status assert_match(/board name.*must not start with/i, out) end def test_archive_rejects_flag_like_name out, status = run_cli("archive", "--board", "--yes") refute_equal 0, status assert_match(/board name.*must not start with/i, out) end def test_board_ensure_accepts_normal_name_and_fails_later_on_network out, status = run_cli("board-ensure", "apprise-api") refute_equal 0, status refute_match(/board name.*must not start with/i, out) end end