mirror of
https://github.com/usememos/memos.git
synced 2025-02-21 05:40:57 +01:00
test: add test for searching memos by tags (#3876)
This commit is contained in:
parent
95939ebcf1
commit
b664653306
@ -7,6 +7,8 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/usememos/memos/store"
|
"github.com/usememos/memos/store"
|
||||||
|
|
||||||
|
storepb "github.com/usememos/memos/proto/gen/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMemoStore(t *testing.T) {
|
func TestMemoStore(t *testing.T) {
|
||||||
@ -62,6 +64,42 @@ func TestMemoStore(t *testing.T) {
|
|||||||
ts.Close()
|
ts.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMemoListByTags(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
ts := NewTestingStore(ctx, t)
|
||||||
|
user, err := createTestingHostUser(ctx, ts)
|
||||||
|
require.NoError(t, err)
|
||||||
|
memoCreate := &store.Memo{
|
||||||
|
UID: "test-resource-name",
|
||||||
|
CreatorID: user.ID,
|
||||||
|
Content: "test_content",
|
||||||
|
Visibility: store.Public,
|
||||||
|
Payload: &storepb.MemoPayload{
|
||||||
|
Property: &storepb.MemoPayload_Property{
|
||||||
|
Tags: []string{"test_tag"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
memo, err := ts.CreateMemo(ctx, memoCreate)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, memoCreate.Content, memo.Content)
|
||||||
|
memo, err = ts.GetMemo(ctx, &store.FindMemo{
|
||||||
|
ID: &memo.ID,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, memo)
|
||||||
|
|
||||||
|
memoList, err := ts.ListMemos(ctx, &store.FindMemo{
|
||||||
|
PayloadFind: &store.FindMemoPayload{
|
||||||
|
TagSearch: []string{"test_tag"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, len(memoList))
|
||||||
|
require.Equal(t, memo, memoList[0])
|
||||||
|
ts.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func TestDeleteMemoStore(t *testing.T) {
|
func TestDeleteMemoStore(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ts := NewTestingStore(ctx, t)
|
ts := NewTestingStore(ctx, t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user