mirror of
https://github.com/usememos/memos.git
synced 2024-12-19 09:02:49 +03:00
b44f2b5ffb
* chore: migrate to api v1 package * chore: update
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package teststore
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/usememos/memos/store"
|
|
)
|
|
|
|
func TestMemoStore(t *testing.T) {
|
|
ctx := context.Background()
|
|
ts := NewTestingStore(ctx, t)
|
|
user, err := createTestingHostUser(ctx, ts)
|
|
require.NoError(t, err)
|
|
memoCreate := &store.MemoMessage{
|
|
CreatorID: user.ID,
|
|
Content: "test_content",
|
|
Visibility: store.Public,
|
|
}
|
|
memo, err := ts.CreateMemo(ctx, memoCreate)
|
|
require.NoError(t, err)
|
|
require.Equal(t, memoCreate.Content, memo.Content)
|
|
memoPatchContent := "test_content_2"
|
|
memoPatch := &store.UpdateMemoMessage{
|
|
ID: memo.ID,
|
|
Content: &memoPatchContent,
|
|
}
|
|
err = ts.UpdateMemo(ctx, memoPatch)
|
|
require.NoError(t, err)
|
|
memo, err = ts.GetMemo(ctx, &store.FindMemoMessage{
|
|
ID: &memo.ID,
|
|
})
|
|
require.NoError(t, err)
|
|
memoList, err := ts.ListMemos(ctx, &store.FindMemoMessage{
|
|
CreatorID: &user.ID,
|
|
})
|
|
require.NoError(t, err)
|
|
require.Equal(t, 1, len(memoList))
|
|
require.Equal(t, memo, memoList[0])
|
|
err = ts.DeleteMemo(ctx, &store.DeleteMemoMessage{
|
|
ID: memo.ID,
|
|
})
|
|
require.NoError(t, err)
|
|
}
|