fix: check for empty header in assertHeader()
This commit is contained in:
@@ -379,7 +379,11 @@ func assertCookieCleared(t *testing.T, rec *httptest.ResponseRecorder, name stri
|
|||||||
func assertHeader(t *testing.T, rec *httptest.ResponseRecorder, name, expectedValue string) {
|
func assertHeader(t *testing.T, rec *httptest.ResponseRecorder, name, expectedValue string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
actualValue := rec.Header().Get(name)
|
actualValue := rec.Header().Get(name)
|
||||||
if actualValue != expectedValue {
|
if expectedValue == "" {
|
||||||
|
if actualValue == "" {
|
||||||
|
t.Errorf("Expected header %s to be present", name)
|
||||||
|
}
|
||||||
|
} else if actualValue != expectedValue {
|
||||||
t.Errorf("Expected header %s=%s, got %s", name, expectedValue, actualValue)
|
t.Errorf("Expected header %s=%s, got %s", name, expectedValue, actualValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user