Skip to content

Commit

Permalink
test: add test for searching memos by tags (usememos#3876)
Browse files Browse the repository at this point in the history
  • Loading branch information
onee-only authored Sep 4, 2024
1 parent 95939eb commit b664653
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/store/memo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/stretchr/testify/require"

"github.com/usememos/memos/store"

storepb "github.com/usememos/memos/proto/gen/store"
)

func TestMemoStore(t *testing.T) {
Expand Down Expand Up @@ -62,6 +64,42 @@ func TestMemoStore(t *testing.T) {
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) {
ctx := context.Background()
ts := NewTestingStore(ctx, t)
Expand Down

0 comments on commit b664653

Please sign in to comment.