Skip to content
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 race condition in unit test #456

Merged
merged 1 commit into from
Dec 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions modules/base/tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ func TestDetectEncoding(t *testing.T) {

// iso-8859-1: d<accented e>cor<newline>
b = []byte{0x44, 0xe9, 0x63, 0x6f, 0x72, 0x0a}
testSuccess(b, "ISO-8859-1")
encoding, err := DetectEncoding(b)
assert.NoError(t, err)
// due to a race condition in `chardet` library, it could either detect
// "ISO-8859-1" or "IS0-8859-2" here. Technically either is correct, so
// we accept either.
assert.Contains(t, encoding, "ISO-8859")

setting.Repository.AnsiCharset = "placeholder"
testSuccess(b, "placeholder")

// invalid bytes
b = []byte{0xfa}
_, err := DetectEncoding(b)
_, err = DetectEncoding(b)
assert.Error(t, err)
}

Expand Down