feat(shorturl): complete P2 M-SHORTURL-01..04 V2 local, storage, and remote providers with frozen V1
This commit is contained in:
1 parent
658c21a2fa
commit
691808eab6
13 files changed
+2317
-1
No files matched your search
@@ -0,0 +1,14 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidShortUrlOnlyConsumer LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 26)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS ShortUrl)
|
||||
|
||||
add_executable(short_url_only_consumer main.cpp)
|
||||
target_link_libraries(short_url_only_consumer PRIVATE Void::ShortUrl)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME short_url_only_consumer COMMAND short_url_only_consumer)
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <Void/ShortUrl/ShortUrl.hpp>
|
||||
#include <Void/ShortUrl/V2.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace Void::ShortUrl::V2;
|
||||
auto repo = std::make_shared<InMemoryLinkRepository>();
|
||||
auto provider = std::make_shared<LocalProvider>(repo);
|
||||
V1Adapter v1{provider};
|
||||
auto s = v1.shorten({.target_url = "https://example.com/pkg"});
|
||||
if (!s.ok()) {
|
||||
return 1;
|
||||
}
|
||||
auto r = v1.resolve({.key = s.key});
|
||||
if (!r.ok() || r.target_url != "https://example.com/pkg") {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user