Skip to content

Add filtering function for data generation#6958

Merged
ruflin merged 1 commit intoelastic:masterfrom
jsoriano:data-conditional-events
Apr 27, 2018
Merged

Add filtering function for data generation#6958
ruflin merged 1 commit intoelastic:masterfrom
jsoriano:data-conditional-events

Conversation

@jsoriano
Copy link
Copy Markdown
Member

So when multiple events are generated, the test can select one that
satisfies some condition instead of choosing the first one, like in this
example, that would write the first event with the messages key:

func TestData(t *testing.T) {
        f := mbtest.NewEventsFetcher(t, getConfig())
        err := mbtest.WriteEventsCond(f, t, func(e common.MapStr) bool {
                hadMessages, _ := e.HasKey("messages")
                return hadMessages
        })
        if err != nil {
                t.Fatal("write:", err)
        }
}

So when multiple events are generated, the test can select one that
satisfies some condition instead of chosing the first one, like in this
example, that would write the first event with the `messages` key:
```
func TestData(t *testing.T) {
        f := mbtest.NewEventsFetcher(t, getConfig())
        err := mbtest.WriteEventsCond(f, t, func(e common.MapStr) bool {
                hadMessages, _ := e.HasKey("messages")
                return hadMessages
        })
        if err != nil {
                t.Fatal("write:", err)
        }
}
```
Copy link
Copy Markdown
Contributor

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WFG

@ruflin ruflin merged commit eccb4a3 into elastic:master Apr 27, 2018
jsoriano added a commit to jsoriano/beats that referenced this pull request Jan 28, 2019
Add elastic#6958 also for V2 reporters.

When destination path is not a directory, use it as file.
jsoriano added a commit to jsoriano/beats that referenced this pull request Jan 28, 2019
Add elastic#6958 also for V2 reporters.

When destination path is not a directory, use it as file.
jsoriano added a commit that referenced this pull request Jan 28, 2019
Add #6958 also for V2 reporters.

When destination path is not a directory, use it as file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants