-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: runtime: in_calyptia_fleet: add placeholders
Signed-off-by: Patrick Stephens <[email protected]>
- Loading branch information
1 parent
5ef6296
commit fc1cbbd
Showing
5 changed files
with
115 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include <fluent-bit.h> | ||
#include <fluent-bit/calyptia/calyptia_constants.h> | ||
#include "flb_tests_runtime.h" | ||
#include "../../plugins/in_calyptia_fleet/in_calyptia_fleet.h" | ||
|
||
flb_sds_t fleet_config_filename(struct flb_in_calyptia_fleet_config *ctx, char *fname); | ||
|
||
int get_calyptia_files(struct flb_in_calyptia_fleet_config *ctx, | ||
const char *url, | ||
time_t timestamp); | ||
|
||
int fleet_cur_chdir(struct flb_in_calyptia_fleet_config *ctx); | ||
|
||
/* Test context structure */ | ||
struct test_context { | ||
struct flb_in_calyptia_fleet_config *ctx; | ||
struct flb_config *config; | ||
}; | ||
|
||
/* Initialize test context */ | ||
static struct test_context *init_test_context() | ||
{ | ||
struct test_context *t_ctx = flb_calloc(1, sizeof(struct test_context)); | ||
if (!t_ctx) { | ||
return NULL; | ||
} | ||
|
||
t_ctx->config = flb_config_init(); | ||
if (!t_ctx->config) { | ||
flb_free(t_ctx); | ||
return NULL; | ||
} | ||
|
||
t_ctx->ctx = flb_calloc(1, sizeof(struct flb_in_calyptia_fleet_config)); | ||
if (!t_ctx->ctx) { | ||
flb_config_exit(t_ctx->config); | ||
flb_free(t_ctx); | ||
return NULL; | ||
} | ||
|
||
/* Initialize plugin instance for logging */ | ||
t_ctx->ctx->ins = flb_calloc(1, sizeof(struct flb_input_instance)); | ||
if (!t_ctx->ctx->ins) { | ||
flb_free(t_ctx->ctx); | ||
flb_config_exit(t_ctx->config); | ||
flb_free(t_ctx); | ||
return NULL; | ||
} | ||
|
||
/* Initialize test values in ctx */ | ||
t_ctx->ctx->api_key = flb_strdup("test_api_key"); | ||
t_ctx->ctx->fleet_id = flb_strdup("test_fleet_id"); | ||
|
||
t_ctx->ctx->fleet_name = flb_strdup("test_fleet"); | ||
t_ctx->ctx->machine_id = flb_strdup("test_machine_id"); | ||
|
||
t_ctx->ctx->fleet_config_legacy_format = FLB_TRUE; | ||
|
||
return t_ctx; | ||
} | ||
|
||
static void cleanup_test_context(struct test_context *t_ctx) | ||
{ | ||
if (!t_ctx) { | ||
return; | ||
} | ||
|
||
if (t_ctx->ctx) { | ||
if (t_ctx->ctx->api_key) flb_free(t_ctx->ctx->api_key); | ||
if (t_ctx->ctx->fleet_id) flb_free(t_ctx->ctx->fleet_id); | ||
|
||
if (t_ctx->ctx->fleet_name) flb_free(t_ctx->ctx->fleet_name); | ||
if (t_ctx->ctx->machine_id) flb_free(t_ctx->ctx->machine_id); | ||
|
||
if (t_ctx->ctx->ins) flb_free(t_ctx->ctx->ins); | ||
flb_free(t_ctx->ctx); | ||
} | ||
|
||
if (t_ctx->config) { | ||
/* Destroy the config which will cleanup any remaining instances */ | ||
flb_config_exit(t_ctx->config); | ||
} | ||
|
||
flb_free(t_ctx); | ||
} | ||
|
||
static void test_in_fleet_toml_format() { | ||
struct test_context *t_ctx = init_test_context(); | ||
TEST_CHECK(t_ctx != NULL); | ||
|
||
cleanup_test_context(t_ctx); | ||
} | ||
|
||
static void test_in_fleet_yaml_format() { | ||
struct test_context *t_ctx = init_test_context(); | ||
TEST_CHECK(t_ctx != NULL); | ||
|
||
cleanup_test_context(t_ctx); | ||
} | ||
|
||
/* Define test list */ | ||
TEST_LIST = { | ||
{"in_calyptia_fleet_toml_format", test_in_fleet_toml_format}, | ||
{"in_calyptia_fleet_yaml_format", test_in_fleet_yaml_format}, | ||
{NULL, NULL} | ||
}; |