mirror of
https://github.com/go-gitea/gitea
synced 2025-07-15 23:17:19 +00:00
Custom regexp external issues (#17624)
* Implement custom regular expression for external issue tracking. Signed-off-by: Alexander Beyn <malex@fatelectrons.org> * Fix syntax/style * Update repo.go * Set metas['regexp'] * gofmt * fix some tests * fix more tests * refactor frontend * use LRU cache for regexp * Update modules/markup/html_internal_test.go Co-authored-by: Alexander Beyn <malex@fatelectrons.org> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
27
modules/regexplru/regexplru_test.go
Normal file
27
modules/regexplru/regexplru_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
package regexplru
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRegexpLru(t *testing.T) {
|
||||
r, err := GetCompiled("a")
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, r.MatchString("a"))
|
||||
|
||||
r, err = GetCompiled("a")
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, r.MatchString("a"))
|
||||
|
||||
assert.EqualValues(t, 1, lruCache.Len())
|
||||
|
||||
_, err = GetCompiled("(")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, 2, lruCache.Len())
|
||||
}
|
Reference in New Issue
Block a user