(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestCompressMaintainMode(t *testing.T) { |
| 88 | currentTime = fakeTime |
| 89 | |
| 90 | dir := makeTempDir("TestCompressMaintainMode", t) |
| 91 | defer os.RemoveAll(dir) |
| 92 | |
| 93 | filename := logFile(dir) |
| 94 | |
| 95 | mode := os.FileMode(0600) |
| 96 | f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, mode) |
| 97 | isNil(err, t) |
| 98 | f.Close() |
| 99 | |
| 100 | l := &Logger{ |
| 101 | Compress: true, |
| 102 | Filename: filename, |
| 103 | MaxBackups: 1, |
| 104 | MaxSize: 100, // megabytes |
| 105 | } |
| 106 | defer l.Close() |
| 107 | b := []byte("boo!") |
| 108 | n, err := l.Write(b) |
| 109 | isNil(err, t) |
| 110 | equals(len(b), n, t) |
| 111 | |
| 112 | newFakeTime() |
| 113 | |
| 114 | err = l.Rotate() |
| 115 | isNil(err, t) |
| 116 | |
| 117 | // we need to wait a little bit since the files get compressed on a different |
| 118 | // goroutine. |
| 119 | <-time.After(10 * time.Millisecond) |
| 120 | |
| 121 | // a compressed version of the log file should now exist with the correct |
| 122 | // mode. |
| 123 | filename2 := backupFile(dir) |
| 124 | info, err := os.Stat(filename) |
| 125 | isNil(err, t) |
| 126 | info2, err := os.Stat(filename2 + compressSuffix) |
| 127 | isNil(err, t) |
| 128 | equals(mode, info.Mode(), t) |
| 129 | equals(mode, info2.Mode(), t) |
| 130 | } |
| 131 | |
| 132 | func TestCompressMaintainOwner(t *testing.T) { |
| 133 | fakeFS := newFakeFS() |
nothing calls this directly
no test coverage detected
searching dependent graphs…