-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathosquerybeat_publisher_test.go
More file actions
60 lines (44 loc) · 1.74 KB
/
Copy pathosquerybeat_publisher_test.go
File metadata and controls
60 lines (44 loc) · 1.74 KB
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
51
52
53
54
55
56
57
58
59
60
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
package beater
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/elastic/beats/v7/x-pack/osquerybeat/internal/config"
"github.com/elastic/beats/v7/x-pack/osquerybeat/internal/ecs"
)
type mockBeatPublisher struct {
closeCalled bool
}
var _ osquerybeatPublisher = (*mockBeatPublisher)(nil)
var _ scheduledQueryPublisher = (*mockBeatPublisher)(nil)
func (m *mockBeatPublisher) Publish(index, idValue, idFieldKey, responseID, spaceID, packID, packName, queryName string, meta map[string]interface{}, hits []map[string]interface{}, ecsm ecs.Mapping, reqData interface{}) {
}
func (m *mockBeatPublisher) PublishActionResult(req map[string]interface{}, res map[string]interface{}) {
}
func (m *mockBeatPublisher) PublishScheduledResponse(scheduleID, packID, packName, queryName, spaceID, responseID string, startedAt, completedAt, plannedScheduleTime time.Time, resultCount int, scheduleExecutionCount int64) {
}
func (m *mockBeatPublisher) PublishQueryProfile(index, queryName, actionID, responseID string, profile map[string]interface{}, reqData interface{}) {
}
func (m *mockBeatPublisher) Configure(inputs []config.InputConfig) error {
return nil
}
func (m *mockBeatPublisher) Close() {
m.closeCalled = true
}
func TestOsquerybeatClose_ClosesPublisher(t *testing.T) {
p := &mockBeatPublisher{}
cancelCalled := false
bt := &osquerybeat{
pub: p,
cancel: func() {
cancelCalled = true
},
}
bt.close()
assert.True(t, p.closeCalled)
assert.True(t, cancelCalled)
assert.Nil(t, bt.cancel)
}