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