(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | |
| 31 | func TestRotatingFile_Rotate(t *testing.T) { |
| 32 | t.Parallel() |
nothing calls this directly
no test coverage detected