Skip to content

Commit

Permalink
- allow tests more time to complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Eik FromHome Madsen committed Jul 21, 2023
1 parent 04865be commit cb4b39c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
13 changes: 9 additions & 4 deletions http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ import (
"time"
)

// newTestTimer returns a new time with longer default timeout to allow -race to complete
func newTestTimer() *Manager {
return New(WithTimeout(time.Second * 300))
}

func TestWrapHandlerBasic(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var finished = false
fn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -42,7 +47,7 @@ func TestWrapHandlerBasic(t *testing.T) {
}

func TestWrapHandlerFuncBasic(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var finished = false
fn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -130,7 +135,7 @@ func TestWrapHandlerFuncPanic(t *testing.T) {

// Tests that shutdown doesn't complete until handler function has returned
func TestWrapHandlerOrder(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var finished = make(chan bool)
var wait = make(chan bool)
Expand Down Expand Up @@ -185,7 +190,7 @@ func TestWrapHandlerOrder(t *testing.T) {

// Tests that shutdown doesn't complete until handler function has returned
func TestWrapHandlerFuncOrder(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var finished = make(chan bool)
var wait = make(chan bool)
Expand Down
46 changes: 23 additions & 23 deletions shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func startTimer(m *Manager, t *testing.T) chan struct{} {
}

func TestBasic(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
f := m.First()
ok := false
Expand All @@ -62,7 +62,7 @@ func TestBasic(t *testing.T) {
}

func TestCancel(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
f := m.First()
ok := false
Expand All @@ -79,7 +79,7 @@ func TestCancel(t *testing.T) {
}

func TestCancel2(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
f2 := m.First()
f := m.First()
Expand Down Expand Up @@ -155,9 +155,9 @@ func TestCancelWait2(t *testing.T) {
// TestCancelWait3 assert that we can CancelWait, and that wait will wait until the
// specified stage.
func TestCancelWait3(t *testing.T) {
m := New(WithTimeout(time.Millisecond * 1000))
m := New(WithTimeout(time.Millisecond * 3000))

defer close(startTimer(m, t))
// defer close(startTimer(m, t))
f := m.First()
var ok, ok2, ok3 bool
f2 := m.Second()
Expand Down Expand Up @@ -275,7 +275,7 @@ func TestContextLog(t *testing.T) {
}

func TestFnCancelWait(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
f := m.First()
var ok, ok2 bool
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestFnCancelWait(t *testing.T) {
}

func TestNilNotifier(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var reached = make(chan struct{})
var finished = make(chan struct{})
Expand All @@ -329,7 +329,7 @@ func TestNilNotifier(t *testing.T) {
}

func TestNilNotifierCancel(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var reached = make(chan struct{})
var finished = make(chan struct{})
Expand All @@ -352,7 +352,7 @@ func TestNilNotifierCancel(t *testing.T) {
}

func TestNilNotifierCancelWait(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var reached = make(chan struct{})
var finished = make(chan struct{})
Expand All @@ -375,7 +375,7 @@ func TestNilNotifierCancelWait(t *testing.T) {
}

func TestNilNotifierFollowing(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var reached = make(chan struct{})
var finished = make(chan struct{})
Expand All @@ -401,7 +401,7 @@ func TestNilNotifierFollowing(t *testing.T) {
}

func TestWait(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
ok := make(chan bool)
go func() {
Expand Down Expand Up @@ -513,7 +513,7 @@ func TestTimeoutN2(t *testing.T) {
}

func TestOrder(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))

t3 := m.Third()
Expand Down Expand Up @@ -583,7 +583,7 @@ func TestOrder(t *testing.T) {
}

func TestRecursive(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))

if m.Started() {
Expand Down Expand Up @@ -621,7 +621,7 @@ func TestRecursive(t *testing.T) {
}

func TestBasicFn(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
gotcall := false

Expand All @@ -644,7 +644,7 @@ func setBool(i *bool) func() {
}

func TestFnOrder(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))

var ok1, ok2, ok3 bool
Expand Down Expand Up @@ -675,7 +675,7 @@ func TestFnOrder(t *testing.T) {
}

func TestFnRecursive(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))

var ok1, ok2, ok3 bool
Expand Down Expand Up @@ -707,7 +707,7 @@ func TestFnRecursive(t *testing.T) {

// When setting First or Second inside stage three they should be ignored.
func TestFnRecursiveRev(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))

var ok1, ok2, ok3 bool
Expand Down Expand Up @@ -738,7 +738,7 @@ func TestFnRecursiveRev(t *testing.T) {
}

func TestFnCancel(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var g0, g1, g2, g3 bool

Expand Down Expand Up @@ -769,7 +769,7 @@ func TestFnCancel(t *testing.T) {
}

func TestFnCancelWait2(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
var g0, g1, g2, g3 bool

Expand Down Expand Up @@ -800,7 +800,7 @@ func TestFnCancelWait2(t *testing.T) {
}

func TestFnPanic(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
gotcall := false

Expand All @@ -818,7 +818,7 @@ func TestFnPanic(t *testing.T) {
}

func TestFnNotify(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))
gotcall := false

Expand Down Expand Up @@ -911,7 +911,7 @@ func TestStatusTimer(t *testing.T) {
}

func TestFnSingleCancel(t *testing.T) {
m := New()
m := newTestTimer()
defer close(startTimer(m, t))

var ok1, ok2, ok3, okcancel bool
Expand Down Expand Up @@ -1202,7 +1202,7 @@ func ExampleWait() {
// ignore this reset, for test purposes only
t.Parallel()
m := New()
m := NewTestTimer()
// Wait for the jobs above to finish
go func() {
Expand Down

0 comments on commit cb4b39c

Please sign in to comment.