ShowFlow.cpp (4644B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #include "pch.h" 4 #include "WorkflowCommon.h" 5 #include <Commands/ShowCommand.h> 6 #include <Workflows/ShowFlow.h> 7 8 using namespace TestCommon; 9 using namespace AppInstaller::CLI; 10 11 TEST_CASE("ShowFlow_SearchAndShowAppInfo", "[ShowFlow][workflow]") 12 { 13 std::ostringstream showOutput; 14 TestContext context{ showOutput, std::cin }; 15 auto previousThreadGlobals = context.SetForCurrentThread(); 16 OverrideForOpenSource(context, CreateTestSource({ TSR::TestQuery_ReturnOne })); 17 context.Args.AddArg(Execution::Args::Type::Query, TSR::TestQuery_ReturnOne.Query); 18 19 ShowCommand show({}); 20 show.Execute(context); 21 INFO(showOutput.str()); 22 23 // Verify AppInfo is printed 24 REQUIRE(showOutput.str().find("AppInstallerCliTest.TestExeInstaller") != std::string::npos); 25 REQUIRE(showOutput.str().find("AppInstaller Test Exe Installer") != std::string::npos); 26 REQUIRE(showOutput.str().find("1.0.0.0") != std::string::npos); 27 REQUIRE(showOutput.str().find("https://ThisIsNotUsed") != std::string::npos); 28 } 29 30 TEST_CASE("ShowFlow_SearchAndShowAppVersion", "[ShowFlow][workflow]") 31 { 32 std::ostringstream showOutput; 33 TestContext context{ showOutput, std::cin }; 34 auto previousThreadGlobals = context.SetForCurrentThread(); 35 OverrideForOpenSource(context, CreateTestSource({ TSR::TestQuery_ReturnOne })); 36 context.Args.AddArg(Execution::Args::Type::Query, TSR::TestQuery_ReturnOne.Query); 37 context.Args.AddArg(Execution::Args::Type::ListVersions); 38 39 ShowCommand show({}); 40 show.Execute(context); 41 INFO(showOutput.str()); 42 43 // Verify App version is printed 44 REQUIRE(showOutput.str().find("1.0.0.0") != std::string::npos); 45 // No manifest info is printed 46 REQUIRE(showOutput.str().find(" Download Url: https://ThisIsNotUsed") == std::string::npos); 47 } 48 49 TEST_CASE("ShowFlow_Dependencies", "[ShowFlow][workflow][dependencies]") 50 { 51 std::ostringstream showOutput; 52 TestContext context{ showOutput, std::cin }; 53 auto previousThreadGlobals = context.SetForCurrentThread(); 54 context.Args.AddArg(Execution::Args::Type::Manifest, TestDataFile("Manifest-Good-AllDependencyTypes.yaml").GetPath().u8string()); 55 56 ShowCommand show({}); 57 show.Execute(context); 58 INFO(showOutput.str()); 59 60 // Verify all types of dependencies are printed 61 REQUIRE(showOutput.str().find("Dependencies") != std::string::npos); 62 REQUIRE(showOutput.str().find("WindowsFeaturesDep") != std::string::npos); 63 REQUIRE(showOutput.str().find("WindowsLibrariesDep") != std::string::npos); 64 // PackageDep1 has minimum version (1.0), PackageDep2 doesn't (shouldn't show [>=...]) 65 REQUIRE(showOutput.str().find("Package.Dep1-x64 [>= 1.0]") != std::string::npos); 66 REQUIRE(showOutput.str().find("Package.Dep2-x64") != std::string::npos); 67 REQUIRE(showOutput.str().find("Package.Dep2-x64 [") == std::string::npos); 68 REQUIRE(showOutput.str().find("ExternalDep") != std::string::npos); 69 } 70 71 TEST_CASE("ShowFlow_InstallerType", "[ShowFlow][workflow]") 72 { 73 std::ostringstream showOutput; 74 TestContext context{ showOutput, std::cin }; 75 auto previousThreadGlobals = context.SetForCurrentThread(); 76 context.Args.AddArg(Execution::Args::Type::Manifest, TestDataFile("InstallFlowTest_Exe.yaml").GetPath().u8string()); 77 78 ShowCommand show({}); 79 show.Execute(context); 80 INFO(showOutput.str()); 81 82 // Verify that just the base installed type is shown; 83 REQUIRE(showOutput.str().find(Resource::LocString(Resource::String::ShowLabelInstallerType)) != std::string::npos); 84 REQUIRE(showOutput.str().find("exe") != std::string::npos); 85 86 // If the base installer is incorrectly shown, an open parenthesis would appear after the effective installer type 87 REQUIRE(showOutput.str().find("exe (") == std::string::npos); 88 } 89 90 TEST_CASE("ShowFlow_NestedInstallerType", "[ShowFlow][workflow]") 91 { 92 std::ostringstream showOutput; 93 TestContext context{ showOutput, std::cin }; 94 auto previousThreadGlobals = context.SetForCurrentThread(); 95 context.Args.AddArg(Execution::Args::Type::Manifest, TestDataFile("InstallFlowTest_Zip_Exe.yaml").GetPath().u8string()); 96 97 ShowCommand show({}); 98 show.Execute(context); 99 INFO(showOutput.str()); 100 101 // Verify that both the effective and base installer types are shown 102 REQUIRE(showOutput.str().find(Resource::LocString(Resource::String::ShowLabelInstallerType)) != std::string::npos); 103 REQUIRE(showOutput.str().find("exe (zip)") != std::string::npos); 104 }