Skip to content

Commit

Permalink
Merge branch 'gz-fuel-tools9' into mjcarroll/collection_identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcarroll authored Jul 24, 2024
2 parents 93c8498 + 9d8c1c2 commit 5df00ed
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/CollectionIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ gz::common::URI CollectionIdentifier::Url() const
this->dataPtr->name), true);
}

//////////////////////////////////////////////////
gz::common::URI CollectionIdentifier::Url() const
{
return common::URI(
common::joinPaths(this->dataPtr->server.Url().Str(),
this->dataPtr->owner,
"collections",
this->dataPtr->name), true);
}

//////////////////////////////////////////////////
std::string CollectionIdentifier::Name() const
{
Expand Down
26 changes: 26 additions & 0 deletions src/CollectionIdentifier_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@ TEST(CollectionIdentifier, Url)
EXPECT_EQ("https://localhost:8003/alice/collections/hello", id.Url().Str());
}

/////////////////////////////////////////////////
/// \brief Unique Name
TEST(CollectionIdentifier, Url)
{
gz::fuel_tools::ServerConfig srv1;
srv1.SetUrl(common::URI("https://localhost:8001", true));

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

gz::fuel_tools::ServerConfig srv3;
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.Url().Str());

id.SetServer(srv2);
EXPECT_EQ("https://localhost:8002/alice/collections/hello", id.Url().Str());

id.SetServer(srv3);
EXPECT_EQ("https://localhost:8003/alice/collections/hello", id.Url().Str());
}

/////////////////////////////////////////////////
/// \brief Copy constructor deep copies
TEST(CollectionIdentifier, CopyConstructorDeepCopy)
Expand Down

0 comments on commit 5df00ed

Please sign in to comment.