diff --git a/.travis.yml b/.travis.yml index 0b1f62e9..1d157e17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: go -go: - - 1.6.3 +go: - 1.7.3 - tip diff --git a/README.md b/README.md index 98d7d450..4bfecb54 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ the [CLI documentation](https://caddyserver.com/docs/cli) for details. ## Running from Source -Note: You will need **[Go 1.6](https://golang.org/dl/)** or newer. +Note: You will need **[Go 1.7](https://golang.org/dl/)** or newer. 1. `go get github.com/mholt/caddy/caddy` 2. `cd` into your website's directory diff --git a/caddyhttp/log/log_test.go b/caddyhttp/log/log_test.go index 957c1f3c..5cadfae6 100644 --- a/caddyhttp/log/log_test.go +++ b/caddyhttp/log/log_test.go @@ -104,10 +104,7 @@ func TestLogRequestBody(t *testing.T) { }, } { got.Reset() - r, err := http.NewRequest("POST", "/", bytes.NewBufferString(c.body)) - if err != nil { - t.Fatal(err) - } + r := httptest.NewRequest("POST", "/", bytes.NewBufferString(c.body)) r.Header.Set("Content-Type", "application/json") status, err := logger.ServeHTTP(httptest.NewRecorder(), r) if status != 0 { diff --git a/caddyhttp/proxy/proxy_test.go b/caddyhttp/proxy/proxy_test.go index 81c45735..af02a17c 100644 --- a/caddyhttp/proxy/proxy_test.go +++ b/caddyhttp/proxy/proxy_test.go @@ -43,10 +43,7 @@ func TestReverseProxy(t *testing.T) { } // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } + r := httptest.NewRequest("GET", "/", nil) w := httptest.NewRecorder() p.ServeHTTP(w, r) @@ -84,10 +81,7 @@ func TestReverseProxyInsecureSkipVerify(t *testing.T) { } // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } + r := httptest.NewRequest("GET", "/", nil) w := httptest.NewRecorder() p.ServeHTTP(w, r) @@ -114,10 +108,8 @@ func TestWebSocketReverseProxyNonHijackerPanic(t *testing.T) { p := newWebSocketTestProxy(wsNop.URL) // Create client request - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } + r := httptest.NewRequest("GET", "/", nil) + r.Header = http.Header{ "Connection": {"Upgrade"}, "Upgrade": {"websocket"}, @@ -141,10 +133,8 @@ func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) { p := newWebSocketTestProxy(wsNop.URL) // Create client request - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } + r := httptest.NewRequest("GET", "/", nil) + r.Header = http.Header{ "Connection": {"Upgrade"}, "Upgrade": {"websocket"}, @@ -195,6 +185,7 @@ func TestWebSocketReverseProxyFromWSClient(t *testing.T) { // Set up WebSocket client url := strings.Replace(echoProxy.URL, "http://", "ws://", 1) ws, err := websocket.Dial(url, "", echoProxy.URL) + if err != nil { t.Fatal(err) } @@ -202,11 +193,18 @@ func TestWebSocketReverseProxyFromWSClient(t *testing.T) { // Send test message trialMsg := "Is it working?" - websocket.Message.Send(ws, trialMsg) + + if sendErr := websocket.Message.Send(ws, trialMsg); sendErr != nil { + t.Fatal(sendErr) + } // It should be echoed back to us var actualMsg string - websocket.Message.Receive(ws, &actualMsg) + + if rcvErr := websocket.Message.Receive(ws, &actualMsg); rcvErr != nil { + t.Fatal(rcvErr) + } + if actualMsg != trialMsg { t.Errorf("Expected '%s' but got '%s' instead", trialMsg, actualMsg) } @@ -419,10 +417,7 @@ func TestUpstreamHeadersUpdate(t *testing.T) { } // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } + r := httptest.NewRequest("GET", "/", nil) w := httptest.NewRecorder() const expectHost = "example.com" @@ -499,10 +494,7 @@ func TestDownstreamHeadersUpdate(t *testing.T) { } // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } + r := httptest.NewRequest("GET", "/", nil) w := httptest.NewRecorder() // set a predefined skip header w.Header().Set("Content-Type", "text/css") @@ -627,8 +619,9 @@ func TestMultiReverseProxyFromClient(t *testing.T) { // Create client request reqURL := proxy.URL + tt.url req, err := http.NewRequest("GET", reqURL, nil) + if err != nil { - t.Fatalf("Failed to create request: %v", err) + t.Fatalf("Failed to make request: %v", err) } resp, err := http.DefaultClient.Do(req) @@ -661,12 +654,9 @@ func TestHostSimpleProxyNoHeaderForward(t *testing.T) { Upstreams: []Upstream{newFakeUpstream(backend.URL, false)}, } - r, err := http.NewRequest("GET", "/", nil) + r := httptest.NewRequest("GET", "/", nil) r.Host = "test.com" - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } w := httptest.NewRecorder() p.ServeHTTP(w, r) @@ -698,12 +688,9 @@ func TestHostHeaderReplacedUsingForward(t *testing.T) { Upstreams: []Upstream{upstream}, } - r, err := http.NewRequest("GET", "/", nil) + r := httptest.NewRequest("GET", "/", nil) r.Host = "test.com" - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } w := httptest.NewRecorder() p.ServeHTTP(w, r)