-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: replace unprintable and invalid characters in errors #23387
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,32 @@ import ( | |
"github.com/influxdata/influxdb/logger" | ||
"github.com/influxdata/influxdb/models" | ||
"github.com/influxdata/influxql" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestShard_ErrorPrinting(t *testing.T) { | ||
|
||
badStrings := []string{ | ||
string([]byte{'b', 'e', 'n', 't', 'e', 's', 't', '\t', '\n'}), | ||
string([]byte{'b', 'e', 'n', 't', 'e', 's', 0, 0, 0xFE, 0, 0xFE, 't'}), | ||
string([]byte{'b', 'e', 'n', 't', 'e', 's', 't', 0, 0, 0, 0, 0xFE, '\t', '\n', '\t', '\t', '\t'}), | ||
} | ||
|
||
for _, s := range badStrings { | ||
f := makePrintable(s) | ||
require.True(t, models.ValidKeyToken(f)) | ||
c := 0 | ||
for _, r := range f { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could just write the expected output for each input, instead of this loop - might be easier to do the new test requested above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote a sequence counter, but I can change it if you prefer. Take a look at your convenience, no rush. |
||
if r == unPrintReplRune { | ||
c++ | ||
require.LessOrEqual(t, c, unPrintMaxReplRune, "too many repeated %c", unPrintReplRune) | ||
} else { | ||
c = 0 | ||
} | ||
} | ||
} | ||
} | ||
|
||
func TestShard_MapType(t *testing.T) { | ||
var sh *TempShard | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c=0
to reset here, so each group is limited to 3 instead of 3 total?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have a test for that case too I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am clearly not awake today