Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Oct 13, 2020
1 parent 1285d15 commit a44de9b
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions filebeat/input/filestream/prospector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,14 @@ func TestProspectorNewAndUpdatedFiles(t *testing.T) {
test := test

t.Run(name, func(t *testing.T) {
pathIdentifier, err := newPathIdentifier(nil)
if err != nil {
t.Fatal(err)
}

p := fileProspector{
filewatcher: &mockFileWatcher{events: test.events},
identifier: pathIdentifier,
identifier: mustPathIdentifier(),
ignoreOlder: test.ignoreOlder,
}

ctx := input.Context{Logger: logp.L(), Cancelation: context.Background()}
hg := getTestHarvesterGroup()

p.Run(ctx, testStateStore(), hg)

assert.ElementsMatch(t, hg.encounteredNames, test.expectedSources)
Expand Down Expand Up @@ -134,18 +129,13 @@ func TestProspectorDeletedFile(t *testing.T) {
test := test

t.Run(name, func(t *testing.T) {
pathIdentifier, err := newPathIdentifier(nil)
if err != nil {
t.Fatal(err)
}

p := fileProspector{
filewatcher: &mockFileWatcher{events: test.events},
identifier: pathIdentifier,
identifier: mustPathIdentifier(),
cleanRemoved: test.cleanRemoved,
}

ctx := input.Context{Logger: logp.L(), Cancelation: context.Background()}

testStore := testStateStore()
testStore.Set("filestream::path::/path/to/file", nil)

Expand Down Expand Up @@ -196,3 +186,12 @@ func testStateStore() *statestore.Store {
s, _ := statestore.NewRegistry(storetest.NewMemoryStoreBackend()).Get(pluginName)
return s
}

func mustPathIdentifier() fileIdentifier {
pathIdentifier, err := newPathIdentifier(nil)
if err != nil {
panic(err)
}
return pathIdentifier

}

0 comments on commit a44de9b

Please sign in to comment.