diff options
author | Ethan Koenig <etk39@cornell.edu> | 2016-12-23 01:31:22 -0500 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-23 14:31:22 +0800 |
commit | ec1fe1183d78b64d6687226fa59c7107f7a07940 (patch) | |
tree | 985cf455eff07a84bbba265967e33dbe6a24a43e /modules/base/tool_test.go | |
parent | dfb547099d5f8e1446742bd48809d5c143968164 (diff) | |
download | gitea-ec1fe1183d78b64d6687226fa59c7107f7a07940.tar.gz gitea-ec1fe1183d78b64d6687226fa59c7107f7a07940.zip |
Fix race condition in unit test (#456)
Diffstat (limited to 'modules/base/tool_test.go')
-rw-r--r-- | modules/base/tool_test.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go index bda2e65a19..739e03266e 100644 --- a/modules/base/tool_test.go +++ b/modules/base/tool_test.go @@ -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) } |