Skip to content

Commit

Permalink
improve test readability
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed May 7, 2024
1 parent fc4b93a commit 585bf5b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/component/loki/source/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/stretchr/testify/require"
)

const taskRestartInterval = 20 * time.Millisecond

func Test(t *testing.T) {
// Use host that works on all platforms (including Windows).
var cfg = `
Expand Down Expand Up @@ -108,9 +110,9 @@ func TestRestart(t *testing.T) {

// Stops the container.
runningState = false
time.Sleep(30 * time.Millisecond) // Sleep for a duration greater than the interval to make sure it stops sending log lines.
time.Sleep(taskRestartInterval + 10*time.Millisecond) // Sleep for a duration greater than taskRestartInterval to make sure it stops sending log lines.
entryHandler.Clear()
time.Sleep(30 * time.Millisecond)
time.Sleep(taskRestartInterval + 10*time.Millisecond)
assert.Empty(t, entryHandler.Received()) // No log lines because the container was not running.

// Restart the container and expect log lines.
Expand Down Expand Up @@ -148,7 +150,7 @@ func setupTailer(t *testing.T, client clientMock) (tailer *tailer, entryHandler
tailerTask := &tailerTask{
options: &options{
client: client,
taskRestartInterval: 20 * time.Millisecond,
taskRestartInterval: taskRestartInterval,
},
target: tgt,
}
Expand Down

0 comments on commit 585bf5b

Please sign in to comment.