9a5720e8ad
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
PR RC Release / Build RC Release (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Full namespace migration: update the Go module path and all import statements from git.mokoconsulting.tech to code.mokoconsulting.tech. Also updates all URL references in templates, workflows, configs, tests, and documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59 lines
1.1 KiB
Go
59 lines
1.1 KiB
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package bleve
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/setting"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestBleveGuessFuzzinessByKeyword(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.Indexer.TypeBleveMaxFuzzniess, 2)()
|
|
|
|
scenarios := []struct {
|
|
Input string
|
|
Fuzziness int // See util.go for the definition of fuzziness in this particular context
|
|
}{
|
|
{
|
|
Input: "",
|
|
Fuzziness: 0,
|
|
},
|
|
{
|
|
Input: "Avocado",
|
|
Fuzziness: 1,
|
|
},
|
|
{
|
|
Input: "Geschwindigkeit",
|
|
Fuzziness: 2,
|
|
},
|
|
{
|
|
Input: "non-exist",
|
|
Fuzziness: 0,
|
|
},
|
|
{
|
|
Input: "갃갃갃",
|
|
Fuzziness: 0,
|
|
},
|
|
{
|
|
Input: "repo1",
|
|
Fuzziness: 0,
|
|
},
|
|
{
|
|
Input: "avocado.md",
|
|
Fuzziness: 0,
|
|
},
|
|
}
|
|
|
|
for _, scenario := range scenarios {
|
|
t.Run(fmt.Sprintf("Fuziniess:%s=%d", scenario.Input, scenario.Fuzziness), func(t *testing.T) {
|
|
assert.Equal(t, scenario.Fuzziness, GuessFuzzinessByKeyword(scenario.Input))
|
|
})
|
|
}
|
|
}
|