-
Notifications
You must be signed in to change notification settings - Fork 271
/
test-event-filter.c
50 lines (41 loc) · 1.27 KB
/
test-event-filter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "ioloop.h"
#include "event-filter.h"
static void test_event_filter_clear_parent_fields(void)
{
struct event_filter *filter;
struct event_filter_field filter_fields[] = {
{ .key = "", .value = "*" },
{ .key = NULL, .value = NULL }
};
const struct event_filter_query query = {
.fields = filter_fields,
};
const struct failure_context failure_ctx = {
.type = LOG_TYPE_DEBUG
};
const char *keys[] = { "str", "int" };
test_begin("event filter: clear parent fields");
struct event *parent = event_create(NULL);
event_add_str(parent, "str", "parent_str");
event_add_int(parent, "int", 0);
struct event *child = event_create(NULL);
event_field_clear(child, "str");
event_field_clear(child, "int");
for (unsigned int i = 0; i < N_ELEMENTS(keys); i++) {
filter_fields[0].key = keys[i];
filter = event_filter_create();
event_filter_add(filter, &query);
test_assert_idx(event_filter_match(filter, parent, &failure_ctx), i);
test_assert_idx(!event_filter_match(filter, child, &failure_ctx), i);
event_filter_unref(&filter);
}
event_unref(&parent);
event_unref(&child);
test_end();
}
void test_event_filter(void)
{
test_event_filter_clear_parent_fields();
}