-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathWSLCE2EGlobalTests.cpp
More file actions
121 lines (102 loc) · 3.84 KB
/
WSLCE2EGlobalTests.cpp
File metadata and controls
121 lines (102 loc) · 3.84 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*++
Copyright (c) Microsoft. All rights reserved.
Module Name:
WSLCE2EGlobalTests.cpp
Abstract:
This file contains end-to-end tests for WSLC.
--*/
#include "precomp.h"
#include "windows/Common.h"
#include "WSLCCLITestHelpers.h"
#include "WSLCExecutor.h"
namespace WSLCE2ETests {
class WSLCE2EGlobalTests
{
WSLC_TEST_CLASS(WSLCE2EGlobalTests)
TEST_CLASS_SETUP(TestClassSetup)
{
return true;
}
TEST_CLASS_CLEANUP(TestClassCleanup)
{
return true;
}
TEST_METHOD(WSLCE2E_HelpCommand)
{
WSL2_TEST_ONLY();
RunWslcAndVerify(L"--help", {.Stdout = GetHelpMessage(), .Stderr = L"", .ExitCode = 0});
}
TEST_METHOD(WSLCE2E_InvalidCommand_DisplaysErrorMessage)
{
WSL2_TEST_ONLY();
RunWslcAndVerify(L"INVALID_CMD", {.Stdout = GetHelpMessage(), .Stderr = L"Unrecognized command: 'INVALID_CMD'\r\n", .ExitCode = 1});
}
TEST_METHOD(WSLCE2E_VersionCommand)
{
WSL2_TEST_ONLY();
RunWslcAndVerify(L"version", {.Stdout = GetVersionMessage(), .Stderr = L"", .ExitCode = 0});
}
private:
std::wstring GetHelpMessage() const
{
std::wstringstream output;
output << GetWslcHeader() //
<< GetDescription() //
<< GetUsage() //
<< GetAvailableCommands() //
<< GetAvailableOptions();
return output.str();
}
std::wstring GetVersionMessage() const
{
return std::format(L"wslc v{}\r\n", WSL_PACKAGE_VERSION);
}
std::wstring GetDescription() const
{
return L"WSLC is the Windows Subsystem for Linux Container CLI tool. It enables management and interaction with WSL "
L"containers from the command line.\r\n\r\n";
}
std::wstring GetUsage() const
{
return L"Usage: wslc [<command>] [<options>]\r\n\r\n";
}
std::wstring GetAvailableCommands() const
{
std::wstringstream commands;
commands << L"The following commands are available:\r\n"
<< L" container Container command.\r\n"
<< L" image Image command.\r\n"
<< L" session Session command.\r\n"
<< L" settings Open the settings file in the default editor.\r\n"
<< L" attach Attach to a container.\r\n"
<< L" build Build an image from a Dockerfile.\r\n"
<< L" create Create a container.\r\n"
<< L" exec Execute a command in a running container.\r\n"
<< L" images List images.\r\n"
<< L" inspect Inspect a container.\r\n"
<< L" kill Kill containers.\r\n"
<< L" list List containers.\r\n"
<< L" load Load images.\r\n"
<< L" logs View container logs.\r\n"
<< L" pull Pull images.\r\n"
<< L" remove Remove containers.\r\n"
<< L" rmi Remove images.\r\n"
<< L" run Run a container.\r\n"
<< L" start Start a container.\r\n"
<< L" stop Stop containers.\r\n"
<< L" version Show version information.\r\n"
<< L"\r\n"
<< L"For more details on a specific command, pass it the help argument. [-h]\r\n\r\n";
return commands.str();
}
std::wstring GetAvailableOptions() const
{
std::wstringstream options;
options << L"The following options are available:\r\n"
<< L" -v,--version Show version information for this tool\r\n"
<< L" -h,--help Shows help about the selected command\r\n"
<< L"\r\n";
return options.str();
}
};
} // namespace WSLCE2ETests