55 "compress/gzip"
66 "encoding/json"
77 "fmt"
8- "io/ioutil"
98 "os"
109 "path/filepath"
1110 "runtime"
@@ -63,7 +62,7 @@ func TestOpenExisting(t *testing.T) {
6362
6463 filename := logFile (dir )
6564 data := []byte ("foo!" )
66- err := ioutil .WriteFile (filename , data , 0644 )
65+ err := os .WriteFile (filename , data , 0600 )
6766 isNil (err , t )
6867 existsWithContent (filename , data , t )
6968
@@ -188,7 +187,7 @@ func TestFirstWriteRotate(t *testing.T) {
188187 defer l .Close ()
189188
190189 start := []byte ("boooooo!" )
191- err := ioutil .WriteFile (filename , start , 0600 )
190+ err := os .WriteFile (filename , start , 0600 )
192191 isNil (err , t )
193192
194193 newFakeTime ()
@@ -277,7 +276,7 @@ func TestMaxBackups(t *testing.T) {
277276 // create a file that is close to but different from the logfile name.
278277 // It shouldn't get caught by our deletion filters.
279278 notlogfile := logFile (dir ) + ".foo"
280- err = ioutil .WriteFile (notlogfile , []byte ("data" ), 0644 )
279+ err = os .WriteFile (notlogfile , []byte ("data" ), 0600 )
281280 isNil (err , t )
282281
283282 // Make a directory that exactly matches our log file filters... it still
@@ -295,7 +294,7 @@ func TestMaxBackups(t *testing.T) {
295294 // not be counted since both the compressed and the uncompressed
296295 // log files still exist.
297296 compLogFile := fourthFilename + compressSuffix
298- err = ioutil .WriteFile (compLogFile , []byte ("compress" ), 0644 )
297+ err = os .WriteFile (compLogFile , []byte ("compress" ), 0600 )
299298 isNil (err , t )
300299
301300 // this will make us rotate again
@@ -344,24 +343,24 @@ func TestCleanupExistingBackups(t *testing.T) {
344343
345344 data := []byte ("data" )
346345 backup := backupFile (dir )
347- err := ioutil .WriteFile (backup , data , 0644 )
346+ err := os .WriteFile (backup , data , 0600 )
348347 isNil (err , t )
349348
350349 newFakeTime ()
351350
352351 backup = backupFile (dir )
353- err = ioutil .WriteFile (backup + compressSuffix , data , 0644 )
352+ err = os .WriteFile (backup + compressSuffix , data , 0600 )
354353 isNil (err , t )
355354
356355 newFakeTime ()
357356
358357 backup = backupFile (dir )
359- err = ioutil .WriteFile (backup , data , 0644 )
358+ err = os .WriteFile (backup , data , 0600 )
360359 isNil (err , t )
361360
362361 // now create a primary log file with some data
363362 filename := logFile (dir )
364- err = ioutil .WriteFile (filename , data , 0644 )
363+ err = os .WriteFile (filename , data , 0600 )
365364 isNil (err , t )
366365
367366 l := & Logger {
@@ -462,7 +461,7 @@ func TestOldLogFiles(t *testing.T) {
462461
463462 filename := logFile (dir )
464463 data := []byte ("data" )
465- err := ioutil .WriteFile (filename , data , 07 )
464+ err := os .WriteFile (filename , data , 0600 )
466465 isNil (err , t )
467466
468467 // This gives us a time with the same precision as the time we get from the
@@ -471,7 +470,7 @@ func TestOldLogFiles(t *testing.T) {
471470 isNil (err , t )
472471
473472 backup := backupFile (dir )
474- err = ioutil .WriteFile (backup , data , 07 )
473+ err = os .WriteFile (backup , data , 0600 )
475474 isNil (err , t )
476475
477476 newFakeTime ()
@@ -480,7 +479,7 @@ func TestOldLogFiles(t *testing.T) {
480479 isNil (err , t )
481480
482481 backup2 := backupFile (dir )
483- err = ioutil .WriteFile (backup2 , data , 07 )
482+ err = os .WriteFile (backup2 , data , 0600 )
484483 isNil (err , t )
485484
486485 l := & Logger {Filename : filename }
@@ -666,9 +665,9 @@ func TestCompressOnResume(t *testing.T) {
666665 // Create a backup file and empty "compressed" file.
667666 filename2 := backupFile (dir )
668667 b := []byte ("foo!" )
669- err := ioutil .WriteFile (filename2 , b , 0644 )
668+ err := os .WriteFile (filename2 , b , 0600 )
670669 isNil (err , t )
671- err = ioutil .WriteFile (filename2 + compressSuffix , []byte {}, 0644 )
670+ err = os .WriteFile (filename2 + compressSuffix , []byte {}, 0600 )
672671 isNil (err , t )
673672
674673 newFakeTime ()
@@ -814,7 +813,7 @@ func TestMillRunDrainsPendingRequestBeforeStop(t *testing.T) {
814813 }
815814 // Pre-create a backup that the mill is expected to compress.
816815 backup := backupFile (dir )
817- err := ioutil .WriteFile (backup , []byte ("content" ), 0644 )
816+ err := os .WriteFile (backup , []byte ("content" ), 0600 )
818817 isNil (err , t )
819818
820819 l .millCh = make (chan bool , 1 )
@@ -848,7 +847,7 @@ func existsWithContent(path string, content []byte, t testing.TB) {
848847 isNilUp (err , t , 1 )
849848 equalsUp (int64 (len (content )), info .Size (), t , 1 )
850849
851- b , err := ioutil .ReadFile (path )
850+ b , err := os .ReadFile (path )
852851 isNilUp (err , t , 1 )
853852 equalsUp (content , b , t , 1 )
854853}
@@ -867,15 +866,9 @@ func backupFileLocal(dir string) string {
867866 return filepath .Join (dir , "foobar-" + fakeTime ().Format (backupTimeFormat )+ ".log" )
868867}
869868
870- // logFileLocal returns the log file name in the given directory for the current
871- // fake time using the local timezone.
872- func logFileLocal (dir string ) string {
873- return filepath .Join (dir , fakeTime ().Format (backupTimeFormat ))
874- }
875-
876869// fileCount checks that the number of files in the directory is exp.
877870func fileCount (dir string , exp int , t testing.TB ) {
878- files , err := ioutil .ReadDir (dir )
871+ files , err := os .ReadDir (dir )
879872 isNilUp (err , t , 1 )
880873 // Make sure no other files were created.
881874 equalsUp (exp , len (files ), t , 1 )
0 commit comments