Files
opencloud/services/search/pkg/content/content_test.go
T
2435420f69 [full-ci] chore: bump reva to 2.52.2 (#3955)
* chore: bump reva to 2.52.2

* Merge pull request #42 from opencloud-eu/fix-web-theme-merge

fix(web): merge copies of the theme sources so themeDefaults is never mutated

* Merge pull request #43 from opencloud-eu/fix-search-trailing-not

fix(search): handle missing operands in the bleve compiler

* Merge pull request #44 from opencloud-eu/fix-search-highlight-escaping

fix(search): escape file content in OpenSearch highlights

---------

Co-authored-by: Ralf Haferkamp <r.haferkamp@opencloud.eu>
Co-authored-by: Florian Schade <f.schade@icloud.com>
2026-11-11 14:14:34 +01:00

44 lines
1.0 KiB
Go

package content_test
import (
"testing"
. "github.com/stretchr/testify/assert"
"github.com/opencloud-eu/opencloud/services/search/pkg/content"
)
func TestCleanContent(t *testing.T) {
tests := []struct {
given string
expect string
}{
{
given: "find can keeper should keeper will",
expect: "keeper keeper",
},
{
given: "user1 shares the file to Mary",
expect: "user1 shares file mary",
},
{
given: "content contains https://localhost/remote.php/dav/files/admin/Photos/San%20Francisco.jpg and stop word",
expect: "content contains https://localhost/remote.php/dav/files/admin/photos/san%20francisco.jpg stop word",
},
{
given: "needle &lt;img src=x&gt; needle",
expect: "needle &lt;img src=x&gt; needle",
},
{
given: "List<String> names from Alice <alice@example.com>",
expect: "list<string> names alice <alice@example.com>",
},
}
for _, tc := range tests {
t.Run(tc.given, func(t *testing.T) {
Equal(t, tc.expect, content.CleanString(tc.given, "en"))
})
}
}