DesktopCommandTests.cs 3.0 KB

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