From 9cccf8f88a71f0c13c37b63d6dea045c2f1bf666 Mon Sep 17 00:00:00 2001 From: palkan Date: Fri, 16 Oct 2015 17:54:33 +0300 Subject: [PATCH] Add locking to test accumulator --- testutil/accumulator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testutil/accumulator.go b/testutil/accumulator.go index 1eca05946..e83eb58bb 100644 --- a/testutil/accumulator.go +++ b/testutil/accumulator.go @@ -4,6 +4,7 @@ import ( "fmt" "reflect" "time" + "sync" ) // Point defines a single point measurement @@ -16,11 +17,14 @@ type Point struct { // Accumulator defines a mocked out accumulator type Accumulator struct { + sync.Mutex Points []*Point } // Add adds a measurement point to the accumulator func (a *Accumulator) Add(measurement string, value interface{}, tags map[string]string) { + a.Lock() + defer a.Unlock() if tags == nil { tags = map[string]string{} }