Skip to content

Commit 42f7a61

Browse files
committed
fixes
1 parent 25231f5 commit 42f7a61

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_objs)
6363

6464

6565
# Functional Tests
66-
include(UserverTestsuite)
67-
6866
userver_testsuite_add_simple()
6967

7068

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
2-
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
2+
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE=''
33
CMAKE_RELEASE_FLAGS ?=
44
NPROCS ?= $(shell nproc)
55
CLANG_FORMAT ?= clang-format
@@ -34,9 +34,8 @@ build-debug build-release: build-%: build_%/CMakeCache.txt
3434
# Test
3535
.PHONY: test-debug test-release
3636
test-debug test-release: test-%: build-%
37-
cmake --build build_$* -j $(NPROCS) --target upastebin_unittest
38-
cmake --build build_$* -j $(NPROCS) --target upastebin_benchmark
39-
cd build_$* && ((test -t 1 && GTEST_COLOR=1 PYTEST_ADDOPTS="--color=yes" ctest -V) || ctest -V)
37+
cmake --build build_$* -j $(NPROCS) --target runtests-upastebin
38+
cd build_$* && GTEST_COLOR=1 PYTEST_ADDOPTS="--color=yes" ctest -V
4039
pycodestyle tests
4140

4241
# Start the service (via testsuite service runner)

src/store.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <userver/components/component_context.hpp>
44
#include <userver/formats/json/inline.hpp>
5+
#include <userver/storages/postgres/io/chrono.hpp>
56
#include <userver/http/common_headers.hpp>
67
#include <userver/server/handlers/exceptions.hpp>
78
#include <userver/server/handlers/http_handler_base.hpp>
@@ -25,7 +26,7 @@ std::string StoreHandler::HandleRequestThrow(
2526
auto author = request.GetArg("author");
2627
auto ip_source = request.GetRemoteAddress().PrimaryAddressString();
2728
auto text = request.RequestBody();
28-
auto created_at = userver::utils::datetime::Now();
29+
userver::storages::postgres::TimePointTz created_at{userver::utils::datetime::Now()};
2930

3031
pg_->Execute(userver::storages::postgres::ClusterHostType::kMaster,
3132
"INSERT INTO upastebin.texts (uuid, author, ip_source, text, created_at) VALUES "

tests/test_crud.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ async def test_create_and_retrieve(service_client):
3131

3232
response = await service_client.get('/api/v1/latest')
3333
assert response.status == 200
34-
assert response.json() == {
35-
'items': [{'author': 'foo', 'ip': '::ffff:127.0.0.1', 'text': TEXT}],
34+
json = response.json()
35+
assert json == {
36+
'items': [
37+
{
38+
'author': 'foo',
39+
'ip': '::ffff:127.0.0.1',
40+
'id': uuid,
41+
'text': TEXT,
42+
}
43+
],
3644
}

www-data/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function onSend() {
2626
return response.json();
2727
})
2828
.then(function(json) {
29-
alert(json);
29+
document.location = '../' + json['uuid'];
3030
})
3131
.catch(function (error) {
3232
alert(error);

www-data/text.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ function setup_text() {
1616
return response.text();
1717
})
1818
.then(function (text) {
19-
document.getElementById("text").innerHTML = text; // TODO: escape
19+
const p = document.createElement("div");
20+
p.appendChild(document.createTextNode(text));
21+
document.getElementById("text").innerHTML = p.innerHTML;
2022
})
2123
.catch(function (error) {
2224
alert(error);

0 commit comments

Comments
 (0)