@@ -484,7 +484,7 @@ static int cb_no_check(void *chunk, size_t size, void *data)
484484 return 0 ;
485485}
486486
487- static void flb_test_log_body ( )
487+ static void flb_test_logs_body_impl ( const char * logs_body_key , char * want_log )
488488{
489489 struct flb_lib_out_cb cb_data ;
490490 struct test_ctx * ctx ;
@@ -498,14 +498,21 @@ static void flb_test_log_body()
498498 clear_output_num ();
499499
500500 cb_data .cb = cb_check_log_body ;
501- cb_data .data = "{\"log\":\"{\\\"message\\\":\\\"test\\\"}\"}" ;
501+ cb_data .data = want_log ;
502502
503503 ctx = test_ctx_create (& cb_data );
504504 if (!TEST_CHECK (ctx != NULL )) {
505505 TEST_MSG ("test_ctx_create failed" );
506506 exit (EXIT_FAILURE );
507507 }
508508
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+
509516 ret = flb_output_set (ctx -> flb , ctx -> o_ffd ,
510517 "match" , "*" ,
511518 "format" , "json" ,
@@ -552,6 +559,14 @@ static void flb_test_log_body()
552559 test_ctx_destroy (ctx );
553560}
554561
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+
555570void flb_test_successful_response_code (char * response_code )
556571{
557572 struct flb_lib_out_cb cb_data = {0 };
@@ -722,6 +737,7 @@ TEST_LIST = {
722737 {"log_group_metadata" , flb_test_log_group_metadata },
723738 {"log_group_body" , flb_test_log_group_body },
724739 {"log_body" , flb_test_log_body },
740+ {"log_body_key" , flb_test_log_body_key },
725741 {"successful_response_code_200" , flb_test_successful_response_code_200 },
726742 {"successful_response_code_204" , flb_test_successful_response_code_204 },
727743 {"tag_from_uri_false" , flb_test_tag_from_uri_false },
0 commit comments