Skip to content

Commit 89f5548

Browse files
committed
Open file with correct flags on windows
1 parent 1fa3763 commit 89f5548

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/component/loki/source/file/internal/tail/block_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"time"
1010

1111
"github.com/stretchr/testify/require"
12+
13+
"github.com/grafana/alloy/internal/component/loki/source/file/internal/tail/fileext"
1214
)
1315

1416
func TestBlockUntilExists(t *testing.T) {
@@ -90,6 +92,11 @@ func TestBlockUntilEvent(t *testing.T) {
9092

9193
t.Run("should return deleted event if file is deleted", func(t *testing.T) {
9294
f := createEmptyFile(t, "startempty")
95+
require.NoError(t, f.Close())
96+
97+
// NOTE: important for windows that we open with correct flags.
98+
f, err := fileext.OpenFile(f.Name())
99+
require.NoError(t, err)
93100
defer f.Close()
94101

95102
go func() {
@@ -107,6 +114,11 @@ func TestBlockUntilEvent(t *testing.T) {
107114

108115
t.Run("should return deleted event if file is deleted before", func(t *testing.T) {
109116
f := createEmptyFile(t, "startempty")
117+
require.NoError(t, f.Close())
118+
119+
// NOTE: important for windows that we open with correct flags.
120+
f, err := fileext.OpenFile(f.Name())
121+
require.NoError(t, err)
110122
defer f.Close()
111123

112124
removeFile(t, f.Name())

0 commit comments

Comments
 (0)