Files
Libation/Source/_Tests/LibationCli.Tests/SetDownloadStatusOptionsTests.cs
T
Cursor Agentandrmcrackan e0c780c998 Make --download-pending the CLI flag, with --not-downloaded as a legacy alias
The status this flag sets is now called 'Download Pending', so -p /
--download-pending is the name the help offers.

-n / --not-downloaded keeps working. It is what years of scripts, forum
answers and issue comments tell people to run, so breaking it would cost
more than the inconsistency is worth. It is hidden from --help so the new
name is the only one advertised, and both flags feed one SetPending
property that the verb acts on.

All three names stay in the 'Download Status' option group, so 'at least
one status flag is required' still holds. That error message does
enumerate the group, which is the one place the legacy name still
surfaces.

Co-authored-by: rmcrackan <rmcrackan@gmail.com>
2026-08-25 02:42:56 +00:00

92 lines
2.7 KiB
C#

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Linq;
namespace LibationCli.Tests;
/// <summary>
/// The 'Not Downloaded' status was renamed 'Download Pending', so the flag that asks for it is now
/// --download-pending. The old --not-downloaded has to keep working: it is what years of scripts, forum
/// answers and issue comments tell people to run.
/// </summary>
[TestClass]
public class SetDownloadStatusOptionsTests
{
private static SetDownloadStatusOptions Parse(params string[] args)
{
using var error = new StringWriter();
var options = Program.ParseInvocation(args, error).Result?.Value as SetDownloadStatusOptions;
Assert.IsNotNull(options);
return options;
}
[TestMethod]
[DataRow("--download-pending")]
[DataRow("-p")]
public void The_new_flag_asks_for_download_pending(string flag)
{
var options = Parse("set-status", flag);
Assert.IsTrue(options.SetPending);
Assert.IsFalse(options.SetDownloaded);
}
[TestMethod]
[DataRow("--not-downloaded")]
[DataRow("-n")]
public void The_legacy_flag_still_asks_for_the_same_thing(string flag)
{
var options = Parse("set-status", flag);
Assert.IsTrue(options.SetPending);
Assert.IsFalse(options.SetDownloaded);
}
[TestMethod]
public void Downloaded_on_its_own_asks_for_nothing_pending()
{
var options = Parse("set-status", "--downloaded");
Assert.IsTrue(options.SetDownloaded);
Assert.IsFalse(options.SetPending);
}
[TestMethod]
[DataRow("--download-pending")]
[DataRow("--not-downloaded")]
public void Both_statuses_can_still_be_set_in_one_run(string pendingFlag)
{
var options = Parse("set-status", "--downloaded", pendingFlag);
Assert.IsTrue(options.SetDownloaded);
Assert.IsTrue(options.SetPending);
}
[TestMethod]
public void A_run_naming_no_status_is_still_rejected()
{
// The two names live in one option group, so adding the legacy alias must not make the group
// satisfiable by nothing at all.
using var error = new StringWriter();
var outcome = Program.ParseInvocation(["set-status"], error);
Assert.AreEqual(ExitCode.ParseError, outcome.ExitCode);
}
[TestMethod]
public void Help_offers_the_new_name_and_keeps_the_legacy_one_out_of_sight()
{
var help = new HelpVerb { HelpType = "set-status" }.GetHelpText().ToString();
StringAssert.Contains(help, "--download-pending");
Assert.IsFalse(
help.Contains("--not-downloaded"),
"The legacy alias should keep working without being advertised as a second way to do this.");
}
[TestMethod]
public void Asins_are_still_read_alongside_the_new_flag()
{
var options = Parse("set-status", "-p", "B017V4IM1G");
Assert.IsTrue(options.SetPending);
CollectionAssert.AreEqual(new[] { "B017V4IM1G" }, options.Asins?.ToArray());
}
}