mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-18 18:39:42 +00:00
test dont panic
This commit is contained in:
parent
63d0b8d320
commit
7f2854d537
1 changed files with 10 additions and 5 deletions
|
@ -44,9 +44,10 @@ func TestGetContent(t *testing.T) {
|
||||||
// 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/")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.NotNil(t, resp) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.StatusCode)
|
||||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
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)
|
assert.Len(t, resp.Header.Get("ETag"), 42)
|
||||||
|
@ -68,9 +69,10 @@ func TestCustomDomain(t *testing.T) {
|
||||||
log.Println("=== TestCustomDomain ===")
|
log.Println("=== TestCustomDomain ===")
|
||||||
resp, err := getTestHTTPSClient().Get("https://mock-pages.codeberg-test.org:4430/README.md")
|
resp, err := getTestHTTPSClient().Get("https://mock-pages.codeberg-test.org:4430/README.md")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.NotNil(t, resp) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.StatusCode)
|
||||||
assert.EqualValues(t, "text/markdown; charset=utf-8", resp.Header.Get("Content-Type"))
|
assert.EqualValues(t, "text/markdown; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||||
assert.EqualValues(t, "106", resp.Header.Get("Content-Length"))
|
assert.EqualValues(t, "106", resp.Header.Get("Content-Length"))
|
||||||
assert.EqualValues(t, 106, getSize(resp.Body))
|
assert.EqualValues(t, 106, getSize(resp.Body))
|
||||||
|
@ -81,9 +83,10 @@ func TestGetNotFound(t *testing.T) {
|
||||||
// test custom not found pages
|
// test custom not found pages
|
||||||
resp, err := getTestHTTPSClient().Get("https://crystal.localhost.mock.directory:4430/pages-404-demo/blah")
|
resp, err := getTestHTTPSClient().Get("https://crystal.localhost.mock.directory:4430/pages-404-demo/blah")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
if !assert.EqualValues(t, http.StatusNotFound, resp.StatusCode) {
|
if !assert.NotNil(t, resp) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
assert.EqualValues(t, http.StatusNotFound, resp.StatusCode)
|
||||||
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header.Get("Content-Type"))
|
||||||
assert.EqualValues(t, "37", resp.Header.Get("Content-Length"))
|
assert.EqualValues(t, "37", resp.Header.Get("Content-Length"))
|
||||||
assert.EqualValues(t, 37, getSize(resp.Body))
|
assert.EqualValues(t, 37, getSize(resp.Body))
|
||||||
|
@ -94,9 +97,10 @@ func TestFollowSymlink(t *testing.T) {
|
||||||
|
|
||||||
resp, err := getTestHTTPSClient().Get("https://6543.localhost.mock.directory:4430/tests_for_pages-server/@main/link")
|
resp, err := getTestHTTPSClient().Get("https://6543.localhost.mock.directory:4430/tests_for_pages-server/@main/link")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.NotNil(t, resp) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.StatusCode)
|
||||||
assert.EqualValues(t, "application/octet-stream", resp.Header.Get("Content-Type"))
|
assert.EqualValues(t, "application/octet-stream", resp.Header.Get("Content-Type"))
|
||||||
assert.EqualValues(t, "4", resp.Header.Get("Content-Length"))
|
assert.EqualValues(t, "4", resp.Header.Get("Content-Length"))
|
||||||
body := getBytes(resp.Body)
|
body := getBytes(resp.Body)
|
||||||
|
@ -109,9 +113,10 @@ func TestLFSSupport(t *testing.T) {
|
||||||
|
|
||||||
resp, err := getTestHTTPSClient().Get("https://6543.localhost.mock.directory:4430/tests_for_pages-server/@main/lfs.txt")
|
resp, err := getTestHTTPSClient().Get("https://6543.localhost.mock.directory:4430/tests_for_pages-server/@main/lfs.txt")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
if !assert.EqualValues(t, http.StatusOK, resp.StatusCode) {
|
if !assert.NotNil(t, resp) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
assert.EqualValues(t, http.StatusOK, resp.StatusCode)
|
||||||
body := strings.TrimSpace(string(getBytes(resp.Body)))
|
body := strings.TrimSpace(string(getBytes(resp.Body)))
|
||||||
assert.EqualValues(t, 12, len(body))
|
assert.EqualValues(t, 12, len(body))
|
||||||
assert.EqualValues(t, "actual value", body)
|
assert.EqualValues(t, "actual value", body)
|
||||||
|
|
Loading…
Reference in a new issue