mirror of
https://github.com/typesense/typesense.git
synced 2025-05-16 03:12:32 +08:00
adding tests
This commit is contained in:
parent
3ec17ff201
commit
1f8c0d73dd
@ -142,8 +142,6 @@ private:
|
||||
|
||||
butil::EndPoint peering_endpoint;
|
||||
|
||||
Option<bool> handle_gzip(const std::shared_ptr<http_req>& request);
|
||||
|
||||
public:
|
||||
|
||||
static constexpr const char* log_dir_name = "log";
|
||||
@ -241,6 +239,8 @@ public:
|
||||
|
||||
std::string get_leader_url() const;
|
||||
|
||||
static Option<bool> handle_gzip(const std::shared_ptr<http_req>& request);
|
||||
|
||||
private:
|
||||
|
||||
friend class ReplicationClosure;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <collection_manager.h>
|
||||
#include <core_api.h>
|
||||
#include "core_api_utils.h"
|
||||
#include "raft_server.h"
|
||||
|
||||
class CoreAPIUtilsTest : public ::testing::Test {
|
||||
protected:
|
||||
@ -1137,4 +1138,30 @@ TEST_F(CoreAPIUtilsTest, TestProxyInvalid) {
|
||||
|
||||
ASSERT_EQ(400, resp->status_code);
|
||||
ASSERT_EQ("Headers must be a JSON object.", nlohmann::json::parse(resp->body)["message"]);
|
||||
}
|
||||
|
||||
TEST_F(CoreAPIUtilsTest, SampleGzipIndexTest) {
|
||||
Collection *coll_hnstories;
|
||||
|
||||
std::vector<field> fields = {field("title", field_types::STRING, false),
|
||||
field("points", field_types::INT32, false),};
|
||||
|
||||
coll_hnstories = collectionManager.get_collection("coll_hnstories").get();
|
||||
if(coll_hnstories == nullptr) {
|
||||
coll_hnstories = collectionManager.create_collection("coll_hnstories", 4, fields, "title").get();
|
||||
}
|
||||
|
||||
auto req = std::make_shared<http_req>();
|
||||
char buf[196605]; //chunk size limit
|
||||
std::ifstream infile(std::string(ROOT_DIR)+"test/resources/hnstories.jsonl.gz");
|
||||
|
||||
while(infile >> buf) {
|
||||
req->body = buf;
|
||||
|
||||
auto res = ReplicationState::handle_gzip(req);
|
||||
if(!res.error().empty()) {
|
||||
LOG(ERROR) << res.error();
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
}
|
BIN
test/resources/hnstories.jsonl.gz
Normal file
BIN
test/resources/hnstories.jsonl.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user