Skip to content

Commit

Permalink
This test illustrates a problem with Points.newFieldsFromBinary.
Browse files Browse the repository at this point in the history
Prior to #5697 it causes a panic, after #5697 it causes an infinite loop

Signed-off-by: Jon Seymour <jon@wildducktheories.com>
  • Loading branch information
jonseymour committed Feb 17, 2016
1 parent b8bb32e commit 23be938
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions models/points_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1772,3 +1772,21 @@ t159,label=another a=2i,value=1i 1`
t.Fatalf("expected 2 points, got %d", len(points))
}
}

func TestAddFieldWithEmptyName(t *testing.T) {
ch := make(chan struct{})
go func() {
p, err := models.NewPoint("foo", nil, models.Fields{"a": 1}, time.Now())
if err != nil {
t.Fatalf("%v", err)
}
p.AddField("", 2)
p.AddField("b", 3) // causes infinite loop in newFieldsFromBinary
close(ch)
}()
select {
case _ = <-ch:
case _ = <-time.NewTimer(time.Second).C:
t.Fatalf("failed: probable infite loop")
}
}

0 comments on commit 23be938

Please sign in to comment.