Skip to content

Commit

Permalink
Documentation and tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nate Koenig <[email protected]>
  • Loading branch information
Nate Koenig committed Dec 8, 2020
1 parent 13c9694 commit e3ae7d8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/ignition/fuel_tools/FuelClient.hh
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ namespace ignition
///
/// Model fields that are patched by this function:
/// * private
/// * Model files contained in _pathToModelDir.
/// * Description, tags, license, and other attributes found in the
/// metadata.pbtxt or model.config file.
///
/// \param[in] _model The model to patch. The contents of this model
/// will be sent in the PATCH request.
Expand Down
27 changes: 27 additions & 0 deletions src/FuelClient_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,33 @@ TEST_F(FuelClientTest, UploadModelFail)
EXPECT_EQ(ResultType::UPLOAD_ERROR, result.Type());
}

//////////////////////////////////////////////////
TEST_F(FuelClientTest, PatchModelFail)
{
FuelClient client;
ModelIdentifier modelId;

std::vector<std::string> headers;

// Bad directory
Result result = client.PatchModel(modelId, headers, "bad");
EXPECT_EQ(ResultType::UPLOAD_ERROR, result.Type());

// Missing metadata.pbtxt and model.config
result = client.PatchModel(modelId, headers, common::cwd());
EXPECT_EQ(ResultType::UPLOAD_ERROR, result.Type());

ClientConfig config;
config.SetCacheLocation(common::joinPaths(common::cwd(), "test_cache"));
createLocalModel(config);

// Bad model.config
result = client.PatchModel(modelId, headers,
common::joinPaths(common::cwd(), "test_cache", "localhost:8007",
"alice", "models", "My Model", "3"));
EXPECT_EQ(ResultType::UPLOAD_ERROR, result.Type());
}

//////////////////////////////////////////////////
int main(int argc, char **argv)
{
Expand Down
1 change: 1 addition & 0 deletions src/ign.hh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ extern "C" IGNITION_FUEL_TOOLS_VISIBLE int pbtxt2Config(const char *_path);
/// \param[in] _header An HTTP header.
/// \param[in] _private "1" to make the resource private, "0" to make it
/// public
/// \param[in] _path Resource path.
/// \return 1 if successful, 0 if not.
extern "C" IGNITION_FUEL_TOOLS_VISIBLE int editUrl(
const char *_url, const char *_header = nullptr,
Expand Down

0 comments on commit e3ae7d8

Please sign in to comment.