mirror of
https://github.com/h2non/imaginary.git
synced 2025-12-13 20:37:04 +01:00
More literal to constant replacements
This commit is contained in:
@@ -32,7 +32,7 @@ func TestLog(t *testing.T) {
|
||||
}
|
||||
|
||||
data := string(buf)
|
||||
if strings.Contains(data, "GET") == false ||
|
||||
if strings.Contains(data, http.MethodGet) == false ||
|
||||
strings.Contains(data, "HTTP/1.1") == false ||
|
||||
strings.Contains(data, " 200 ") == false {
|
||||
t.Fatalf("Invalid log output: %s", data)
|
||||
|
||||
@@ -191,7 +191,7 @@ func TestTypeAuto(t *testing.T) {
|
||||
url := ts.URL + "?width=300&type=auto"
|
||||
defer ts.Close()
|
||||
|
||||
req, _ := http.NewRequest("POST", url, buf)
|
||||
req, _ := http.NewRequest(http.MethodPost, url, buf)
|
||||
req.Header.Add("Content-Type", "image/jpeg")
|
||||
req.Header.Add("Accept", test.acceptHeader)
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
|
||||
@@ -13,7 +13,7 @@ const fixtureFile = "testdata/large.jpg"
|
||||
|
||||
func TestSourceBodyMatch(t *testing.T) {
|
||||
u, _ := url.Parse("http://foo")
|
||||
req := &http.Request{Method: "POST", URL: u}
|
||||
req := &http.Request{Method: http.MethodPost, URL: u}
|
||||
source := NewBodyImageSource(&SourceConfig{})
|
||||
|
||||
if !source.Matches(req) {
|
||||
@@ -39,7 +39,7 @@ func TestBodyImageSource(t *testing.T) {
|
||||
}
|
||||
|
||||
file, _ := os.Open(fixtureFile)
|
||||
r, _ := http.NewRequest("POST", "http://foo/bar", file)
|
||||
r, _ := http.NewRequest(http.MethodPost, "http://foo/bar", file)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
|
||||
@@ -67,7 +67,7 @@ func testReadBody(t *testing.T) {
|
||||
}
|
||||
|
||||
file, _ := os.Open(fixtureFile)
|
||||
r, _ := http.NewRequest("POST", "http://foo/bar", file)
|
||||
r, _ := http.NewRequest(http.MethodPost, "http://foo/bar", file)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestFileSystemImageSource(t *testing.T) {
|
||||
}
|
||||
|
||||
file, _ := os.Open(fixtureFile)
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?file=large.jpg", file)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?file=large.jpg", file)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestHttpImageSource(t *testing.T) {
|
||||
w.Write(body)
|
||||
}
|
||||
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?url="+ts.URL, nil)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?url="+ts.URL, nil)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestHttpImageSourceAllowedOrigin(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?url="+ts.URL, nil)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?url="+ts.URL, nil)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func TestHttpImageSourceNotAllowedOrigin(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?url=http://bar.com", nil)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?url=http://bar.com", nil)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func TestHttpImageSourceForwardAuthHeader(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, header := range cases {
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?url=http://bar.com", nil)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?url=http://bar.com", nil)
|
||||
r.Header.Set(header, "foobar")
|
||||
|
||||
source := &HTTPImageSource{&SourceConfig{AuthForwarding: true}}
|
||||
@@ -145,7 +145,7 @@ func TestHttpImageSourceError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?url="+ts.URL, nil)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?url="+ts.URL, nil)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func TestHttpImageSourceExceedsMaximumAllowedLength(t *testing.T) {
|
||||
w.Write(body)
|
||||
}
|
||||
|
||||
r, _ := http.NewRequest("GET", "http://foo/bar?url="+ts.URL, nil)
|
||||
r, _ := http.NewRequest(http.MethodGet, "http://foo/bar?url="+ts.URL, nil)
|
||||
w := httptest.NewRecorder()
|
||||
fakeHandler(w, r)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestMatchSource(t *testing.T) {
|
||||
u, _ := url.Parse("http://foo?url=http://bar/image.jpg")
|
||||
req := &http.Request{Method: "GET", URL: u}
|
||||
req := &http.Request{Method: http.MethodGet, URL: u}
|
||||
|
||||
source := MatchSource(req)
|
||||
if source == nil {
|
||||
|
||||
Reference in New Issue
Block a user