2017-04-21 02:01:08 -05:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2017-09-16 12:17:57 -05:00
|
|
|
package markup_test
|
2017-04-21 02:01:08 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-09-16 12:17:57 -05:00
|
|
|
. "code.gitea.io/gitea/modules/markup"
|
2017-09-21 00:20:14 -05:00
|
|
|
_ "code.gitea.io/gitea/modules/markup/markdown"
|
2017-09-16 12:17:57 -05:00
|
|
|
|
2017-04-21 02:01:08 -05:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMisc_IsReadmeFile(t *testing.T) {
|
|
|
|
trueTestCases := []string{
|
|
|
|
"readme",
|
|
|
|
"README",
|
|
|
|
"readME.mdown",
|
|
|
|
"README.md",
|
2019-01-14 13:15:06 -06:00
|
|
|
"readme.i18n.md",
|
2017-04-21 02:01:08 -05:00
|
|
|
}
|
|
|
|
falseTestCases := []string{
|
|
|
|
"test.md",
|
|
|
|
"wow.MARKDOWN",
|
|
|
|
"LOL.mDoWn",
|
|
|
|
"test",
|
|
|
|
"abcdefg",
|
|
|
|
"abcdefghijklmnopqrstuvwxyz",
|
|
|
|
"test.md.test",
|
2017-05-09 09:20:22 -05:00
|
|
|
"readmf",
|
2017-04-21 02:01:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, testCase := range trueTestCases {
|
|
|
|
assert.True(t, IsReadmeFile(testCase))
|
|
|
|
}
|
|
|
|
for _, testCase := range falseTestCases {
|
|
|
|
assert.False(t, IsReadmeFile(testCase))
|
|
|
|
}
|
2019-01-14 13:15:06 -06:00
|
|
|
|
|
|
|
trueTestCasesStrict := [][]string{
|
|
|
|
{"readme", ""},
|
|
|
|
{"readme.md", ".md"},
|
|
|
|
{"readme.txt", ".txt"},
|
|
|
|
}
|
|
|
|
falseTestCasesStrict := [][]string{
|
|
|
|
{"readme", ".md"},
|
|
|
|
{"readme.md", ""},
|
|
|
|
{"readme.md", ".txt"},
|
|
|
|
{"readme.md", "md"},
|
|
|
|
{"readmee.md", ".md"},
|
|
|
|
{"readme.i18n.md", ".md"},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, testCase := range trueTestCasesStrict {
|
|
|
|
assert.True(t, IsReadmeFile(testCase[0], testCase[1]))
|
|
|
|
}
|
|
|
|
for _, testCase := range falseTestCasesStrict {
|
|
|
|
assert.False(t, IsReadmeFile(testCase[0], testCase[1]))
|
|
|
|
}
|
2017-04-21 02:01:08 -05:00
|
|
|
}
|