diff options
author | Florian Engelhardt <flo@dotbox.org> | 2020-09-17 11:50:18 +0300 |
---|---|---|
committer | Florian Engelhardt <flo@dotbox.org> | 2020-10-20 14:10:46 +0300 |
commit | 97e087b3fad6b8378a24adef1eb356bb22af23dc (patch) | |
tree | ac0c80ca8c80960a6c865366d43adb5c30c6c741 | |
parent | 7b2e94899452931247e3c8d7c9e336efc2b8182c (diff) |
PATCH-44819 #460 cleanup DRY in mime type test
-rw-r--r-- | acceptance_test.go | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 32567425..6f4b2d12 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -650,23 +650,32 @@ func TestMIMETypes(t *testing.T) { require.NoError(t, httpListener.WaitUntilRequestSucceeds(nil)) - rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/file.webmanifest") - require.NoError(t, err) - defer rsp.Body.Close() - - require.Equal(t, http.StatusOK, rsp.StatusCode) - mt, _, err := mime.ParseMediaType(rsp.Header.Get("Content-Type")) - require.NoError(t, err) - require.Equal(t, "application/manifest+json", mt) + tests := map[string]struct { + file string + expectedContentType string + }{ + "manifest_json": { + file: "file.webmanifest", + expectedContentType: "application/manifest+json", + }, + "avif": { + file: "image.avif", + expectedContentType: "image/avif", + }, + } - rsp, err = GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/image.avif") - require.NoError(t, err) - defer rsp.Body.Close() + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "project/"+tt.file) + require.NoError(t, err) + defer rsp.Body.Close() - require.Equal(t, http.StatusOK, rsp.StatusCode) - mt, _, err = mime.ParseMediaType(rsp.Header.Get("Content-Type")) - require.NoError(t, err) - require.Equal(t, "image/avif", mt) + require.Equal(t, http.StatusOK, rsp.StatusCode) + mt, _, err := mime.ParseMediaType(rsp.Header.Get("Content-Type")) + require.NoError(t, err) + require.Equal(t, tt.expectedContentType, mt) + }) + } } func TestCompressedEncoding(t *testing.T) { |