Change order of "yoda conditions" (1 != foo) (#4756)

staticcheck cleanup: https://staticcheck.io/docs/checks#ST1017
This commit is contained in:
Jacob Hoffman-Andrews 2020-04-08 17:19:56 -07:00 committed by GitHub
parent cdb0bddbd8
commit 8d99ada705
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ func TestLogCode(t *testing.T) {
}
th.ServeHTTP(httptest.NewRecorder(), req)
expected := `INFO: GET /endpoint 0 201 0 0.0.0.0 JSON={}`
if 1 != len(mockLog.GetAllMatching(expected)) {
if len(mockLog.GetAllMatching(expected)) != 1 {
t.Errorf("Expected exactly one log line matching %q. Got \n%s",
expected, strings.Join(mockLog.GetAllMatching(".*"), "\n"))
}
@ -53,7 +53,7 @@ func TestStatusCodeLogging(t *testing.T) {
}
th.ServeHTTP(httptest.NewRecorder(), req)
expected := `INFO: GET /endpoint 0 200 0 0.0.0.0 JSON={}`
if 1 != len(mockLog.GetAllMatching(expected)) {
if len(mockLog.GetAllMatching(expected)) != 1 {
t.Errorf("Expected exactly one log line matching %q. Got \n%s",
expected, strings.Join(mockLog.GetAllMatching(".*"), "\n"))
}
@ -69,7 +69,7 @@ func TestOrigin(t *testing.T) {
req.Header.Add("Origin", "https://example.com")
th.ServeHTTP(httptest.NewRecorder(), req)
expected := `INFO: GET /endpoint 0 201 0 0.0.0.0 JSON={.*"Origin":"https://example.com"}`
if 1 != len(mockLog.GetAllMatching(expected)) {
if len(mockLog.GetAllMatching(expected)) != 1 {
t.Errorf("Expected exactly one log line matching %q. Got \n%s",
expected, strings.Join(mockLog.GetAllMatching(".*"), "\n"))
}