summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/braintree/manners/helper_test.go
blob: ea721a180030adc611da936bbcb42022e136e6e3 (plain)
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
26
27
28
29
30
31
32
33
34
package manners

import (
	"net/http"
	"time"
)

// A response handler that blocks until it receives a signal; simulates an
// arbitrarily long web request. The "ready" channel is to prevent a race
// condition in the test where the test moves on before the server is ready
// to handle the request.
func newBlockingHandler(ready, done chan bool) *blockingHandler {
	return &blockingHandler{ready, done}
}

type blockingHandler struct {
	ready chan bool
	done  chan bool
}

func (h *blockingHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
	h.ready <- true
	time.Sleep(1e2)
	h.done <- true
}

// A response handler that does nothing.
func newTestHandler() testHandler {
	return testHandler{}
}

type testHandler struct{}

func (h testHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {}