summaryrefslogtreecommitdiffstats
path: root/client/go/util/http_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/go/util/http_test.go')
-rw-r--r--client/go/util/http_test.go55
1 files changed, 0 insertions, 55 deletions
diff --git a/client/go/util/http_test.go b/client/go/util/http_test.go
deleted file mode 100644
index ccb809d198b..00000000000
--- a/client/go/util/http_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-// Basic testing of our HTTP client wrapper
-// Author: bratseth
-
-package util
-
-import (
- "bytes"
- "crypto/tls"
- "io/ioutil"
- "net/http"
- "testing"
- "time"
-
- "github.com/stretchr/testify/assert"
-)
-
-type mockHttpClient struct{}
-
-func (c mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) {
- var status int
- var body string
- if request.URL.String() == "http://host/okpath" {
- status = 200
- body = "OK body"
- } else {
- status = 500
- body = "Unexpected url body"
- }
-
- return &http.Response{
- StatusCode: status,
- Header: make(http.Header),
- Body: ioutil.NopCloser(bytes.NewBufferString(body)),
- },
- nil
-}
-
-func (c mockHttpClient) UseCertificate(certificates []tls.Certificate) {}
-
-func TestHttpRequest(t *testing.T) {
- ActiveHttpClient = mockHttpClient{}
-
- req, err := http.NewRequest("GET", "http://host/okpath", nil)
- assert.Nil(t, err)
- response, err := HttpDo(req, time.Second*10, "description")
- assert.Nil(t, err)
- assert.Equal(t, 200, response.StatusCode)
-
- req, err = http.NewRequest("GET", "http://host/otherpath", nil)
- assert.Nil(t, err)
- response, err = HttpDo(req, time.Second*10, "description")
- assert.Nil(t, err)
- assert.Equal(t, 500, response.StatusCode)
-}