<commit_before>/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

#include <gtest/gtest.h>
#include <fluent-bit.h>
#include "data/json_es.h"

TEST(Outputs, json_es) {
    int ret;
    int size = sizeof(JSON_ES) - 1;
    struct flb_lib_ctx *ctx;

    ctx = flb_lib_init(NULL, (char *) "es", NULL);
    EXPECT_TRUE(ctx != NULL);

    ret = flb_lib_start(ctx);
    EXPECT_EQ(ret, 0);

    flb_lib_push(ctx, (char *) JSON_ES, size);
    flb_lib_stop(ctx);
    flb_lib_exit(ctx);
}
<commit_msg>tests: elasticsearch: use new API mechanism<commit_after>/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

#include <gtest/gtest.h>
#include <fluent-bit.h>
#include "data/json_es.h"

TEST(Outputs, json_es) {
    int ret;
    int size = sizeof(JSON_ES) - 1;
    flb_ctx_t *ctx;
    flb_input_t *input;
    flb_output_t *output;

    ctx = flb_create();
    EXPECT_TRUE(ctx != NULL);

    input = flb_input(ctx, (char *) "lib", NULL);
    EXPECT_TRUE(input != NULL);
    flb_input_set(input, "tag", "test");

    output = flb_output(ctx, (char *) "es", NULL);
    EXPECT_TRUE(output != NULL);
    flb_output_set(output, "tag", "test");

    ret = flb_start(ctx);
    EXPECT_EQ(ret, 0);

    flb_lib_push(input, (char *) JSON_ES, size);

    flb_stop(ctx);
    flb_destroy(ctx);
}

{'fraction_non_alphanumeric': 0.17447129909365558, 'fraction_numerical': 0.006042296072507553, 'mean_word_length': 3.3874172185430464, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7369767', 'n_tokens_mistral': 551, 'n_tokens_neox': 539, 'n_words': 111}