aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/commands.cpp
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2020-08-01 13:45:17 -0700
committerGitHub <noreply@github.com>2020-08-01 13:45:17 -0700
commit54ec974afefae1864b423335ba8bcb64291d2317 (patch)
tree24443f5bcb949a06aa5edef8850a7e633baa6a6f /toolsrc/src/vcpkg-test/commands.cpp
parent00e44369cb23f911821ee96888cbb4785810ba07 (diff)
downloadvcpkg-54ec974afefae1864b423335ba8bcb64291d2317.tar.gz
vcpkg-54ec974afefae1864b423335ba8bcb64291d2317.zip
[vcpkg] Refactor commands 2: Electric Boogaloo (#12641)
* Add BasicCommand and VersionCommand * Add ContactCommand * test get_available_commands_type_c * Change get_available_commands_type_c to return objects * Add TripletCommand & InstallCommand * Add SetInstalledCommand * add linking tests * Add CICommand * Add remaining *Command objects * Add tests for commands_type_a * Move over to using const TripletCommand* for commands_type_a * Add PathsCommand * Add SearchCommand * add test for commands_type_b * add *Command for all type b commands * Switch from function pointers to PathsCommand for everything * format * rename get_available_commands also remove CommandType* types
Diffstat (limited to 'toolsrc/src/vcpkg-test/commands.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/commands.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-test/commands.cpp b/toolsrc/src/vcpkg-test/commands.cpp
new file mode 100644
index 000000000..eeefa3098
--- /dev/null
+++ b/toolsrc/src/vcpkg-test/commands.cpp
@@ -0,0 +1,68 @@
+#include <catch2/catch.hpp>
+
+#include <vcpkg/commands.contact.h>
+#include <vcpkg/commands.h>
+#include <vcpkg/commands.version.h>
+
+using namespace vcpkg;
+
+TEST_CASE ("test commands are constructible", "[commands]")
+{
+ Commands::Contact::ContactCommand contact{};
+ Commands::Version::VersionCommand version{};
+}
+
+TEST_CASE ("get_available_basic_commands works", "[commands]")
+{
+ auto commands_list = Commands::get_available_basic_commands();
+ CHECK(commands_list.size() == 2);
+ CHECK(Commands::find("version", commands_list) != nullptr);
+ CHECK(Commands::find("contact", commands_list) != nullptr);
+ CHECK(Commands::find("aang", commands_list) == nullptr);
+}
+
+TEST_CASE ("get_available_paths_commands works", "[commands]")
+{
+ auto commands_list = Commands::get_available_paths_commands();
+ CHECK(commands_list.size() == 18);
+
+ CHECK(Commands::find("/?", commands_list) != nullptr);
+ CHECK(Commands::find("help", commands_list) != nullptr);
+ CHECK(Commands::find("search", commands_list) != nullptr);
+ CHECK(Commands::find("list", commands_list) != nullptr);
+ CHECK(Commands::find("integrate", commands_list) != nullptr);
+ CHECK(Commands::find("owns", commands_list) != nullptr);
+ CHECK(Commands::find("update", commands_list) != nullptr);
+ CHECK(Commands::find("edit", commands_list) != nullptr);
+ CHECK(Commands::find("create", commands_list) != nullptr);
+ CHECK(Commands::find("cache", commands_list) != nullptr);
+ CHECK(Commands::find("portsdiff", commands_list) != nullptr);
+ CHECK(Commands::find("autocomplete", commands_list) != nullptr);
+ CHECK(Commands::find("hash", commands_list) != nullptr);
+ CHECK(Commands::find("fetch", commands_list) != nullptr);
+ CHECK(Commands::find("x-ci-clean", commands_list) != nullptr);
+ CHECK(Commands::find("x-history", commands_list) != nullptr);
+ CHECK(Commands::find("x-vsinstances", commands_list) != nullptr);
+ CHECK(Commands::find("x-format-manifest", commands_list) != nullptr);
+
+ CHECK(Commands::find("korra", commands_list) == nullptr);
+}
+
+TEST_CASE ("get_available_commands_type_a works", "[commands]")
+{
+ auto commands_list = Commands::get_available_triplet_commands();
+ CHECK(commands_list.size() == 10);
+
+ CHECK(Commands::find("install", commands_list) != nullptr);
+ CHECK(Commands::find("x-set-installed", commands_list) != nullptr);
+ CHECK(Commands::find("ci", commands_list) != nullptr);
+ CHECK(Commands::find("remove", commands_list) != nullptr);
+ CHECK(Commands::find("upgrade", commands_list) != nullptr);
+ CHECK(Commands::find("build", commands_list) != nullptr);
+ CHECK(Commands::find("env", commands_list) != nullptr);
+ CHECK(Commands::find("build-external", commands_list) != nullptr);
+ CHECK(Commands::find("export", commands_list) != nullptr);
+ CHECK(Commands::find("depend-info", commands_list) != nullptr);
+
+ CHECK(Commands::find("mai", commands_list) == nullptr);
+}