DesktopCommandTests.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Tests.EndToEnd.Infra;
  2. using Xunit.Abstractions;
  3. namespace Tests.EndToEnd.DesktopTests;
  4. [Collection("Yaml CLI tests")]
  5. public class DesktopCommandTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
  6. : IClassFixture<TempYamlCliFixture>
  7. {
  8. private async Task<(string, string)> ExecuteAsync(params string[] args)
  9. {
  10. var output = await YamlCliTestHost.RunAsync(
  11. args,
  12. fs.Root,
  13. outputHelper,
  14. "config.yaml"
  15. );
  16. var yaml = await File.ReadAllTextAsync(Path.Combine(fs.Root, "config.yaml"));
  17. return (output, yaml);
  18. }
  19. [Fact]
  20. public async Task describe_returns_detailed_information()
  21. {
  22. // given
  23. await ExecuteAsync("desktops", "add", "workstation01");
  24. await ExecuteAsync("desktops", "set", "workstation01", "--model", "Dell Precision 7960");
  25. // then
  26. var (output, _) = await ExecuteAsync("desktops", "describe", "workstation01");
  27. // when
  28. Assert.Contains("Name:", output);
  29. Assert.Contains("workstation01", output);
  30. Assert.Contains("Model:", output);
  31. Assert.Contains("Dell Precision 7960", output);
  32. }
  33. [Fact]
  34. public async Task help_outputs_do_not_throw()
  35. {
  36. Assert.Contains("Manage desktop computers", (await ExecuteAsync("desktops", "--help")).Item1);
  37. Assert.Contains("Add a new desktop", (await ExecuteAsync("desktops", "add", "--help")).Item1);
  38. Assert.Contains("Retrieve a desktop", (await ExecuteAsync("desktops", "get", "--help")).Item1);
  39. Assert.Contains("Show detailed information", (await ExecuteAsync("desktops", "describe", "--help")).Item1);
  40. Assert.Contains("Update properties", (await ExecuteAsync("desktops", "set", "--help")).Item1);
  41. Assert.Contains("Delete a desktop", (await ExecuteAsync("desktops", "del", "--help")).Item1);
  42. Assert.Contains("summarized hardware report", (await ExecuteAsync("desktops", "summary", "--help")).Item1);
  43. Assert.Contains("dependency tree", (await ExecuteAsync("desktops", "tree", "--help")).Item1);
  44. // Component help
  45. Assert.Contains("Manage CPUs", (await ExecuteAsync("desktops", "cpu", "--help")).Item1);
  46. Assert.Contains("Add a CPU", (await ExecuteAsync("desktops", "cpu", "add", "--help")).Item1);
  47. Assert.Contains("Update a desktop CPU", (await ExecuteAsync("desktops", "cpu", "set", "--help")).Item1);
  48. Assert.Contains("Manage storage drives", (await ExecuteAsync("desktops", "drive", "--help")).Item1);
  49. Assert.Contains("Add a drive", (await ExecuteAsync("desktops", "drive", "add", "--help")).Item1);
  50. Assert.Contains("Manage GPUs", (await ExecuteAsync("desktops", "gpu", "--help")).Item1);
  51. Assert.Contains("Add a GPU", (await ExecuteAsync("desktops", "gpu", "add", "--help")).Item1);
  52. Assert.Contains("Manage network interface cards", (await ExecuteAsync("desktops", "nic", "--help")).Item1);
  53. Assert.Contains("Add a NIC", (await ExecuteAsync("desktops", "nic", "add", "--help")).Item1);
  54. }
  55. }