-
Notifications
You must be signed in to change notification settings - Fork 2
/
updater_test.go
39 lines (28 loc) · 856 Bytes
/
updater_test.go
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
35
36
37
38
39
package proxy
import (
"github.com/mailgun/oxy/testutils"
. "gopkg.in/check.v1"
"net/http"
"testing"
)
// /solr/{}/verb
func TestUpdater(t *testing.T) { TestingT(t) }
type UpdaterSuite struct{}
var _ = Suite(&UpdaterSuite{})
func (s *UpdaterSuite) TestUpdaterRoundRobin(c *C) {
called1 := false
srv1 := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
called1 = true
})
defer srv1.Close()
updater := NewUpdater(srv1.URL)
proxyWrapper := testutils.NewHandler(func(w http.ResponseWriter, req *http.Request) {
updater.ServeHTTP(w, req, &AWSConfig{}, "collection1")
})
defer proxyWrapper.Close()
re, z, err := testutils.Get(proxyWrapper.URL, testutils.Headers(http.Header{}))
c.Logf("Z: %#+v", string(z))
c.Assert(err, IsNil)
c.Assert(re.StatusCode, Equals, http.StatusOK)
c.Assert(called1, Equals, true)
}