package web import ( "net/http/httptest" "os" "path/filepath" "strings" "testing" ) func TestStaticPagesAndAssets(t *testing.T) { root := t.TempDir() os.Mkdir(filepath.Join(root, "site"), 0700) files := map[string]string{"site/index.html": "

Home

", "page.HTML": "

Direct

", "site/app.js": "console.log('ok')", "site/style.css": "h1{color:red}", "archive.zip": "archive", "script.php": "Home", 200, false}, {"/site/index.html", "text/html; charset=utf-8", "

Home

", 200, false}, {"/page.HTML", "text/html; charset=utf-8", "

Direct

", 200, false}, {"/site/app.js", "text/javascript; charset=utf-8", "console.log('ok')", 200, false}, {"/site/style.css", "text/css; charset=utf-8", "h1{color:red}", 200, false}, {"/archive.zip", "application/octet-stream", "archive", 200, true}, {"/script.php", "application/octet-stream", "Root index"), 0600) w = httptest.NewRecorder() h.ServeHTTP(w, httptest.NewRequest("GET", "/", nil)) if w.Body.String() != "

Root index

" { t.Fatal("root index not served") } }