Skip to content

Commit

Permalink
Add test for ETag header
Browse files Browse the repository at this point in the history
  • Loading branch information
SlIdE42 authored Dec 7, 2021
1 parent 614da84 commit 2b51fa0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hashfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func TestFileServer(t *testing.T) {
t.Fatalf("content-type=%v, want %v", got, want)
} else if got, want := hdr.Get("Content-Length"), `13`; got != want {
t.Fatalf("content-length=%v, want %v", got, want)
} else if got, want := hdr.Get("ETag"), ""; got != want {
t.Fatalf("etag=%v, want %v", got, want)
} else if got, want := w.Body.String(), `<html></html>`; got != want {
t.Fatalf("body=%q, want %q", got, want)
}
Expand All @@ -183,6 +185,8 @@ func TestFileServer(t *testing.T) {
h := hashfs.FileServer(fsys)
h.ServeHTTP(w, r)

hash := "\"b633a587c652d02386c4f16f8c6f6aab7352d97f16367c3c40576214372dd628\""

hdr := w.Result().Header
if got, want := w.Code, 200; got != want {
t.Fatalf("code=%v, want %v", got, want)
Expand All @@ -192,6 +196,8 @@ func TestFileServer(t *testing.T) {
t.Fatalf("content-type=%v, want %v", got, want)
} else if got, want := hdr.Get("Content-Length"), `13`; got != want {
t.Fatalf("content-length=%v, want %v", got, want)
} else if got, want := hdr.Get("ETag"), hash; got != want {
t.Fatalf("etag=%v, want %v", got, want)
} else if got, want := w.Body.String(), `<html></html>`; got != want {
t.Fatalf("body=%q, want %q", got, want)
}
Expand Down

0 comments on commit 2b51fa0

Please sign in to comment.