Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix world tests #76

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expectation doesn't appear to be replaced with another one. Was it spurious?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed that on purpose, because it's hard to assume an exact number of users for a given server. Right now for example there are none.

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