Skip to content

Commit

Permalink
test rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
nbari committed Sep 7, 2016
1 parent 70bdc34 commit b80154e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions logrotate_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package logrotate

import (
"fmt"
"io/ioutil"
"log"
"os"
Expand Down Expand Up @@ -93,8 +94,8 @@ func TestRotate(t *testing.T) {
}
}

func TestRotateIfNotEmpty(t *testing.T) {
dir, err := ioutil.TempDir("", "TestRotateIfNotEmpty")
func TestRotateRotate(t *testing.T) {
dir, err := ioutil.TempDir("", "TestRotateRotate")
if err != nil {
t.Error(err)
}
Expand All @@ -109,6 +110,7 @@ func TestRotateIfNotEmpty(t *testing.T) {
if err != nil {
t.Error(err)
}
fmt.Printf("dir = %+v\n", dir)
l.Rotate()
log.SetOutput(l)
for i := 0; i <= 100; i++ {
Expand All @@ -121,4 +123,12 @@ func TestRotateIfNotEmpty(t *testing.T) {
if len(files) != 2 {
t.Errorf("Expecting 2 files got: %v", len(files))
}
l.Rotate()
files, err = ioutil.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
if len(files) != 3 {
t.Errorf("Expecting 3 files got: %v", len(files))
}
}

0 comments on commit b80154e

Please sign in to comment.