-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional content types. Add extra tests.
- Loading branch information
1 parent
d32fbf0
commit 0cfd13d
Showing
2 changed files
with
172 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package server | ||
|
||
import "testing" | ||
|
||
func Test_getContentTypeForExtension(t *testing.T) { | ||
tests := []struct { | ||
extension string | ||
want string | ||
}{ | ||
{ | ||
extension: ".css", | ||
want: "text/css", | ||
}, | ||
{ | ||
extension: ".html", | ||
want: "text/html", | ||
}, | ||
{ | ||
extension: ".js", | ||
want: "text/javascript", | ||
}, | ||
{ | ||
extension: ".json", | ||
want: "application/json", | ||
}, | ||
{ | ||
extension: ".jpg", | ||
want: "image/jpeg", | ||
}, | ||
{ | ||
extension: ".jpeg", | ||
want: "image/jpeg", | ||
}, | ||
{ | ||
extension: ".png", | ||
want: "image/png", | ||
}, | ||
{ | ||
extension: ".svg", | ||
want: "image/svg+xml", | ||
}, | ||
{ | ||
extension: ".gif", | ||
want: "image/gif", | ||
}, | ||
{ | ||
extension: ".webp", | ||
want: "image/webp", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.extension, func(t *testing.T) { | ||
if got := getContentTypeForExtension(tt.extension); got != tt.want { | ||
t.Errorf("getContentTypeForExtension() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |