Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch committed Apr 9, 2020
1 parent 871bea3 commit 25cdd13
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions libbeat/common/file/interval_rotator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func TestSecondRotator(t *testing.T) {
a, err := newIntervalRotator(time.Second)
a, err := newMockIntervalRotator(time.Second)
if err != nil {
t.Fatal(err)
}
Expand All @@ -51,7 +51,7 @@ func TestSecondRotator(t *testing.T) {
}

func TestMinuteRotator(t *testing.T) {
a, err := newIntervalRotator(time.Minute)
a, err := newMockIntervalRotator(time.Minute)
if err != nil {
t.Fatal(err)
}
Expand All @@ -77,7 +77,7 @@ func TestMinuteRotator(t *testing.T) {
}

func TestHourlyRotator(t *testing.T) {
a, err := newIntervalRotator(time.Hour)
a, err := newMockIntervalRotator(time.Hour)
if err != nil {
t.Fatal(err)
}
Expand All @@ -103,7 +103,7 @@ func TestHourlyRotator(t *testing.T) {
}

func TestDailyRotator(t *testing.T) {
a, err := newIntervalRotator(24 * time.Hour)
a, err := newMockIntervalRotator(24 * time.Hour)
if err != nil {
t.Fatal(err)
}
Expand All @@ -129,7 +129,7 @@ func TestDailyRotator(t *testing.T) {
}

func TestWeeklyRotator(t *testing.T) {
a, err := newIntervalRotator(7 * 24 * time.Hour)
a, err := newMockIntervalRotator(7 * 24 * time.Hour)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestWeeklyRotator(t *testing.T) {
}

func TestMonthlyRotator(t *testing.T) {
a, err := newIntervalRotator(30 * 24 * time.Hour)
a, err := newMockIntervalRotator(30 * 24 * time.Hour)
if err != nil {
t.Fatal(err)
}
Expand All @@ -184,7 +184,7 @@ func TestMonthlyRotator(t *testing.T) {
}

func TestYearlyRotator(t *testing.T) {
a, err := newIntervalRotator(365 * 24 * time.Hour)
a, err := newMockIntervalRotator(365 * 24 * time.Hour)
if err != nil {
t.Fatal(err)
}
Expand All @@ -210,7 +210,7 @@ func TestYearlyRotator(t *testing.T) {
}

func TestArbitraryIntervalRotator(t *testing.T) {
a, err := newIntervalRotator(3 * time.Second)
a, err := newMockIntervalRotator(3 * time.Second)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -253,15 +253,15 @@ func TestArbitraryIntervalRotator(t *testing.T) {
}

func TestIntervalIsTruncatedToSeconds(t *testing.T) {
a, err := newIntervalRotator(2345 * time.Millisecond)
a, err := newMockIntervalRotator(2345 * time.Millisecond)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 2*time.Second, a.interval)
}

func TestZeroIntervalIsNil(t *testing.T) {
a, err := newIntervalRotator(0)
a, err := newMockIntervalRotator(0)
if err != nil {
t.Fatal(err)
}
Expand All @@ -275,3 +275,7 @@ type testClock struct {
func (t testClock) Now() time.Time {
return t.time
}

func newMockIntervalRotator(interval time.Duration) (*intervalRotator, error) {
return newIntervalRotator(nil, interval, false, "foo")
}

0 comments on commit 25cdd13

Please sign in to comment.