MCPcopy Index your code
hub / github.com/docker/docker-agent / TestRotatingFile_Write

Function TestRotatingFile_Write

pkg/logging/rotate_test.go:12–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestRotatingFile_Write(t *testing.T) {
13 t.Parallel()
14 dir := t.TempDir()
15 path := filepath.Join(dir, "test.log")
16
17 rf, err := NewRotatingFile(path, WithMaxSize(100), WithMaxBackups(2))
18 require.NoError(t, err)
19 defer rf.Close()
20
21 data := []byte("hello world\n")
22 n, err := rf.Write(data)
23 require.NoError(t, err)
24 assert.Equal(t, len(data), n)
25
26 content, err := os.ReadFile(path)
27 require.NoError(t, err)
28 assert.Equal(t, data, content)
29}
30
31func TestRotatingFile_Rotate(t *testing.T) {
32 t.Parallel()

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
WriteMethod · 0.95
NewRotatingFileFunction · 0.85
WithMaxSizeFunction · 0.85
WithMaxBackupsFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected