You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/05/18 15:44:25 UTC

[GitHub] [trafficcontrol] rob05c commented on a diff in pull request #5696: Change lib/go-log to escape newlines

rob05c commented on code in PR #5696:
URL: https://github.com/apache/trafficcontrol/pull/5696#discussion_r876060447


##########
lib/go-log/log_test.go:
##########
@@ -42,3 +42,15 @@ func TestUTC(t *testing.T) {
 		t.Errorf("expected UTC time, actual '" + actual + "'")
 	}
 }
+
+func TestNewlinesSingleLogLine(t *testing.T) {
+	buf := &bytes.Buffer{}
+	Init(nil, writeCloser{buf}, nil, nil, nil)
+	// Have to concatenate, because Go doesn't allow you to test multiple trailing newline behavior.
+	Errorln("foo\n\nbar\n" + "\n" + "\n")

Review Comment:
   It won't build, `go test` implicitly runs `go vet` and fails if it fails.
   Changing that to
   ```
   Errorln("foo\n\nbar\n\n\n")
   ```
   Produces
   ```
   $ go test -v -failfast
   # github.com/apache/trafficcontrol/lib/go-log
   ./log_test.go:50:2: Errorln arg list ends with redundant newline
   FAIL    github.com/apache/trafficcontrol/lib/go-log [build failed]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org