aboutsummaryrefslogtreecommitdiff
path: root/src/app_test.cpp
blob: 06f20840af56621704729474cd77ebc8c830c531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <httplib.h>
#include <memory>
#include <iostream>

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <mw/test_utils.hpp>
#include <mw/http_client.hpp>
#include <mw/auth_mock.hpp>

#include "app.hpp"
#include "config.hpp"
#include "data.hpp"
#include "data_mock.hpp"

using ::testing::_;
using ::testing::Return;
using ::testing::HasSubstr;
using ::testing::FieldsAre;
using ::testing::ContainsRegex;

// class UserAppTest : public testing::Test
// {
// protected:
//     UserAppTest()
//     {
//         config.base_url = "http://localhost:8080/";
//         config.listen_address = "localhost";
//         config.listen_port = 8080;
//         config.data_dir = ".";

//         auto auth = std::make_unique<mw::AuthMock>();

//         mw::UserInfo expected_user;
//         expected_user.name = "mw";
//         expected_user.id = "mw";
//         mw::Tokens token;
//         token.access_token = "aaa";
//         EXPECT_CALL(*auth, getUser(std::move(token)))
//             .Times(::testing::AtLeast(0))
//             .WillRepeatedly(Return(expected_user));
//         auto data = std::make_unique<DataSourceMock>();
//         data_source = data.get();

//         app = std::make_unique<App>(config, std::move(data), std::move(auth));
//     }

//     Configuration config;
//     std::unique_ptr<App> app;
//     const DataSourceMock* data_source;
// };

// TEST_F(UserAppTest, CanDenyAccessToLinkList)
// {
//     EXPECT_TRUE(mw::isExpected(app->start()));
//     {
//         mw::HTTPSession client;
//         ASSIGN_OR_FAIL(const mw::HTTPResponse* res, client.get(
//             mw::HTTPRequest("http://localhost:8080/_/links")));
//         EXPECT_EQ(res->status, 401);
//     }
//     app->stop();
//     app->wait();
// }