Skip to content

Commit

Permalink
fix tests with favicon ETAG
Browse files Browse the repository at this point in the history
  • Loading branch information
whyvrafvr committed Sep 23, 2023
1 parent c4eeafb commit 2b73112
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ clean:
rm -rf ./bin
test:
go clean -testcache
go test -v ./...
go test ./...
11 changes: 6 additions & 5 deletions api/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func TestHealth(t *testing.T) {
}

func TestGetFavicon(t *testing.T) {
etg := "042fcec4629b02c73aa21a3d26ca8965"
r := setupRouter()

w := httptest.NewRecorder()
Expand Down Expand Up @@ -212,8 +213,8 @@ func TestGetFavicon(t *testing.T) {
t.Errorf("incorrect Cache-Control, got %q, want%q\n", headers.Get("Cache-Control"), "public, max-age=31536000")
t.FailNow()
}
if headers.Get("ETag") != "d6ab255e0eb3f7ce86dcb0ba12992a67" {
t.Errorf("incorrect ETag, got %q, want %q\n", headers.Get("ETag"), "d6ab255e0eb3f7ce86dcb0ba12992a67")
if headers.Get("ETag") != etg {
t.Errorf("incorrect ETag, got %q, want %q\n", headers.Get("ETag"), etg)
t.FailNow()
}

Expand All @@ -232,14 +233,14 @@ func TestGetFavicon(t *testing.T) {
t.Errorf("incorrect Cache-Control, got %q, want %q\n", headers.Get("Cache-Control"), "public, max-age=31536000")
t.FailNow()
}
if headers.Get("ETag") != "d6ab255e0eb3f7ce86dcb0ba12992a67" {
t.Errorf("incorrect ETag, got %q, want %q\n", headers.Get("ETag"), "d6ab255e0eb3f7ce86dcb0ba12992a67")
if headers.Get("ETag") != etg {
t.Errorf("incorrect ETag, got %q, want %q\n", headers.Get("ETag"), etg)
t.FailNow()
}

w = httptest.NewRecorder()
req, _ = http.NewRequest("GET", "/favicon.ico", nil)
req.Header.Add("If-None-Match", "d6ab255e0eb3f7ce86dcb0ba12992a67")
req.Header.Add("If-None-Match", etg)
r.ServeHTTP(w, req)

if w.Code != http.StatusNotModified {
Expand Down

0 comments on commit 2b73112

Please sign in to comment.