Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filtering function for data generation #6958

Merged
merged 1 commit into from
Apr 27, 2018

Conversation

jsoriano
Copy link
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
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