Commit f9ff0e5b authored by Steven Allen's avatar Steven Allen

make tests more reliable

parent d52d20ae
...@@ -17,7 +17,7 @@ func TestBasic(t *testing.T) { ...@@ -17,7 +17,7 @@ func TestBasic(t *testing.T) {
defer ticker.Stop() defer ticker.Stop()
m := new(Meter) m := new(Meter)
for i := 0; i < 100; i++ { for i := 0; i < 300; i++ {
m.Mark(1000) m.Mark(1000)
<-ticker.C <-ticker.C
} }
...@@ -42,8 +42,8 @@ func TestBasic(t *testing.T) { ...@@ -42,8 +42,8 @@ func TestBasic(t *testing.T) {
// get the right total // get the right total
actual = m.Snapshot() actual = m.Snapshot()
if actual.Total != 140000 { if actual.Total != 340000 {
t.Errorf("expected total %d, got %d", 120000, actual.Total) t.Errorf("expected total %d, got %d", 340000, actual.Total)
} }
}() }()
} }
...@@ -60,7 +60,7 @@ func TestShared(t *testing.T) { ...@@ -60,7 +60,7 @@ func TestShared(t *testing.T) {
defer wg.Done() defer wg.Done()
ticker := time.NewTicker(40 * time.Millisecond) ticker := time.NewTicker(40 * time.Millisecond)
defer ticker.Stop() defer ticker.Stop()
for i := 0; i < 100; i++ { for i := 0; i < 300; i++ {
m.Mark(50) m.Mark(50)
<-ticker.C <-ticker.C
} }
...@@ -73,7 +73,7 @@ func TestShared(t *testing.T) { ...@@ -73,7 +73,7 @@ func TestShared(t *testing.T) {
} }
go func() { go func() {
defer wg.Done() defer wg.Done()
time.Sleep(40 * 100 * time.Millisecond) time.Sleep(40 * 300 * time.Millisecond)
actual := m.Snapshot() actual := m.Snapshot()
if !approxEq(actual.Rate, 25000, 250) { if !approxEq(actual.Rate, 25000, 250) {
t.Errorf("expected rate 25000 (±250), got %f", actual.Rate) t.Errorf("expected rate 25000 (±250), got %f", actual.Rate)
...@@ -92,8 +92,8 @@ func TestShared(t *testing.T) { ...@@ -92,8 +92,8 @@ func TestShared(t *testing.T) {
// get the right total // get the right total
actual = m.Snapshot() actual = m.Snapshot()
if actual.Total != 140000 { if actual.Total != 340000 {
t.Errorf("expected total %d, got %d", 140000, actual.Total) t.Errorf("expected total %d, got %d", 340000, actual.Total)
} }
}() }()
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment