File: testutil_test.go

package info (click to toggle)
golang-github-araddon-gou 0.0~git20180509.7db4be5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 160 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 312 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package gou

import (
	"testing"
	"time"
)

func TestWaitFor(t *testing.T) {

	isDone := false
	foundDone := false
	go func() {
		time.Sleep(time.Second * 1)
		isDone = true
	}()
	WaitFor(func() bool {
		if isDone == true {
			foundDone = true
		}
		return isDone == true
	}, 2)
	if !foundDone {
		t.Fail()
	}
}