package main import ( "net/http" "net/http/httptest" "net/url" "testing" "gogs.inhome.blapointe.com/local/gziphttp" ) func TestSetContentType(t *testing.T) { t.Parallel() cases := map[string]struct { path string want string }{ "css with multi .": { path: "/static/css/main.2145ce41.chunk.css", want: "text/css", }, } for name, d := range cases { c := d t.Run(name, func(t *testing.T) { r := &http.Request{URL: &url.URL{Path: c.path}} w := httptest.NewRecorder() gziphttp.SetContentTypeIfMedia(w, r) if ct := w.Header().Get("Content-Type"); ct != c.want { t.Errorf("wrong content type: want %q, got %q", c.want, ct) } }) } }