@@ -484,7 +484,7 @@ static int cb_no_check(void *chunk, size_t size, void *data)
484
484
return 0 ;
485
485
}
486
486
487
- static void flb_test_log_body ( )
487
+ static void flb_test_logs_body_impl ( const char * logs_body_key , char * want_log )
488
488
{
489
489
struct flb_lib_out_cb cb_data ;
490
490
struct test_ctx * ctx ;
@@ -498,14 +498,21 @@ static void flb_test_log_body()
498
498
clear_output_num ();
499
499
500
500
cb_data .cb = cb_check_log_body ;
501
- cb_data .data = "{\"log\":\"{\\\"message\\\":\\\"test\\\"}\"}" ;
501
+ cb_data .data = want_log ;
502
502
503
503
ctx = test_ctx_create (& cb_data );
504
504
if (!TEST_CHECK (ctx != NULL )) {
505
505
TEST_MSG ("test_ctx_create failed" );
506
506
exit (EXIT_FAILURE );
507
507
}
508
508
509
+ if (logs_body_key != NULL ) {
510
+ ret = flb_input_set (ctx -> flb , ctx -> i_ffd ,
511
+ "logs_body_key" , logs_body_key ,
512
+ NULL );
513
+ TEST_CHECK (ret == 0 );
514
+ }
515
+
509
516
ret = flb_output_set (ctx -> flb , ctx -> o_ffd ,
510
517
"match" , "*" ,
511
518
"format" , "json" ,
@@ -552,6 +559,14 @@ static void flb_test_log_body()
552
559
test_ctx_destroy (ctx );
553
560
}
554
561
562
+ static void flb_test_log_body () {
563
+ flb_test_logs_body_impl (NULL , "{\"log\":\"{\\\"message\\\":\\\"test\\\"}\"}" );
564
+ }
565
+
566
+ static void flb_test_log_body_key () {
567
+ flb_test_logs_body_impl ("body" , "{\"body\":\"{\\\"message\\\":\\\"test\\\"}\"}" );
568
+ }
569
+
555
570
void flb_test_successful_response_code (char * response_code )
556
571
{
557
572
struct flb_lib_out_cb cb_data = {0 };
@@ -722,6 +737,7 @@ TEST_LIST = {
722
737
{"log_group_metadata" , flb_test_log_group_metadata },
723
738
{"log_group_body" , flb_test_log_group_body },
724
739
{"log_body" , flb_test_log_body },
740
+ {"log_body_key" , flb_test_log_body_key },
725
741
{"successful_response_code_200" , flb_test_successful_response_code_200 },
726
742
{"successful_response_code_204" , flb_test_successful_response_code_204 },
727
743
{"tag_from_uri_false" , flb_test_tag_from_uri_false },
0 commit comments