Skip to content

Commit

Permalink
Make CollectionIdentifier::UniqueName consistent
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Jul 24, 2024
1 parent 7e5c31d commit 93c8498
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/CollectionIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ CollectionIdentifier::~CollectionIdentifier() = default;
//////////////////////////////////////////////////
std::string CollectionIdentifier::UniqueName() const
{
return common::joinPaths(this->dataPtr->server.Url().Str(),
this->dataPtr->owner, "collections",
this->dataPtr->name);
return common::copyToUnixPath(common::joinPaths(
uriToPath(this->dataPtr->server.Url()),
this->dataPtr->owner, "collections",
this->dataPtr->name));
}

//////////////////////////////////////////////////
Expand Down
14 changes: 7 additions & 7 deletions src/CollectionIdentifier_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ TEST(CollectionIdentifier, SetFields)
TEST(CollectionIdentifier, UniqueName)
{
gz::fuel_tools::ServerConfig srv1;
srv1.SetUrl(common::URI("https://localhost:8001"));
srv1.SetUrl(common::URI("https://localhost:8001", true));

gz::fuel_tools::ServerConfig srv2;
srv2.SetUrl(common::URI("https://localhost:8002"));
srv2.SetUrl(common::URI("https://localhost:8002", true));

gz::fuel_tools::ServerConfig srv3;
srv3.SetUrl(common::URI("https://localhost:8003"));
srv3.SetUrl(common::URI("https://localhost:8003", true));

CollectionIdentifier id;
id.SetName("hello");
id.SetOwner("alice");
id.SetServer(srv1);
EXPECT_EQ("https://localhost:8001/alice/collections/hello", id.UniqueName());
EXPECT_EQ("localhost%3A8001/alice/collections/hello", id.UniqueName());

id.SetServer(srv2);
EXPECT_EQ("https://localhost:8002/alice/collections/hello", id.UniqueName());
EXPECT_EQ("localhost%3A8002/alice/collections/hello", id.UniqueName());

id.SetServer(srv3);
EXPECT_EQ("https://localhost:8003/alice/collections/hello", id.UniqueName());
EXPECT_EQ("localhost%3A8003/alice/collections/hello", id.UniqueName());
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -149,7 +149,7 @@ TEST(CollectionIdentifier, AsString)
std::string str =
"Name: \n"\
"Owner: \n"\
"Unique name: https://fuel.gazebosim.org/collections/\n"
"Unique name: fuel.gazebosim.org/collections/\n"
"Server:\n"
" URL: https://fuel.gazebosim.org\n"
" Version: 1.0\n"
Expand Down

0 comments on commit 93c8498

Please sign in to comment.