diff --git a/src/gossa_test.go b/src/gossa_test.go index c82c7fd..39ca7f1 100644 --- a/src/gossa_test.go +++ b/src/gossa_test.go @@ -53,6 +53,8 @@ func postJSON(t *testing.T, url string, what string) string { return trimSpaces(string(body)) } +var mainPage = `

./

compress/
curimit@gmail.com (40%)/
gzip/
hols/
show-dir$$href_encoding$$/
subdir/
subdir_with space/
中文/
13.0B
404.html
40.0B
404.html.gz
5.0B
b.txt
211.0B
custom_mime_type.types
` + func testDefaults(t *testing.T, url string) string { bodyStr := get(t, url) @@ -86,10 +88,15 @@ func testDefaults(t *testing.T, url string) string { func TestGetFolder(t *testing.T) { payload := "" path := "" + bodyStr := "" // ~~~~~~~~~~~~~~~~~ fmt.Println("\r\n~~~~~~~~~~ test fetching default path") testDefaults(t, "http://127.0.0.1:8001/") + bodyStr = get(t, "http://127.0.0.1:8001/") + if !strings.Contains(bodyStr, mainPage) { + t.Fatal("fetching default path errored") + } // ~~~~~~~~~~~~~~~~~ fmt.Println("\r\n~~~~~~~~~~ test fetching an invalid path - redirected to root") @@ -98,7 +105,7 @@ func TestGetFolder(t *testing.T) { // ~~~~~~~~~~~~~~~~~ fmt.Println("\r\n~~~~~~~~~~ test fetching a regular file") - bodyStr := get(t, "http://127.0.0.1:8001/subdir_with%20space/file_with%20space.html") + bodyStr = get(t, "http://127.0.0.1:8001/subdir_with%20space/file_with%20space.html") if !strings.Contains(bodyStr, `spacious!!`) { t.Fatal("fetching a regular file errored") }