mirror of https://github.com/usememos/memos
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
868 B
Go
40 lines
868 B
Go
2 years ago
|
package server
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestFindTagListFromMemoContent(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
memoContent string
|
||
|
want []string
|
||
|
}{
|
||
|
{
|
||
|
memoContent: "#tag1 ",
|
||
|
want: []string{"tag1"},
|
||
|
},
|
||
|
{
|
||
|
memoContent: "#tag1 #tag2 ",
|
||
|
want: []string{"tag1", "tag2"},
|
||
|
},
|
||
|
{
|
||
|
memoContent: "#tag1 #tag2 \n#tag3 ",
|
||
|
want: []string{"tag1", "tag2", "tag3"},
|
||
|
},
|
||
|
{
|
||
|
memoContent: "#tag1 #tag2 \n#tag3 #tag4 ",
|
||
|
want: []string{"tag1", "tag2", "tag3", "tag4"},
|
||
|
},
|
||
|
{
|
||
|
memoContent: "#tag1 #tag2 \n#tag3 #tag4 ",
|
||
|
want: []string{"tag1", "tag2", "tag3", "tag4"},
|
||
|
},
|
||
|
}
|
||
|
for _, test := range tests {
|
||
|
result := findTagListFromMemoContent(test.memoContent)
|
||
|
if len(result) != len(test.want) {
|
||
|
t.Errorf("Find tag list %s: got result %v, want %v.", test.memoContent, result, test.want)
|
||
|
}
|
||
|
}
|
||
|
}
|