From e88d5e6a0e08408c08bfbb904d6b1c8ff73af571 Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Mon, 10 Jan 2022 12:33:46 -0800 Subject: [PATCH 1/4] Improve and fix ResultType tests (#225) Signed-off-by: Louise Poubel --- src/FuelClient_TEST.cc | 100 ++++++++++++++++++++--------------------- src/Interface_TEST.cc | 24 +++++----- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/FuelClient_TEST.cc b/src/FuelClient_TEST.cc index 384a9a6c..9ed02443 100644 --- a/src/FuelClient_TEST.cc +++ b/src/FuelClient_TEST.cc @@ -417,13 +417,13 @@ TEST_F(FuelClientTest, DownloadModel) std::string cachedPath; Result res1 = client.CachedModel(url, cachedPath); EXPECT_FALSE(res1); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1); + EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type()); // Download std::string path; Result res2 = client.DownloadModel(url, path); EXPECT_TRUE(res2); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res2); + EXPECT_EQ(ResultType::FETCH, res2.Type()); // Check it was downloaded to `2` auto modelPath = common::joinPaths(common::cwd(), "test_cache", @@ -441,7 +441,7 @@ TEST_F(FuelClientTest, DownloadModel) // Check it is cached Result res3 = client.CachedModel(url, cachedPath); EXPECT_TRUE(res3); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res3.Type()); EXPECT_EQ(common::joinPaths(modelPath, "2"), cachedPath); } @@ -455,13 +455,13 @@ TEST_F(FuelClientTest, DownloadModel) std::string cachedPath; Result res1 = client.CachedModel(url, cachedPath); EXPECT_FALSE(res1); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1); + EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type()); // Download std::string path; Result res2 = client.DownloadModel(url, path); EXPECT_TRUE(res2); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res2); + EXPECT_EQ(ResultType::FETCH, res2.Type()); // Check it was downloaded to `2` auto modelPath = common::joinPaths(common::cwd(), "test_cache", @@ -479,7 +479,7 @@ TEST_F(FuelClientTest, DownloadModel) // Check it is cached Result res3 = client.CachedModel(url, cachedPath); EXPECT_TRUE(res3); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res3.Type()); EXPECT_EQ(common::joinPaths(modelPath, "2"), cachedPath); // Check that URIs have been updated. @@ -510,28 +510,28 @@ TEST_F(FuelClientTest, DownloadModel) std::string cachedPath; Result res1 = client.CachedModel(url, cachedPath); EXPECT_FALSE(res1); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1); + EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type()); // Check the dependency is not cached Result res2 = client.CachedModel(depUrl, cachedPath); EXPECT_FALSE(res2); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res2); + EXPECT_EQ(ResultType::FETCH_ERROR, res2.Type()); // Download std::string path; Result res3 = client.DownloadModel(url, path); EXPECT_TRUE(res3); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3); + EXPECT_EQ(ResultType::FETCH, res3.Type()); // Check it is cached Result res4 = client.CachedModel(url, cachedPath); EXPECT_TRUE(res4); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res4); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res4.Type()); // Check the dependency is cached Result res5 = client.CachedModel(depUrl, cachedPath); EXPECT_TRUE(res5); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res5); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res5.Type()); } // Download model with a dependency specified within its `model.config` @@ -545,28 +545,28 @@ TEST_F(FuelClientTest, DownloadModel) std::string cachedPath; Result res1 = client.CachedModel(url, cachedPath); EXPECT_FALSE(res1); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1); + EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type()); // Check the dependency is not cached Result res2 = client.CachedModel(depUrl, cachedPath); EXPECT_FALSE(res2); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res2); + EXPECT_EQ(ResultType::FETCH_ERROR, res2.Type()); // Download std::string path; Result res3 = client.DownloadModel(url, path); EXPECT_TRUE(res3); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3); + EXPECT_EQ(ResultType::FETCH, res3.Type()); // Check it is cached Result res4 = client.CachedModel(url, cachedPath); EXPECT_TRUE(res4); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res4); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res4.Type()); // Check the dependency is cached Result res5 = client.CachedModel(depUrl, cachedPath); EXPECT_TRUE(res5); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res5); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res5.Type()); } // Try using nonexistent URL @@ -577,7 +577,7 @@ TEST_F(FuelClientTest, DownloadModel) std::string path; Result result = client.DownloadModel(common::URI(url), path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Try using bad URL @@ -586,7 +586,7 @@ TEST_F(FuelClientTest, DownloadModel) std::string path; Result result = client.DownloadModel(common::URI(url), path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } } @@ -623,19 +623,19 @@ TEST_F(FuelClientTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(ModelDependencies)) std::string cachedPath; Result res1 = client.CachedModel(url, cachedPath); EXPECT_FALSE(res1); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1); + EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type()); // Check the dependency is not cached Result res2 = client.CachedModel(depUrl, cachedPath); EXPECT_FALSE(res2); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res2); + EXPECT_EQ(ResultType::FETCH_ERROR, res2.Type()); // Download on the model, do not download dependencies { std::vector dependencies; Result res3 = client.DownloadModel(id, {}, dependencies); EXPECT_TRUE(res3); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3); + EXPECT_EQ(ResultType::FETCH, res3.Type()); EXPECT_EQ(1u, dependencies.size()); } @@ -643,14 +643,14 @@ TEST_F(FuelClientTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(ModelDependencies)) { Result res4 = client.CachedModel(url, cachedPath); EXPECT_TRUE(res4); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res4); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res4.Type()); } // Check the dependency is not cached { Result res5 = client.CachedModel(depUrl, cachedPath); EXPECT_FALSE(res5); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res5); + EXPECT_EQ(ResultType::FETCH_ERROR, res5.Type()); } // Check that the dependencies are populated @@ -687,7 +687,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModel(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "alice", "models", "My Model", "3"), path); } @@ -698,7 +698,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModel(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "alice", "models", "My Model", "3"), path); } @@ -709,7 +709,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModel(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "alice", "models", "My Model", "2"), path); } @@ -721,7 +721,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModelFile(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "alice", "models", "My Model", "3", "model.sdf"), path); } @@ -733,7 +733,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModelFile(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "alice", "models", "My Model", "2", "meshes", "model.dae"), path); } @@ -744,7 +744,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModel(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Non-cached model (when looking for file) @@ -753,7 +753,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModelFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Non-cached model file @@ -764,7 +764,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModelFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Model root URL to model file @@ -773,7 +773,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModelFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Bad model URL @@ -782,7 +782,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModel(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Bad model file URL @@ -791,7 +791,7 @@ TEST_F(FuelClientTest, CachedModel) std::string path; auto result = client.CachedModelFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } } @@ -1086,13 +1086,13 @@ TEST_F(FuelClientTest, DownloadWorld) std::string cachedPath; auto res1 = client.CachedWorld(url, cachedPath); EXPECT_FALSE(res1); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res1); + EXPECT_EQ(ResultType::FETCH_ERROR, res1.Type()); // Download std::string path; auto res2 = client.DownloadWorld(url, path); EXPECT_TRUE(res2); - EXPECT_EQ(Result(ResultType::FETCH), res2); + EXPECT_EQ(ResultType::FETCH, res2.Type()); // Check it was downloaded to `1` auto worldPath = common::joinPaths(common::cwd(), "test_cache", @@ -1108,7 +1108,7 @@ TEST_F(FuelClientTest, DownloadWorld) // Check it is cached auto res3 = client.CachedWorld(url, cachedPath); EXPECT_TRUE(res3); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res3.Type()); EXPECT_EQ(common::joinPaths(worldPath, "2"), cachedPath); } @@ -1119,7 +1119,7 @@ TEST_F(FuelClientTest, DownloadWorld) std::string path; auto result = client.DownloadWorld(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Try using bad URL @@ -1128,7 +1128,7 @@ TEST_F(FuelClientTest, DownloadWorld) std::string path; auto result = client.DownloadWorld(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } } @@ -1155,7 +1155,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorld(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "banana", "worlds", "My World", "3"), path); } @@ -1166,7 +1166,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorld(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "banana", "worlds", "My World", "3"), path); } @@ -1177,7 +1177,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorld(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "banana", "worlds", "My World", "2"), path); } @@ -1189,7 +1189,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorldFile(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "banana", "worlds", "My World", "3", "strawberry.world"), path); @@ -1202,7 +1202,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorldFile(url, path); EXPECT_TRUE(result); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), result); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, result.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "localhost:8007", "banana", "worlds", "My World", "2", "strawberry.world"), path); @@ -1214,7 +1214,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorld(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Non-cached world (when looking for file) @@ -1224,7 +1224,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorldFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Non-cached world file @@ -1234,7 +1234,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorldFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // World root URL to world file @@ -1243,7 +1243,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorldFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Bad world URL @@ -1252,7 +1252,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorld(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } // Bad world file URL @@ -1261,7 +1261,7 @@ TEST_F(FuelClientTest, CachedWorld) std::string path; auto result = client.CachedWorldFile(url, path); EXPECT_FALSE(result); - EXPECT_EQ(Result(ResultType::FETCH_ERROR), result); + EXPECT_EQ(ResultType::FETCH_ERROR, result.Type()); } } diff --git a/src/Interface_TEST.cc b/src/Interface_TEST.cc index 4f342f17..9707a3a4 100644 --- a/src/Interface_TEST.cc +++ b/src/Interface_TEST.cc @@ -64,7 +64,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedModel(modelUrl, cachedPath); EXPECT_FALSE(res) << "Cached Path: " << cachedPath; - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res); + EXPECT_EQ(ResultType::FETCH_ERROR, res.Type()); } // Download model @@ -92,7 +92,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedModel(modelUrl, cachedPath); EXPECT_TRUE(res); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "fuel.ignitionrobotics.org", "chapulina", "models", "test box", "2"), cachedPath); @@ -111,12 +111,12 @@ TEST(Interface, FetchResources) { Result res = client.CachedModel(modelUrl, cachedPath); EXPECT_FALSE(res) << "Cached Path: " << cachedPath; - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res); + EXPECT_EQ(ResultType::FETCH_ERROR, res.Type()); } { Result res = client.CachedModelFile(modelFileUrl, cachedPath); EXPECT_FALSE(res) << "Cached Path: " << cachedPath; - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res); + EXPECT_EQ(ResultType::FETCH_ERROR, res.Type()); } // Download model file @@ -150,7 +150,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedModel(modelUrl, cachedPath); EXPECT_TRUE(res); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "fuel.ignitionrobotics.org", "openrobotics", "models", "bus", "1"), cachedPath); @@ -160,7 +160,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedModelFile(modelFileUrl, cachedPath); EXPECT_TRUE(res); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "fuel.ignitionrobotics.org", "openrobotics", "models", "bus", "1", "meshes", "bus.obj"), cachedPath); @@ -175,7 +175,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedWorld(worldUrl, cachedPath); EXPECT_FALSE(res) << "Cached Path: " << cachedPath; - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res); + EXPECT_EQ(ResultType::FETCH_ERROR, res.Type()); } // Download world @@ -196,7 +196,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedWorld(worldUrl, cachedPath); EXPECT_TRUE(res); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"), cachedPath); @@ -215,12 +215,12 @@ TEST(Interface, FetchResources) { Result res = client.CachedWorld(worldUrl, cachedPath); EXPECT_FALSE(res) << "Cached Path: " << cachedPath; - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res); + EXPECT_EQ(ResultType::FETCH_ERROR, res.Type()); } { Result res = client.CachedWorldFile(worldFileUrl, cachedPath); EXPECT_FALSE(res) << "Cached Path: " << cachedPath; - EXPECT_EQ(Result(ResultType::FETCH_ERROR), res); + EXPECT_EQ(ResultType::FETCH_ERROR, res.Type()); } // Download world file @@ -241,7 +241,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedWorld(worldUrl, cachedPath); EXPECT_TRUE(res); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "fuel.ignitionrobotics.org", "chapulina", "worlds", "test world", "2"), cachedPath); @@ -251,7 +251,7 @@ TEST(Interface, FetchResources) { Result res = client.CachedWorldFile(worldFileUrl, cachedPath); EXPECT_TRUE(res); - EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res); + EXPECT_EQ(ResultType::FETCH_ALREADY_EXISTS, res.Type()); EXPECT_EQ(common::joinPaths(common::cwd(), "test_cache", "fuel.ignitionrobotics.org", "chapulina", "worlds", "test world", "2", "thumbnails", "1.png"), cachedPath); From 3ea0844f86182713ccce5d9e24dc99a10e6f19bd Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 11 Jan 2022 10:34:15 -0800 Subject: [PATCH 2/4] Move test cache to build folder (#222) Signed-off-by: Louise Poubel --- src/ign_src_TEST.cc | 518 ++++++++++++++++---------------------------- 1 file changed, 189 insertions(+), 329 deletions(-) diff --git a/src/ign_src_TEST.cc b/src/ign_src_TEST.cc index f5d16e0c..75bf2c24 100644 --- a/src/ign_src_TEST.cc +++ b/src/ign_src_TEST.cc @@ -33,220 +33,180 @@ static std::streambuf *g_stdOutFile; static std::streambuf *g_stdErrFile; ///////////////////////////////////////////////// -// \brief Redirect stdout and stderr to streams. -void redirectIO(std::stringstream &_stdOutBuffer, - std::stringstream &_stdErrBuffer) +class CmdLine : public ::testing::Test { - g_stdOutFile = std::cout.rdbuf(_stdOutBuffer.rdbuf()); - g_stdErrFile = std::cerr.rdbuf(_stdErrBuffer.rdbuf()); -} - -///////////////////////////////////////////////// -// \brief Clear all streams (including state flags). -void clearIOStreams(std::stringstream &_stdOutBuffer, - std::stringstream &_stdErrBuffer) -{ - _stdOutBuffer.str(""); - _stdOutBuffer.clear(); - _stdErrBuffer.str(""); - _stdErrBuffer.clear(); -} - -///////////////////////////////////////////////// -/// \brief Restore stdout and stderr redirections. -void restoreIO() -{ - std::cout.rdbuf(g_stdOutFile); - std::cerr.rdbuf(g_stdErrFile); -} + // Documentation inherited + public: void SetUp() override + { + cmdVerbosity("4"); + + // Redirect stdout and stderr to streams. + g_stdOutFile = std::cout.rdbuf(this->stdOutBuffer.rdbuf()); + g_stdErrFile = std::cerr.rdbuf(this->stdErrBuffer.rdbuf()); + + this->testCachePath = common::joinPaths(std::string(PROJECT_BINARY_PATH), + "test_cache"); + + // Clear and recreate the cache at the start of every test. Doing it here + // instead of on teardown leaves the folder intact for debugging if needed + common::removeAll(testCachePath); + common::createDirectories(testCachePath); + setenv("IGN_FUEL_CACHE_PATH", this->testCachePath.c_str(), true); + } + + // Documentation inherited + public: void TearDown() override + { + // Clear all streams (including state flags). + this->stdOutBuffer.str(""); + this->stdOutBuffer.clear(); + this->stdErrBuffer.str(""); + this->stdErrBuffer.clear(); + + // Restore stdout and stderr redirections. + std::cout.rdbuf(g_stdOutFile); + std::cerr.rdbuf(g_stdErrFile); + } + + /// \brief Buffer for std::cout + public: std::stringstream stdOutBuffer; + + /// \brief Buffer for std::cerr + public: std::stringstream stdErrBuffer; + + /// \brief Path for a test cache within the build folder + public: std::string testCachePath; +}; ///////////////////////////////////////////////// -TEST(CmdLine, ModelListFail) +TEST_F(CmdLine, ModelListFail) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_FALSE(listModels("fake_url")); - EXPECT_NE(stdOutBuffer.str().find("Invalid URL"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("Invalid URL"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(CmdLine, ModelListConfigServerUgly) +TEST_F(CmdLine, ModelListConfigServerUgly) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_TRUE(listModels("", "", "true")); - EXPECT_NE(stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find("owners"), std::string::npos) - << stdOutBuffer.str(); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find("owners"), std::string::npos) + << this->stdOutBuffer.str(); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(CmdLine, ModelListConfigServerPretty) +TEST_F(CmdLine, ModelListConfigServerPretty) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_TRUE(listModels("https://staging-fuel.ignitionrobotics.org")); - EXPECT_NE(stdOutBuffer.str().find( + EXPECT_NE(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("owners"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("models"), std::string::npos) - << stdOutBuffer.str(); - - EXPECT_EQ(stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find( + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("owners"), std::string::npos) + << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("models"), std::string::npos) + << this->stdOutBuffer.str(); + + EXPECT_EQ(this->stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org/1.0/"), std::string::npos) - << stdOutBuffer.str(); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + << this->stdOutBuffer.str(); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(CmdLine, ModelListConfigServerPrettyOwner) +TEST_F(CmdLine, ModelListConfigServerPrettyOwner) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_TRUE(listModels("https://staging-fuel.ignitionrobotics.org", "openrobotics")); - EXPECT_NE(stdOutBuffer.str().find( + EXPECT_NE(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("1 owners"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("models"), std::string::npos) - << stdOutBuffer.str(); + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("1 owners"), std::string::npos) + << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("models"), std::string::npos) + << this->stdOutBuffer.str(); // If pagination fails, we only get the first 20 models - EXPECT_EQ(stdOutBuffer.str().find("20 models"), std::string::npos) - << stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find("20 models"), std::string::npos) + << this->stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find( + EXPECT_EQ(this->stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org/1.0/"), std::string::npos) - << stdOutBuffer.str(); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + << this->stdOutBuffer.str(); } ///////////////////////////////////////////////// -TEST(CmdLine, ModelDownloadBadUrl) +TEST_F(CmdLine, ModelDownloadBadUrl) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_FALSE(downloadUrl("fake_url")); - EXPECT_NE(stdOutBuffer.str().find("Malformed URL"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("Malformed URL"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()); } ///////////////////////////////////////////////// -TEST(CmdLine, ModelDownloadWrongUrl) +TEST_F(CmdLine, ModelDownloadWrongUrl) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_FALSE(downloadUrl( "https://site.com/1.0/ownername/modelname")); - EXPECT_NE(stdOutBuffer.str().find("Invalid URL"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("Invalid URL"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(CmdLine, ModelDownloadUnversioned) +TEST_F(CmdLine, ModelDownloadUnversioned) { - cmdVerbosity("4"); - - ignition::common::removeAll("test_cache"); - ignition::common::createDirectories("test_cache"); - setenv("IGN_FUEL_CACHE_PATH", "test_cache", true); - - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - // Download EXPECT_TRUE(downloadUrl( "https://fuel.ignitionrobotics.org/1.0/chapulina/models/Test box")); // Check output - EXPECT_NE(stdOutBuffer.str().find("Download succeeded"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()) << stdErrBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("Download succeeded"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files EXPECT_TRUE(ignition::common::isDirectory( - "test_cache/fuel.ignitionrobotics.org/chapulina/models/test box")); + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", + "chapulina", "models", "test box"))); EXPECT_TRUE(ignition::common::isDirectory( - "test_cache/fuel.ignitionrobotics.org/chapulina/models/test box/2")); + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", + "chapulina", "models", "test box", "2"))); EXPECT_TRUE(ignition::common::isFile( - std::string("test_cache/fuel.ignitionrobotics.org/chapulina/models") + - "/test box/2/model.sdf")); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", + "chapulina", "models", "test box", "2", "model.sdf"))); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(CmdLine, DownloadConfigCache) +TEST_F(CmdLine, DownloadConfigCache) { - cmdVerbosity("4"); - unsetenv("IGN_FUEL_CACHE_PATH"); - ignition::common::removeAll("test_cache"); - ignition::common::createDirectories("test_cache"); // Test config std::ofstream ofs; - std::string testPath = common::joinPaths( - std::string(PROJECT_BINARY_PATH), "test_cache", "test_conf.yaml"); + auto testPath = common::joinPaths(this->testCachePath, "test_conf.yaml"); ofs.open(testPath, std::ofstream::out | std::ofstream::app); ofs << "---" << std::endl @@ -255,13 +215,10 @@ TEST(CmdLine, DownloadConfigCache) << " url: https://fuel.ignitionrobotics.org" << std::endl << "" << std::endl << "cache:" << std::endl - << " path: " << PROJECT_BINARY_PATH << "/test_cache" << std::endl + << " path: " << this->testCachePath << std::endl << std::endl; ofs.close(); - - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); + EXPECT_TRUE(common::exists(testPath)) << testPath; // Download EXPECT_TRUE(downloadUrl( @@ -269,199 +226,140 @@ TEST(CmdLine, DownloadConfigCache) testPath.c_str())); // Check output - EXPECT_NE(stdOutBuffer.str().find("Download succeeded"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()) << stdErrBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("Download succeeded"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files - auto modelPath = common::joinPaths(std::string(PROJECT_BINARY_PATH), - "test_cache", "fuel.ignitionrobotics.org", "chapulina", "models", - "test box"); + auto modelPath = common::joinPaths(this->testCachePath, + "fuel.ignitionrobotics.org", "chapulina", "models", "test box"); EXPECT_TRUE(ignition::common::isDirectory(modelPath)); EXPECT_TRUE(ignition::common::isDirectory(common::joinPaths(modelPath, "2"))); EXPECT_TRUE(ignition::common::isFile(common::joinPaths(modelPath, "2", "model.sdf"))); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); } ///////////////////////////////////////////////// -TEST(CmdLine, WorldListFail) +TEST_F(CmdLine, WorldListFail) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_FALSE(listWorlds("fake_url")); - EXPECT_NE(stdOutBuffer.str().find("Invalid URL"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("Invalid URL"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(FuelClientTest, WorldListConfigServerUgly) +TEST_F(CmdLine, WorldListConfigServerUgly) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_TRUE(listWorlds( "https://staging-fuel.ignitionrobotics.org", "", "true")); - EXPECT_NE(stdOutBuffer.str().find( + EXPECT_NE(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find("owners"), std::string::npos) - << stdOutBuffer.str(); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find("owners"), std::string::npos) + << this->stdOutBuffer.str(); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(FuelClientTest, WorldListConfigServerPretty) +TEST_F(CmdLine, WorldListConfigServerPretty) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_TRUE(listWorlds("https://staging-fuel.ignitionrobotics.org")); - EXPECT_NE(stdOutBuffer.str().find( + EXPECT_NE(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("owners"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("worlds"), std::string::npos) - << stdOutBuffer.str(); - - EXPECT_EQ(stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find( + << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("owners"), std::string::npos) + << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("worlds"), std::string::npos) + << this->stdOutBuffer.str(); + + EXPECT_EQ(this->stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org/1.0/"), std::string::npos) - << stdOutBuffer.str(); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + << this->stdOutBuffer.str(); } ///////////////////////////////////////////////// -TEST(CmdLine, WorldListCustomServerPrettyOwner) +TEST_F(CmdLine, WorldListCustomServerPrettyOwner) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_TRUE(listWorlds("https://staging-fuel.ignitionrobotics.org", "openrobotics")); - EXPECT_NE(stdOutBuffer.str().find( + EXPECT_NE(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_NE(stdOutBuffer.str().find("worlds"), std::string::npos) - << stdOutBuffer.str(); + << this->stdOutBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("worlds"), std::string::npos) + << this->stdOutBuffer.str(); // If pagination fails, we only get the first 20 worlds - EXPECT_EQ(stdOutBuffer.str().find("20 worlds"), std::string::npos) - << stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find("20 worlds"), std::string::npos) + << this->stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_EQ(stdOutBuffer.str().find( + EXPECT_EQ(this->stdOutBuffer.str().find("https://fuel.ignitionrobotics.org"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_EQ(this->stdOutBuffer.str().find( "https://staging-fuel.ignitionrobotics.org/1.0/"), std::string::npos) - << stdOutBuffer.str(); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + << this->stdOutBuffer.str(); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(FuelClientTest, WorldDownloadBadUrl) +TEST_F(CmdLine, WorldDownloadBadUrl) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_FALSE(downloadUrl("fake_url")); - EXPECT_NE(stdOutBuffer.str().find("Malformed URL"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("Malformed URL"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); } ///////////////////////////////////////////////// -TEST(CmdLine, WorldDownloadWrongUrl) +TEST_F(CmdLine, WorldDownloadWrongUrl) { - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - EXPECT_FALSE(downloadUrl( "https://site.com/1.0/ownername/worldname")); - EXPECT_NE(stdOutBuffer.str().find("Invalid URL"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); + EXPECT_NE(this->stdOutBuffer.str().find("Invalid URL"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); } ///////////////////////////////////////////////// // Protocol "https" not supported or disabled in libcurl for Windows // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 -TEST(FuelClientTest, WorldDownloadUnversioned) +TEST_F(CmdLine, WorldDownloadUnversioned) { - cmdVerbosity("4"); - - ignition::common::removeAll("test_cache"); - ignition::common::createDirectories("test_cache"); - setenv("IGN_FUEL_CACHE_PATH", "test_cache", true); - - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - // Download EXPECT_TRUE(downloadUrl( "https://fuel.ignitionrobotics.org/1.0/OpenRobotics/worlds/Test world")); // Check output - EXPECT_NE(stdOutBuffer.str().find("Download succeeded"), - std::string::npos) << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); + EXPECT_NE(this->stdOutBuffer.str().find("Download succeeded"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2", "test.world"))); - - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); } class DownloadCollectionTest - : public ::testing::Test, + : public CmdLine, public ::testing::WithParamInterface {}; @@ -473,16 +371,6 @@ INSTANTIATE_TEST_CASE_P(CollectionTest, DownloadCollectionTest, // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 TEST_P(DownloadCollectionTest, AllItems) { - cmdVerbosity("4"); - - ignition::common::removeAll("test_cache"); - ignition::common::createDirectories("test_cache"); - setenv("IGN_FUEL_CACHE_PATH", "test_cache", true); - - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - // Download EXPECT_TRUE( downloadUrl("https://fuel.ignitionrobotics.org/1.0/OpenRobotics/" @@ -490,57 +378,54 @@ TEST_P(DownloadCollectionTest, AllItems) nullptr, nullptr, nullptr, GetParam())); // Check output - EXPECT_NE(stdOutBuffer.str().find("Download succeeded"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()) - << stdErrBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("Download succeeded"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files // Model: Backpack EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2", "model.sdf"))); // Model: TEAMBASE EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2", "model.sdf"))); // World: Test World EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2", "test.world"))); // World: Test World 2 EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2", "test.world"))); - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); } ///////////////////////////////////////////////// @@ -549,16 +434,6 @@ TEST_P(DownloadCollectionTest, AllItems) // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 TEST_P(DownloadCollectionTest, Models) { - cmdVerbosity("4"); - - ignition::common::removeAll("test_cache"); - ignition::common::createDirectories("test_cache"); - setenv("IGN_FUEL_CACHE_PATH", "test_cache", true); - - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - // Download EXPECT_TRUE( downloadUrl("https://fuel.ignitionrobotics.org/1.0/OpenRobotics/" @@ -566,44 +441,42 @@ TEST_P(DownloadCollectionTest, Models) nullptr, nullptr, "model", GetParam())); // Check output - EXPECT_NE(stdOutBuffer.str().find("Download succeeded"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()); + EXPECT_NE(this->stdOutBuffer.str().find("Download succeeded"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files // Model: Backpack EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2", "model.sdf"))); // Model: TEAMBASE EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2", "model.sdf"))); // World: Test World EXPECT_FALSE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); // World: Test World 2 EXPECT_FALSE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world2"))); - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); } ///////////////////////////////////////////////// @@ -612,16 +485,6 @@ TEST_P(DownloadCollectionTest, Models) // https://github.com/ignitionrobotics/ign-fuel-tools/issues/105 TEST_P(DownloadCollectionTest, Worlds) { - cmdVerbosity("4"); - - ignition::common::removeAll("test_cache"); - ignition::common::createDirectories("test_cache"); - setenv("IGN_FUEL_CACHE_PATH", "test_cache", true); - - std::stringstream stdOutBuffer; - std::stringstream stdErrBuffer; - redirectIO(stdOutBuffer, stdErrBuffer); - // Download EXPECT_TRUE( downloadUrl("https://fuel.ignitionrobotics.org/1.0/OpenRobotics/" @@ -629,43 +492,40 @@ TEST_P(DownloadCollectionTest, Worlds) nullptr, nullptr, "world", GetParam())); // Check output - EXPECT_NE(stdOutBuffer.str().find("Download succeeded"), std::string::npos) - << stdOutBuffer.str(); - EXPECT_TRUE(stdErrBuffer.str().empty()) - << stdErrBuffer.str(); + EXPECT_NE(this->stdOutBuffer.str().find("Download succeeded"), + std::string::npos) << this->stdOutBuffer.str(); + EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files // Model: Backpack EXPECT_FALSE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack"))); // Model: TEAMBASE EXPECT_FALSE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase"))); // World: Test World EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2", "test.world"))); // World: Test World 2 EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2"))); EXPECT_TRUE(ignition::common::isDirectory( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2"))); EXPECT_TRUE(ignition::common::isFile( - ignition::common::joinPaths("test_cache", "fuel.ignitionrobotics.org", + common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2", "test.world"))); - clearIOStreams(stdOutBuffer, stdErrBuffer); - restoreIO(); } From ae90993ebfe92af80818ab0e7e7d746444fe917e Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 11 Jan 2022 11:01:54 -0800 Subject: [PATCH 3/4] More checks when manipulating file system in tests (#227) Signed-off-by: Louise Poubel --- src/ClientConfig_TEST.cc | 2 + src/FuelClient_TEST.cc | 41 ++++++----- src/Interface_TEST.cc | 2 +- src/LocalCache_TEST.cc | 152 ++++++++++++++++++--------------------- src/ign_src_TEST.cc | 76 ++++++++++---------- 5 files changed, 134 insertions(+), 139 deletions(-) diff --git a/src/ClientConfig_TEST.cc b/src/ClientConfig_TEST.cc index 24bb229e..8ce0ec9a 100644 --- a/src/ClientConfig_TEST.cc +++ b/src/ClientConfig_TEST.cc @@ -413,6 +413,8 @@ TEST(ServerConfig, Url) ServerConfig srv; srv.SetUrl(common::URI("http://banana:8080/")); EXPECT_EQ("http://banana:8080", srv.Url().Str()); + EXPECT_EQ("http", srv.Url().Scheme()); + EXPECT_EQ("banana:8080", srv.Url().Path().Str()); } // Set from URI diff --git a/src/FuelClient_TEST.cc b/src/FuelClient_TEST.cc index 9ed02443..111dd579 100644 --- a/src/FuelClient_TEST.cc +++ b/src/FuelClient_TEST.cc @@ -50,8 +50,10 @@ void createLocalModel(ClientConfig &_conf) auto modelPath = common::joinPaths( "test_cache", "localhost:8007", "alice", "models", "My Model"); - common::createDirectories(common::joinPaths(modelPath, "2", "meshes")); - common::createDirectories(common::joinPaths(modelPath, "3", "meshes")); + ASSERT_TRUE(common::createDirectories( + common::joinPaths(modelPath, "2", "meshes"))); + ASSERT_TRUE(common::createDirectories( + common::joinPaths(modelPath, "3", "meshes"))); { std::ofstream fout(common::joinPaths(modelPath, "2", "model.config"), @@ -60,8 +62,8 @@ void createLocalModel(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(modelPath, "2", "model.config"), - common::joinPaths(modelPath, "3", "model.config")); + ASSERT_TRUE(common::copyFile(common::joinPaths(modelPath, "2", + "model.config"), common::joinPaths(modelPath, "3", "model.config"))); } { @@ -71,8 +73,8 @@ void createLocalModel(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(modelPath, "2", "model.sdf"), - common::joinPaths(modelPath, "3", "model.sdf")); + ASSERT_TRUE(common::copyFile(common::joinPaths(modelPath, "2", "model.sdf"), + common::joinPaths(modelPath, "3", "model.sdf"))); } { @@ -82,8 +84,9 @@ void createLocalModel(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(modelPath, "2", "meshes", "model.dae"), - common::joinPaths(modelPath, "3", "meshes", "model.dae")); + ASSERT_TRUE(common::copyFile(common::joinPaths(modelPath, "2", "meshes", + "model.dae"), common::joinPaths(modelPath, "3", "meshes", + "model.dae"))); } ignition::fuel_tools::ServerConfig srv; @@ -102,8 +105,8 @@ void createLocalWorld(ClientConfig &_conf) auto worldPath = common::joinPaths( "test_cache", "localhost:8007", "banana", "worlds", "My World"); - common::createDirectories(common::joinPaths(worldPath, "2")); - common::createDirectories(common::joinPaths(worldPath, "3")); + ASSERT_TRUE(common::createDirectories(common::joinPaths(worldPath, "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(worldPath, "3"))); { std::ofstream fout(common::joinPaths(worldPath, "2", "strawberry.world"), @@ -112,8 +115,9 @@ void createLocalWorld(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(worldPath, "2", "strawberry.world"), - common::joinPaths(worldPath, "3", "strawberry.world")); + ASSERT_TRUE(common::copyFile(common::joinPaths(worldPath, "2", + "strawberry.world"), common::joinPaths(worldPath, "3", + "strawberry.world"))); } ignition::fuel_tools::ServerConfig srv; @@ -399,7 +403,7 @@ TEST_F(FuelClientTest, DownloadModel) // Configure to use binary path as cache ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig config; config.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); @@ -598,7 +602,7 @@ TEST_F(FuelClientTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(ModelDependencies)) // Configure to use binary path as cache ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig config; config.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); @@ -672,7 +676,7 @@ TEST_F(FuelClientTest, CachedModel) // Configure to use binary path as cache and populate it ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig config; config.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); createLocalModel(config); @@ -875,13 +879,14 @@ TEST_F(FuelClientTest, ParseWorldUrl) // * with client config // * without server API version // * with world version `tip` + // * with trailing / { ClientConfig config; FuelClient client(config); WorldIdentifier id; const common::URI url{ - "https://fuel.ignitionrobotics.org/german/worlds/Cardboard Box/tip"}; + "https://fuel.ignitionrobotics.org/german/worlds/Cardboard Box/tip/"}; EXPECT_TRUE(client.ParseWorldUrl(url, id)); EXPECT_EQ(id.Server().Url().Str(), "https://fuel.ignitionrobotics.org"); @@ -1062,7 +1067,7 @@ TEST_F(FuelClientTest, DownloadWorld) // Configure to use binary path as cache ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ServerConfig server; server.SetUrl(ignition::common::URI( @@ -1140,7 +1145,7 @@ TEST_F(FuelClientTest, CachedWorld) // Configure to use binary path as cache and populate it ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig config; config.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); createLocalWorld(config); diff --git a/src/Interface_TEST.cc b/src/Interface_TEST.cc index 9707a3a4..dba45ee6 100644 --- a/src/Interface_TEST.cc +++ b/src/Interface_TEST.cc @@ -46,7 +46,7 @@ TEST(Interface, FetchResources) // Configure to use binary path as cache ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig config; config.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); diff --git a/src/LocalCache_TEST.cc b/src/LocalCache_TEST.cc index d30fe045..011a9756 100644 --- a/src/LocalCache_TEST.cc +++ b/src/LocalCache_TEST.cc @@ -47,18 +47,18 @@ void createLocal6Models(ClientConfig &_conf) igndbg << "Creating 6 local models in [" << common::cwd() << "]" << std::endl; auto serverPath = common::joinPaths("test_cache", "localhost:8001"); - common::createDirectories(common::joinPaths(serverPath, - "alice", "models", "am1", "2")); - common::createDirectories(common::joinPaths(serverPath, - "alice", "models", "am2", "1")); - common::createDirectories(common::joinPaths(serverPath, - "bob", "models", "bm1", "1")); - common::createDirectories(common::joinPaths(serverPath, - "bob", "models", "bm2", "2")); - common::createDirectories(common::joinPaths(serverPath, - "trudy", "models", "tm1", "3")); - common::createDirectories(common::joinPaths(serverPath, - "trudy", "models", "tm2", "2")); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "alice", "models", "am1", "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "alice", "models", "am2", "1"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "bob", "models", "bm1", "1"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "bob", "models", "bm2", "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "trudy", "models", "tm1", "3"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "trudy", "models", "tm2", "2"))); std::ofstream fout(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), @@ -67,26 +67,26 @@ void createLocal6Models(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(serverPath, + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "alice", "models", "am2", "1", "model.config")); - common::copyFile(common::joinPaths(serverPath, + "alice", "models", "am2", "1", "model.config"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "bob", "models", "bm1", "1", "model.config")); - common::copyFile(common::joinPaths(serverPath, + "bob", "models", "bm1", "1", "model.config"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "bob", "models", "bm2", "2", "model.config")); - common::copyFile(common::joinPaths(serverPath, + "bob", "models", "bm2", "2", "model.config"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "trudy", "models", "tm1", "3", "model.config")); - common::copyFile(common::joinPaths(serverPath, + "trudy", "models", "tm1", "3", "model.config"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "trudy", "models", "tm2", "2", "model.config")); + "trudy", "models", "tm2", "2", "model.config"))); ignition::fuel_tools::ServerConfig srv; srv.SetUrl(common::URI("http://localhost:8001/")); @@ -99,12 +99,12 @@ void createLocal3Models(ClientConfig &_conf) igndbg << "Creating 3 local models in [" << common::cwd() << "]" << std::endl; auto serverPath = common::joinPaths("test_cache", "localhost:8007"); - common::createDirectories(common::joinPaths(serverPath, - "alice", "models", "am1", "2")); - common::createDirectories(common::joinPaths(serverPath, - "bob", "models", "bm1", "1")); - common::createDirectories(common::joinPaths(serverPath, - "trudy", "models", "tm1", "3")); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "alice", "models", "am1", "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "bob", "models", "bm1", "1"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "trudy", "models", "tm1", "3"))); std::ofstream fout(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), @@ -113,14 +113,14 @@ void createLocal3Models(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(serverPath, + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "bob", "models", "bm1", "1", "model.config")); - common::copyFile(common::joinPaths(serverPath, + "bob", "models", "bm1", "1", "model.config"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "models", "am1", "2", "model.config"), common::joinPaths(serverPath, - "trudy", "models", "tm1", "3", "model.config")); + "trudy", "models", "tm1", "3", "model.config"))); ignition::fuel_tools::ServerConfig srv; srv.SetUrl(ignition::common::URI("http://localhost:8007/")); @@ -133,18 +133,18 @@ void createLocal6Worlds(ClientConfig &_conf) igndbg << "Creating 6 local worlds in [" << common::cwd() << "]" << std::endl; auto serverPath = common::joinPaths("test_cache", "localhost:8001"); - common::createDirectories(common::joinPaths(serverPath, - "alice", "worlds", "am1", "2")); - common::createDirectories(common::joinPaths(serverPath, - "alice", "worlds", "am2", "1")); - common::createDirectories(common::joinPaths(serverPath, - "bob", "worlds", "bm1", "1")); - common::createDirectories(common::joinPaths(serverPath, - "bob", "worlds", "bm2", "2")); - common::createDirectories(common::joinPaths(serverPath, - "trudy", "worlds", "tm1", "3")); - common::createDirectories(common::joinPaths(serverPath, - "trudy", "worlds", "tm2", "2")); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "alice", "worlds", "am1", "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "alice", "worlds", "am2", "1"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "bob", "worlds", "bm1", "1"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "bob", "worlds", "bm2", "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "trudy", "worlds", "tm1", "3"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "trudy", "worlds", "tm2", "2"))); std::ofstream fout(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), @@ -153,26 +153,26 @@ void createLocal6Worlds(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(serverPath, + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "alice", "worlds", "am2", "1", "world.world")); - common::copyFile(common::joinPaths(serverPath, + "alice", "worlds", "am2", "1", "world.world"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "bob", "worlds", "bm1", "1", "world.world")); - common::copyFile(common::joinPaths(serverPath, + "bob", "worlds", "bm1", "1", "world.world"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "bob", "worlds", "bm2", "2", "world.world")); - common::copyFile(common::joinPaths(serverPath, + "bob", "worlds", "bm2", "2", "world.world"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "trudy", "worlds", "tm1", "3", "world.world")); - common::copyFile(common::joinPaths(serverPath, + "trudy", "worlds", "tm1", "3", "world.world"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "trudy", "worlds", "tm2", "2", "world.world")); + "trudy", "worlds", "tm2", "2", "world.world"))); ignition::fuel_tools::ServerConfig srv; srv.SetUrl(ignition::common::URI("http://localhost:8001/")); @@ -185,12 +185,12 @@ void createLocal3Worlds(ClientConfig &_conf) igndbg << "Creating 3 local worlds in [" << common::cwd() << "]" << std::endl; auto serverPath = common::joinPaths("test_cache", "localhost:8007"); - common::createDirectories(common::joinPaths(serverPath, - "alice", "worlds", "am1", "2")); - common::createDirectories(common::joinPaths(serverPath, - "bob", "worlds", "bm1", "1")); - common::createDirectories(common::joinPaths(serverPath, - "trudy", "worlds", "tm1", "3")); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "alice", "worlds", "am1", "2"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "bob", "worlds", "bm1", "1"))); + ASSERT_TRUE(common::createDirectories(common::joinPaths(serverPath, + "trudy", "worlds", "tm1", "3"))); std::ofstream fout(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), @@ -199,14 +199,14 @@ void createLocal3Worlds(ClientConfig &_conf) fout.flush(); fout.close(); - common::copyFile(common::joinPaths(serverPath, + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "bob", "worlds", "bm1", "1", "world.world")); - common::copyFile(common::joinPaths(serverPath, + "bob", "worlds", "bm1", "1", "world.world"))); + ASSERT_TRUE(common::copyFile(common::joinPaths(serverPath, "alice", "worlds", "am1", "2", "world.world"), common::joinPaths(serverPath, - "trudy", "worlds", "tm1", "3", "world.world")); + "trudy", "worlds", "tm1", "3", "world.world"))); ignition::fuel_tools::ServerConfig srv; srv.SetUrl(common::URI("http://localhost:8007/")); @@ -224,13 +224,11 @@ class LocalCacheTest : public ::testing::Test ///////////////////////////////////////////////// /// \brief Iterate through all models in cache -// Windows doesn't support colons in filenames -// https://github.com/ignitionrobotics/ign-fuel-tools/issues/106 TEST_F(LocalCacheTest, AllModels) { ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig conf; conf.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); createLocal6Models(conf); @@ -254,13 +252,11 @@ TEST_F(LocalCacheTest, AllModels) ///////////////////////////////////////////////// /// \brief Get all models that match some fields /// \brief Iterate through all models in cache -// Windows doesn't support colons in filenames -// https://github.com/ignitionrobotics/ign-fuel-tools/issues/106 TEST_F(LocalCacheTest, MatchingModels) { ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig conf; conf.Clear(); conf.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); @@ -302,13 +298,11 @@ TEST_F(LocalCacheTest, MatchingModels) ///////////////////////////////////////////////// /// \brief Get a specific model from cache /// \brief Iterate through all models in cache -// Windows doesn't support colons in filenames -// https://github.com/ignitionrobotics/ign-fuel-tools/issues/106 TEST_F(LocalCacheTest, MatchingModel) { ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig conf; conf.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); createLocal6Models(conf); @@ -360,13 +354,11 @@ TEST_F(LocalCacheTest, MatchingModel) ///////////////////////////////////////////////// /// \brief Iterate through all worlds in cache /// \brief Iterate through all models in cache -// Windows doesn't support colons in filenames -// https://github.com/ignitionrobotics/ign-fuel-tools/issues/106 TEST_F(LocalCacheTest, AllWorlds) { ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig conf; conf.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); createLocal6Worlds(conf); @@ -394,13 +386,11 @@ TEST_F(LocalCacheTest, AllWorlds) ///////////////////////////////////////////////// /// \brief Get all worlds that match some fields /// \brief Iterate through all models in cache -// Windows doesn't support colons in filenames -// https://github.com/ignitionrobotics/ign-fuel-tools/issues/106 TEST_F(LocalCacheTest, MatchingWorlds) { ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig conf; conf.Clear(); conf.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); @@ -430,13 +420,11 @@ TEST_F(LocalCacheTest, MatchingWorlds) ///////////////////////////////////////////////// /// \brief Get a specific world from cache /// \brief Iterate through all models in cache -// Windows doesn't support colons in filenames -// https://github.com/ignitionrobotics/ign-fuel-tools/issues/106 TEST_F(LocalCacheTest, MatchingWorld) { ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH)); common::removeAll("test_cache"); - common::createDirectories("test_cache"); + ASSERT_TRUE(common::createDirectories("test_cache")); ClientConfig conf; conf.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache")); createLocal6Worlds(conf); diff --git a/src/ign_src_TEST.cc b/src/ign_src_TEST.cc index 75bf2c24..a5df1bcb 100644 --- a/src/ign_src_TEST.cc +++ b/src/ign_src_TEST.cc @@ -50,7 +50,7 @@ class CmdLine : public ::testing::Test // Clear and recreate the cache at the start of every test. Doing it here // instead of on teardown leaves the folder intact for debugging if needed common::removeAll(testCachePath); - common::createDirectories(testCachePath); + ASSERT_TRUE(common::createDirectories(testCachePath)); setenv("IGN_FUEL_CACHE_PATH", this->testCachePath.c_str(), true); } @@ -186,13 +186,13 @@ TEST_F(CmdLine, ModelDownloadUnversioned) EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "chapulina", "models", "test box"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "chapulina", "models", "test box", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "chapulina", "models", "test box", "2", "model.sdf"))); } @@ -233,9 +233,9 @@ TEST_F(CmdLine, DownloadConfigCache) // Check files auto modelPath = common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "chapulina", "models", "test box"); - EXPECT_TRUE(ignition::common::isDirectory(modelPath)); - EXPECT_TRUE(ignition::common::isDirectory(common::joinPaths(modelPath, "2"))); - EXPECT_TRUE(ignition::common::isFile(common::joinPaths(modelPath, "2", + EXPECT_TRUE(common::isDirectory(modelPath)); + EXPECT_TRUE(common::isDirectory(common::joinPaths(modelPath, "2"))); + EXPECT_TRUE(common::isFile(common::joinPaths(modelPath, "2", "model.sdf"))); } @@ -347,13 +347,13 @@ TEST_F(CmdLine, WorldDownloadUnversioned) EXPECT_TRUE(this->stdErrBuffer.str().empty()) << this->stdErrBuffer.str(); // Check files - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2", "test.world"))); } @@ -384,46 +384,46 @@ TEST_P(DownloadCollectionTest, AllItems) // Check files // Model: Backpack - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2", "model.sdf"))); // Model: TEAMBASE - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2", "model.sdf"))); // World: Test World - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2", "test.world"))); // World: Test World 2 - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2", "test.world"))); } @@ -447,34 +447,34 @@ TEST_P(DownloadCollectionTest, Models) // Check files // Model: Backpack - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack", "2", "model.sdf"))); // Model: TEAMBASE - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase", "2", "model.sdf"))); // World: Test World - EXPECT_FALSE(ignition::common::isDirectory( + EXPECT_FALSE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); // World: Test World 2 - EXPECT_FALSE(ignition::common::isDirectory( + EXPECT_FALSE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world2"))); } @@ -498,34 +498,34 @@ TEST_P(DownloadCollectionTest, Worlds) // Check files // Model: Backpack - EXPECT_FALSE(ignition::common::isDirectory( + EXPECT_FALSE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "backpack"))); // Model: TEAMBASE - EXPECT_FALSE(ignition::common::isDirectory( + EXPECT_FALSE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "models", "teambase"))); // World: Test World - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world", "2", "test.world"))); // World: Test World 2 - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2"))); - EXPECT_TRUE(ignition::common::isDirectory( + EXPECT_TRUE(common::isDirectory( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2"))); - EXPECT_TRUE(ignition::common::isFile( + EXPECT_TRUE(common::isFile( common::joinPaths(this->testCachePath, "fuel.ignitionrobotics.org", "openrobotics", "worlds", "test world 2", "2", "test.world"))); } From 2a8f8e66df8605b6ca97e95ea472447ad854b9c6 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Mon, 7 Mar 2022 09:12:14 -0800 Subject: [PATCH 4/4] Fix trailing slashes in failing tests (#237) Follow up to ignitionrobotics/ign-common#275 Signed-off-by: Steve Peters --- src/ClientConfig_TEST.cc | 4 ++-- src/LocalCache_TEST.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ClientConfig_TEST.cc b/src/ClientConfig_TEST.cc index 36e3799a..826c990e 100644 --- a/src/ClientConfig_TEST.cc +++ b/src/ClientConfig_TEST.cc @@ -413,9 +413,9 @@ TEST(ServerConfig, Url) { ServerConfig srv; srv.SetUrl(common::URI("http://banana:8080/")); - EXPECT_EQ("http://banana:8080", srv.Url().Str()); + EXPECT_EQ("http://banana:8080/", srv.Url().Str()); EXPECT_EQ("http", srv.Url().Scheme()); - EXPECT_EQ("banana:8080", srv.Url().Path().Str()); + EXPECT_EQ("banana:8080/", srv.Url().Path().Str()); EXPECT_FALSE(srv.Url().Authority()); } diff --git a/src/LocalCache_TEST.cc b/src/LocalCache_TEST.cc index 683f19c8..c44a0185 100644 --- a/src/LocalCache_TEST.cc +++ b/src/LocalCache_TEST.cc @@ -351,7 +351,7 @@ TEST_F(LocalCacheTest, MatchingModel) ASSERT_TRUE(am1Model); EXPECT_EQ("alice", am1Model.Identification().Owner()); EXPECT_EQ("am1", am1Model.Identification().Name()); - EXPECT_EQ("http://localhost:8001", + EXPECT_EQ("http://localhost:8001/", am1Model.Identification().Server().Url().Str()); ModelIdentifier tm2; @@ -502,7 +502,7 @@ TEST_F(LocalCacheTest, MatchingWorld) EXPECT_TRUE(cache.MatchingWorld(am1)); EXPECT_EQ("alice", am1.Owner()); EXPECT_EQ("am1", am1.Name()); - EXPECT_EQ("http://localhost:8001", am1.Server().Url().Str()); + EXPECT_EQ("http://localhost:8001/", am1.Server().Url().Str()); WorldIdentifier tm2; tm2.SetServer(srv1);