Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
stop operator at the end of each test
Browse files Browse the repository at this point in the history
  • Loading branch information
rockb1017 committed Jun 9, 2021
1 parent 085721b commit 1c0e5c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion operator/builtin/input/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestReadExistingAndNewLogs(t *testing.T) {
t.Parallel()
operator, logReceived, tempDir := newTestFileOperator(t, nil, nil)
operator.persister = testutil.NewMockPersister("test")
defer operator.Stop()

// Start with a file with an entry in it, and expect that entry
// to come through when we poll for the first time
Expand All @@ -134,6 +135,7 @@ func TestStartAtEnd(t *testing.T) {
cfg.StartAt = "end"
}, nil)
operator.persister = testutil.NewMockPersister("test")
defer operator.Stop()

temp := openTemp(t, tempDir)
writeString(t, temp, "testlog1\n")
Expand All @@ -156,9 +158,9 @@ func TestStartAtEndNewFile(t *testing.T) {
operator, logReceived, tempDir := newTestFileOperator(t, nil, nil)
operator.persister = testutil.NewMockPersister("test")
operator.startAtBeginning = false
defer operator.Stop()

operator.poll(context.Background())

temp := openTemp(t, tempDir)
writeString(t, temp, "testlog1\ntestlog2\n")

Expand Down Expand Up @@ -205,6 +207,7 @@ func TestSplitWrite(t *testing.T) {
t.Parallel()
operator, logReceived, tempDir := newTestFileOperator(t, nil, nil)
operator.persister = testutil.NewMockPersister("test")
defer operator.Stop()

temp := openTemp(t, tempDir)
writeString(t, temp, "testlog1")
Expand Down Expand Up @@ -447,6 +450,7 @@ func TestFileBatching(t *testing.T) {
},
)
operator.persister = testutil.NewMockPersister("test")
defer operator.Stop()

temps := make([]*os.File, 0, files)
for i := 0; i < files; i++ {
Expand Down Expand Up @@ -492,13 +496,15 @@ func TestFileReader_FingerprintUpdated(t *testing.T) {
t.Parallel()

operator, logReceived, tempDir := newTestFileOperator(t, nil, nil)
defer operator.Stop()

temp := openTemp(t, tempDir)
tempCopy := openFile(t, temp.Name())
fp, err := operator.NewFingerprint(temp)
require.NoError(t, err)
reader, err := operator.NewReader(temp.Name(), tempCopy, fp)
require.NoError(t, err)
defer reader.Close()

writeString(t, temp, "testlog1\n")
reader.ReadToEnd(context.Background())
Expand Down

0 comments on commit 1c0e5c3

Please sign in to comment.