Don't forget to close buffer in tests
This commit is contained in:
parent
be5155b227
commit
89d7c1f584
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue