notify/file_event_metrics_test.go

34 lines
890 B
Go
Raw Normal View History

package notify
import (
"testing"
"time"
)
func TestFillFileEventTimeline(t *testing.T) {
event := FileEvent{
Received: 150,
}
timeline := fileEventTimeline{
startedAt: time.Unix(100, 0),
updatedAt: time.Unix(110, 0),
previousUpdatedAt: time.Unix(106, 0),
previousProgress: 90,
}
fillFileEventTimeline(&event, timeline)
if got, want := event.StartedAt, timeline.startedAt; !got.Equal(want) {
t.Fatalf("startedAt mismatch: got %v want %v", got, want)
}
if got, want := event.UpdatedAt, timeline.updatedAt; !got.Equal(want) {
t.Fatalf("updatedAt mismatch: got %v want %v", got, want)
}
if got, want := event.StepDuration, 4*time.Second; got != want {
t.Fatalf("step duration mismatch: got %v want %v", got, want)
}
if got, want := event.InstantRateBPS, 15.0; got != want {
t.Fatalf("instant rate mismatch: got %v want %v", got, want)
}
}