mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 22:06:57 +00:00
add testcase for new func
This commit is contained in:
parent
01272092eb
commit
1b53f50fda
1 changed files with 10 additions and 8 deletions
|
@ -23,7 +23,7 @@ func TestGetRedirect(t *testing.T) {
|
||||||
if !assert.EqualValues(t, http.StatusTemporaryRedirect, resp.StatusCode) {
|
if !assert.EqualValues(t, http.StatusTemporaryRedirect, resp.StatusCode) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.EqualValues(t, "https://www.cabr2.de/", resp.Header["Location"][0])
|
assert.EqualValues(t, "https://www.cabr2.de/", resp.Header.Get("Location"))
|
||||||
assert.EqualValues(t, 0, getSize(resp.Body))
|
assert.EqualValues(t, 0, getSize(resp.Body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,10 @@ func TestGetContent(t *testing.T) {
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.EqualValues(t, "image/jpeg", resp.Header["Content-Type"][0])
|
assert.EqualValues(t, "image/jpeg", resp.Header.Get("Content-Type"))
|
||||||
assert.EqualValues(t, "124635", resp.Header["Content-Length"][0])
|
assert.EqualValues(t, "124635", resp.Header.Get("Content-Length"))
|
||||||
assert.EqualValues(t, 124635, getSize(resp.Body))
|
assert.EqualValues(t, 124635, getSize(resp.Body))
|
||||||
|
assert.Len(t, resp.Header.Get("ETag"), 42)
|
||||||
|
|
||||||
// specify branch
|
// specify branch
|
||||||
resp, err = getTestHTTPSClient().Get("https://momar.localhost.mock.directory:4430/pag/@master/")
|
resp, err = getTestHTTPSClient().Get("https://momar.localhost.mock.directory:4430/pag/@master/")
|
||||||
|
@ -45,8 +46,9 @@ func TestGetContent(t *testing.T) {
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header["Content-Type"][0])
|
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||||
assert.True(t, getSize(resp.Body) > 1000)
|
assert.True(t, getSize(resp.Body) > 1000)
|
||||||
|
assert.Len(t, resp.Header.Get("ETag"), 42)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCustomDomain(t *testing.T) {
|
func TestCustomDomain(t *testing.T) {
|
||||||
|
@ -56,8 +58,8 @@ func TestCustomDomain(t *testing.T) {
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.EqualValues(t, "text/markdown; charset=utf-8", resp.Header["Content-Type"][0])
|
assert.EqualValues(t, "text/markdown; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||||
assert.EqualValues(t, "106", resp.Header["Content-Length"][0])
|
assert.EqualValues(t, "106", resp.Header.Get("Content-Length"))
|
||||||
assert.EqualValues(t, 106, getSize(resp.Body))
|
assert.EqualValues(t, 106, getSize(resp.Body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +71,8 @@ func TestGetNotFound(t *testing.T) {
|
||||||
if !assert.EqualValues(t, http.StatusNotFound, resp.StatusCode) {
|
if !assert.EqualValues(t, http.StatusNotFound, resp.StatusCode) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header["Content-Type"][0])
|
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||||
assert.EqualValues(t, "37", resp.Header["Content-Length"][0])
|
assert.EqualValues(t, "37", resp.Header.Get("Content-Length"))
|
||||||
assert.EqualValues(t, 37, getSize(resp.Body))
|
assert.EqualValues(t, 37, getSize(resp.Body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue