From 73dcbc537fb9503f6fefa502a37665f0dc3b357e Mon Sep 17 00:00:00 2001 From: Matt Aimonetti Date: Sat, 26 Apr 2014 11:13:25 -0600 Subject: [PATCH] made tests fast again --- utils_test.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/utils_test.go b/utils_test.go index a3eb3b04..c8bb1991 100644 --- a/utils_test.go +++ b/utils_test.go @@ -1,9 +1,9 @@ package gobot import ( + "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "time" ) var _ = Describe("Utils", func() { @@ -15,22 +15,18 @@ var _ = Describe("Utils", func() { Context("when valid", func() { It("should execute function at every interval", func() { var i = 0 - Every("500ms", func() { - i = i + 1 + Every("2ms", func() { + i++ }) - time.Sleep(600 * time.Millisecond) - Expect(i).To(Equal(1)) - time.Sleep(600 * time.Millisecond) - Expect(i).To(Equal(2)) + time.Sleep(5 * time.Millisecond) + Expect(2).To(Equal(i)) }) It("should execute function after specific interval", func() { var i = 0 - After("500ms", func() { + After("1ms", func() { i = i + 1 }) - time.Sleep(600 * time.Millisecond) - Expect(i).To(Equal(1)) - time.Sleep(600 * time.Millisecond) + time.Sleep(2 * time.Millisecond) Expect(i).To(Equal(1)) }) It("should Publish message to channel without blocking", func() {