1
0
Fork 0

Don't forget to close buffer in tests

This commit is contained in:
Gregory Eremin 2014-08-12 15:23:22 +07:00
parent be5155b227
commit 89d7c1f584
No known key found for this signature in database
GPG Key ID: 5EFA427EEC26E86C
1 changed files with 7 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import (
func TestNewBuffer(t *testing.T) {
fn := func(series []*influxdb.Series) {}
b := NewBuffer(10, fn)
defer b.Close()
if b == nil {
t.Error("Failed to instantiate buffer with `NewBuffer` function")
@ -19,6 +20,7 @@ func TestNewBuffer(t *testing.T) {
func TestAdd(t *testing.T) {
fn := func(series []*influxdb.Series) {}
b := NewBuffer(10, fn)
defer b.Close()
if b.Size() != 0 {
t.Error("Freshly created buffer is not empty")
@ -33,10 +35,9 @@ func TestAdd(t *testing.T) {
func TestFlush(t *testing.T) {
res := make(chan []*influxdb.Series, 1)
fn := func(series []*influxdb.Series) {
res <- series
}
fn := func(series []*influxdb.Series) { res <- series }
b := NewBuffer(1, fn)
defer b.Close()
b.Add(&influxdb.Series{})
timer := time.NewTimer(time.Second)
@ -55,6 +56,7 @@ func TestFlush(t *testing.T) {
func TestLookup(t *testing.T) {
fn := func(series []*influxdb.Series) {}
b := NewBuffer(10, fn)
defer b.Close()
b.Add(
&influxdb.Series{
Name: "foo",
@ -174,10 +176,9 @@ func TestClose(t *testing.T) {
func TestAggregate(t *testing.T) {
res := make(chan []*influxdb.Series, 1)
fn := func(series []*influxdb.Series) {
res <- series
}
fn := func(series []*influxdb.Series) { res <- series }
b := NewBuffer(3, fn)
defer b.Close()
b.Add(
&influxdb.Series{
Name: "foo",