Skip to content

Commit

Permalink
Fix world tests (#76)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored Jun 15, 2020
1 parent 0f9aa4c commit e883e60
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
39 changes: 20 additions & 19 deletions src/FuelClient_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,14 +810,14 @@ TEST_F(FuelClientTest, ParseWorldFileUrl)
std::string filePath;
const common::URI worldUrl{
"https://fuel.ignitionrobotics.org/1.0/OpenRobotics/worlds/Empty/tip/"
"files/empty.world"};
"files/test.world"};
EXPECT_TRUE(client.ParseWorldFileUrl(worldUrl, id, filePath));

EXPECT_EQ(id.Server().Url().Str(), "https://fuel.ignitionrobotics.org");
EXPECT_EQ(id.Server().Version(), "1.0");
EXPECT_EQ(id.Owner(), "OpenRobotics");
EXPECT_EQ(id.Name(), "Empty");
EXPECT_EQ(filePath, "empty.world");
EXPECT_EQ(filePath, "test.world");
}

// URL - with client config
Expand Down Expand Up @@ -848,14 +848,14 @@ TEST_F(FuelClientTest, ParseWorldFileUrl)
std::string filePath;
const common::URI worldUrl{
"https://fuel.ignitionrobotics.org/5.0/OpenRobotics/worlds/Empty/tip/"
"files/empty.world"};
"files/test.world"};
EXPECT_TRUE(client.ParseWorldFileUrl(worldUrl, id, filePath));

EXPECT_EQ(id.Server().Url().Str(), "https://fuel.ignitionrobotics.org");
EXPECT_EQ(id.Server().Version(), "1.0");
EXPECT_EQ(id.Owner(), "OpenRobotics");
EXPECT_EQ(id.Name(), "Empty");
EXPECT_EQ(filePath, "empty.world");
EXPECT_EQ(filePath, "test.world");
}

// Unique name - without client config
Expand Down Expand Up @@ -885,14 +885,14 @@ TEST_F(FuelClientTest, ParseWorldFileUrl)
std::string filePath;
const common::URI worldUrl{
"https://fuel.ignitionrobotics.org/1.0/OpenRobotics/worlds/Empty/tip/"
"files/empty.world"};
"files/test.world"};
EXPECT_TRUE(client.ParseWorldFileUrl(worldUrl, id, filePath));

EXPECT_EQ(id.Server().Url().Str(), "https://fuel.ignitionrobotics.org");
EXPECT_EQ(id.Server().Version(), "1.0");
EXPECT_EQ(id.Owner(), "OpenRobotics");
EXPECT_EQ(id.Name(), "Empty");
EXPECT_EQ(filePath, "empty.world");
EXPECT_EQ(filePath, "test.world");
}

// Bad URL
Expand Down Expand Up @@ -924,7 +924,7 @@ TEST_F(FuelClientTest, DownloadWorld)

ServerConfig server;
server.SetUrl(ignition::common::URI(
"https://staging-fuel.ignitionrobotics.org"));
"https://fuel.ignitionrobotics.org"));

ClientConfig config;
config.AddServer(server);
Expand All @@ -937,8 +937,8 @@ TEST_F(FuelClientTest, DownloadWorld)
// Download world from URL
{
// Unversioned URL should get the latest available version
common::URI url{
"https://staging-fuel.ignitionrobotics.org/1.0/nate/worlds/Empty"};
common::URI url{"https://fuel.ignitionrobotics.org/1.0/OpenRobotics/"
"worlds/Test world"};

// Check it is not cached
std::string cachedPath;
Expand All @@ -954,31 +954,32 @@ TEST_F(FuelClientTest, DownloadWorld)

// Check it was downloaded to `1`
EXPECT_EQ(path, common::cwd() +
"/test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/Empty/1");
"/test_cache/fuel.ignitionrobotics.org/OpenRobotics/worlds/"
"Test world/1");
EXPECT_TRUE(common::exists(
"test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/Empty/1"));
"test_cache/fuel.ignitionrobotics.org/OpenRobotics/worlds/"
"Test world/1"));
EXPECT_TRUE(common::exists(
"test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/Empty/1/"
"empty.world"));
"test_cache/fuel.ignitionrobotics.org/OpenRobotics/worlds/"
"Test world/1/test.world"));

// Check it wasn't downloaded to world root directory
EXPECT_FALSE(common::exists(
"test_cache/staging-fuel.ignitionrobotics.org/" +
std::string("nate/worlds/Empty/empty.world")));
"test_cache/fuel.ignitionrobotics.org/" +
std::string("OpenRobotics/worlds/Test world/test.world")));

// Check it is cached
auto res3 = client.CachedWorld(url, cachedPath);
EXPECT_TRUE(res3);
EXPECT_EQ(Result(ResultType::FETCH_ALREADY_EXISTS), res3);
EXPECT_EQ(common::cwd() +
"/test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/Empty/1",
cachedPath);
EXPECT_EQ(common::cwd() + "/test_cache/fuel.ignitionrobotics.org"
"/OpenRobotics/worlds/Test world/1", cachedPath);
}

// Try using nonexistent URL
{
common::URI url{
"https://staging-fuel.ignitionrobotics.org/1.0/nate/worlds/Bad world"};
"https://fuel.ignitionrobotics.org/1.0/OpenRobotics/worlds/Bad world"};
std::string path;
auto result = client.DownloadWorld(url, path);
EXPECT_FALSE(result);
Expand Down
15 changes: 7 additions & 8 deletions src/ign_src_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,12 @@ TEST(CmdLine, WorldListCustomServerPrettyOwner)
std::stringstream stdErrBuffer;
redirectIO(stdOutBuffer, stdErrBuffer);

EXPECT_TRUE(listWorlds("https://staging-fuel.ignitionrobotics.org", "nate"));
EXPECT_TRUE(listWorlds("https://staging-fuel.ignitionrobotics.org",
"OpenRobotics"));

EXPECT_NE(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("worlds"), std::string::npos)
<< stdOutBuffer.str();

Expand Down Expand Up @@ -418,7 +417,7 @@ TEST(CmdLine, WorldDownloadUnversioned)

// Download
EXPECT_TRUE(downloadUrl(
"https://staging-fuel.ignitionrobotics.org/1.0/nate/worlds/Empty"));
"https://fuel.ignitionrobotics.org/1.0/OpenRobotics/worlds/Test world"));

// Check output
EXPECT_NE(stdOutBuffer.str().find("Download succeeded"),
Expand All @@ -427,12 +426,12 @@ TEST(CmdLine, WorldDownloadUnversioned)

// Check files
EXPECT_TRUE(ignition::common::isDirectory(
"test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/Empty"));
"test_cache/fuel.ignitionrobotics.org/OpenRobotics/worlds/Test world"));
EXPECT_TRUE(ignition::common::isDirectory(
"test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/Empty/1"));
"test_cache/fuel.ignitionrobotics.org/OpenRobotics/worlds/Test world/1"));
EXPECT_TRUE(ignition::common::isFile(
std::string("test_cache/staging-fuel.ignitionrobotics.org/nate/worlds/")
+ "Empty/1/empty.world"));
std::string("test_cache/fuel.ignitionrobotics.org/OpenRobotics/worlds/")
+ "Test world/1/test.world"));

clearIOStreams(stdOutBuffer, stdErrBuffer);
restoreIO();
Expand Down

0 comments on commit e883e60

Please sign in to comment.