Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire committed Jul 11, 2024
1 parent f3eb217 commit bed6792
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
5 changes: 0 additions & 5 deletions include/cpprealm/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,6 @@ class App {

};

[[deprecated("Use App(const configuration&) instead.")]]
explicit App(const std::string& app_id,
const std::optional<std::string>& base_url = {},
const std::optional<std::string>& path = {},
const std::optional<std::map<std::string, std::string>>& custom_http_headers = {});

App(const configuration&);

Expand Down
12 changes: 0 additions & 12 deletions src/cpprealm/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,18 +532,6 @@ namespace realm {
std::move(app_config));
}

App::App(const std::string &app_id,
const std::optional<std::string> &base_url,
const std::optional<std::string> &path,
const std::optional<std::map<std::string, std::string>> &custom_http_headers) {
configuration c;
c.app_id = app_id;
c.base_url = base_url;
c.path = path;
c.custom_http_headers = custom_http_headers;
*this = App(std::move(c));
}

std::string App::get_base_url() const {
return m_app->get_base_url();
}
Expand Down
25 changes: 20 additions & 5 deletions tests/sync/app_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,23 @@ TEST_CASE("app", "[app]") {
auto app = realm::App(config);

SECTION("base_url") {
auto no_url_provided_app = realm::App(realm::App::configuration({"NA"}));
auto config = realm::App::configuration();
config.app_id = "NA";
auto no_url_provided_app = realm::App(config);
CHECK(no_url_provided_app.get_base_url() == "https://services.cloud.mongodb.com");
auto with_url_provided_app = realm::App(realm::App::configuration({"NA", "https://foobar.com"}));

auto config2 = realm::App::configuration();
config2.app_id = "NA";
config2.base_url = "https://foobar.com";
auto with_url_provided_app = realm::App(config2);
CHECK(with_url_provided_app.get_base_url() == "https://foobar.com");
}

#ifdef REALM_ENABLE_EXPERIMENTAL
SECTION("update_base_url") {
auto no_url_provided_app = realm::App(realm::App::configuration({"NA"}));
auto config = realm::App::configuration();
config.app_id = "NA";
auto no_url_provided_app = realm::App(config);
CHECK(no_url_provided_app.get_base_url() == "https://services.cloud.mongodb.com");
REQUIRE_THROWS_AS(no_url_provided_app.update_base_url("https://foobar.com").get(), realm::app_error);
CHECK(no_url_provided_app.get_base_url() == "https://services.cloud.mongodb.com");
Expand Down Expand Up @@ -126,7 +134,11 @@ TEST_CASE("app", "[app]") {

SECTION("clear_cached_apps") {
auto temp_app_id = Admin::Session::shared().create_app({"str_col", "_id"});
auto temp_app = realm::App(realm::App::configuration({temp_app_id, Admin::Session::shared().base_url()}));
auto config = realm::App::configuration();
config.app_id = temp_app_id;
config.base_url = Admin::Session::shared().base_url();

auto temp_app = realm::App(config);
auto cached_app = temp_app.get_cached_app(temp_app_id, Admin::Session::shared().base_url());
CHECK(cached_app.has_value());
app.clear_cached_apps();
Expand All @@ -135,7 +147,10 @@ TEST_CASE("app", "[app]") {
}

SECTION("error handling") {
auto dead_app = realm::App(realm::App::configuration({"NA", Admin::Session::shared().base_url()}));
auto config = realm::App::configuration();
config.app_id = "NA";
config.base_url = Admin::Session::shared().base_url();
auto dead_app = realm::App(config);
REQUIRE_THROWS_AS(dead_app.login(realm::App::credentials::anonymous()).get(), realm::app_error);
REQUIRE_THROWS_AS(dead_app.register_user("", "").get(), realm::app_error);

Expand Down

0 comments on commit bed6792

Please sign in to comment.