1
1
#include " pagination.h"
2
2
3
- #include < src/library/getopt/last_getopt.h>
4
3
#include < ydb-cpp-sdk/json_value/ydb_json_value.h>
5
4
6
5
#include < gtest/gtest.h>
7
6
8
- using namespace NLastGetopt ;
9
7
using namespace NYdb ;
10
8
11
9
const uint32_t MaxPages = 10 ;
12
10
13
- void StopHandler (int ) {
14
- exit (1 );
15
- }
16
-
17
- RunArgs getRunArgs () {
18
- TOpts opts = TOpts::Default ();
19
-
20
- std::string database = std::getenv ( " DATABASE" );
21
- std::string endpoint = std::getenv ( " ENDPOINT" );
22
- std::string path;
23
-
24
- if (path.empty ()) {
25
- path = database;
26
- }
11
+ RunArgs GetRunArgs () {
12
+ std::string database = std::getenv (" YDB_DATABASE" );
13
+ std::string endpoint = std::getenv (" YDB_ENDPOINT" );
27
14
28
15
auto driverConfig = TDriverConfig ()
29
16
.SetEndpoint (endpoint)
30
17
.SetDatabase (database)
31
18
.SetAuthToken (std::getenv (" YDB_TOKEN" ) ? std::getenv (" YDB_TOKEN" ) : " " );
19
+
32
20
TDriver driver (driverConfig);
33
-
34
- return {driver, path};
21
+ return {driver, database};
35
22
}
36
23
37
24
TEST (Integration, Pagination) {
38
-
25
+
39
26
std::vector<std::string> mapPagToJson = {
40
27
" {\" address\" :\" Кирова, 6\" ,\" city\" :\" Кирс\" ,\" number\" :3}\n {\" address\" :\" Урицкого, 21\" ,\" city\" :\" Котельнич\" ,\" number\" :1}\n {\" address\" :\" Октябрьская, 109\" ,\" city\" :\" Котельнич\" ,\" number\" :2}\n " ,
41
28
" {\" address\" :\" Советская, 153\" ,\" city\" :\" Котельнич\" ,\" number\" :3}\n {\" address\" :\" Школьная, 2\" ,\" city\" :\" Котельнич\" ,\" number\" :5}\n {\" address\" :\" Октябрьская, 91\" ,\" city\" :\" Котельнич\" ,\" number\" :15}\n " ,
@@ -45,7 +32,7 @@ TEST(Integration, Pagination) {
45
32
" "
46
33
};
47
34
48
- auto [driver, path] = getRunArgs ();
35
+ auto [driver, path] = GetRunArgs ();
49
36
50
37
TTableClient client (driver);
51
38
@@ -62,19 +49,15 @@ TEST(Integration, Pagination) {
62
49
uint32_t page = 0 ;
63
50
std::string currentResultSet = " " ;
64
51
65
- std::cout << " > Pagination, Limit=" << limit << std::endl;
66
-
67
52
// show first MaxPages=10 pages:
68
53
while (!currentResultSet.empty () && page <= MaxPages) {
69
54
++page;
70
- std::cout << " > Page " << page << " :" << std::endl;
71
55
currentResultSet = SelectPaging (client, path, limit, lastCity, lastNumber);
72
56
ASSERT_EQ (mapPagToJson[page - 1 ], currentResultSet);
73
57
}
74
58
}
75
59
catch (const TYdbErrorException& e) {
76
60
std::cerr << " Execution failed due to fatal error:" << std::endl;
77
- PrintStatus (e.Status );
78
61
FAIL ();
79
62
}
80
63
}
0 commit comments