1 parent
3851aeb703
commit
053ee5b296
23 files changed
+845
-93
No files matched your search
@@ -38,7 +38,7 @@ Void::Testing::Test field_scope_nests()
|
||||
|
||||
FieldScope a{"a", "1"};
|
||||
{
|
||||
FieldScope b{{{"b", "2"}, {"c", "3"}}};
|
||||
FieldScope b{{"b", "2"}, {"c", "3"}};
|
||||
log.info("two scopes");
|
||||
}
|
||||
log.info("one scope");
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include <Void/ShortUrl/ShortUrl.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
class Shortener final : public Void::ShortUrl::IShortener
|
||||
{
|
||||
public:
|
||||
|
||||
[[nodiscard]] std::string_view provider_id() const noexcept override
|
||||
{
|
||||
return "test";
|
||||
}
|
||||
|
||||
[[nodiscard]] Void::ShortUrl::Health health() const override
|
||||
{
|
||||
return {.status = Void::ShortUrl::HealthStatus::healthy};
|
||||
}
|
||||
|
||||
[[nodiscard]] Void::ShortUrl::ShortenResult
|
||||
shorten(const Void::ShortUrl::ShortenRequest& request) override
|
||||
{
|
||||
return {
|
||||
.short_url = "https://sho.rt/s/Ab3dE5fG7h",
|
||||
.key = "Ab3dE5fG7h",
|
||||
.expires_at_unix_seconds = request.expires_at_unix_seconds,
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Void::Testing::Test short_url_service_contract()
|
||||
{
|
||||
Shortener shortener;
|
||||
Void::Testing::expect_eq(shortener.service_name(),
|
||||
Void::ShortUrl::kServiceId);
|
||||
Void::Testing::expect_eq(shortener.service_version(), std::uint32_t{1});
|
||||
Void::Testing::expect_eq(shortener.provider_id(), std::string_view{"test"});
|
||||
Void::Testing::expect_eq(shortener.health().status,
|
||||
Void::ShortUrl::HealthStatus::healthy);
|
||||
|
||||
auto result = shortener.shorten({.target_url = "https://example.com/a"});
|
||||
Void::Testing::expect(result.ok());
|
||||
Void::Testing::expect_eq(result.key, std::string{"Ab3dE5fG7h"});
|
||||
}
|
||||
|
||||
Void::Testing::Test short_url_resolution_is_optional()
|
||||
{
|
||||
Shortener shortener;
|
||||
auto result = shortener.resolve({.key = "Ab3dE5fG7h"});
|
||||
Void::Testing::expect(!result.ok());
|
||||
Void::Testing::expect_eq(result.error.code,
|
||||
Void::ShortUrl::ErrorCode::unsupported);
|
||||
}
|
||||
Reference in new issue
Block a user