(t *testing.T)
| 101 | } |
| 102 | |
| 103 | func TestRotatingFile_AppendsToExisting(t *testing.T) { |
| 104 | t.Parallel() |
| 105 | dir := t.TempDir() |
| 106 | path := filepath.Join(dir, "test.log") |
| 107 | |
| 108 | // Create a file with existing content |
| 109 | err := os.WriteFile(path, []byte("existing\n"), 0o600) |
| 110 | require.NoError(t, err) |
| 111 | |
| 112 | rf, err := NewRotatingFile(path, WithMaxSize(1000), WithMaxBackups(2)) |
| 113 | require.NoError(t, err) |
| 114 | defer rf.Close() |
| 115 | |
| 116 | _, err = rf.Write([]byte("new\n")) |
| 117 | require.NoError(t, err) |
| 118 | |
| 119 | content, err := os.ReadFile(path) |
| 120 | require.NoError(t, err) |
| 121 | assert.Equal(t, "existing\nnew\n", string(content)) |
| 122 | } |
| 123 | |
| 124 | func TestRotatingFile_CreatesDirectory(t *testing.T) { |
| 125 | t.Parallel() |
nothing calls this directly
no test coverage detected