init commit
This commit is contained in:
48
store/test/reaction_test.go
Normal file
48
store/test/reaction_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package teststore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func TestReactionStore(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
|
||||
user, err := createTestingHostUser(ctx, ts)
|
||||
require.NoError(t, err)
|
||||
|
||||
contentID := "test_content_id"
|
||||
reaction, err := ts.UpsertReaction(ctx, &store.Reaction{
|
||||
CreatorID: user.ID,
|
||||
ContentID: contentID,
|
||||
ReactionType: "💗",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, reaction)
|
||||
require.NotEmpty(t, reaction.ID)
|
||||
|
||||
reactions, err := ts.ListReactions(ctx, &store.FindReaction{
|
||||
ContentID: &contentID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, reactions, 1)
|
||||
require.Equal(t, reaction, reactions[0])
|
||||
|
||||
err = ts.DeleteReaction(ctx, &store.DeleteReaction{
|
||||
ID: reaction.ID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
reactions, err = ts.ListReactions(ctx, &store.FindReaction{
|
||||
ContentID: &contentID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, reactions, 0)
|
||||
|
||||
ts.Close()
|
||||
}
|
||||
Reference in New Issue
Block a user