activity_test.go 838 B

12345678910111213141516171819202122232425262728293031323334
  1. package teststore
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/require"
  6. storepb "github.com/usememos/memos/proto/gen/store"
  7. "github.com/usememos/memos/store"
  8. )
  9. func TestActivityStore(t *testing.T) {
  10. ctx := context.Background()
  11. ts := NewTestingStore(ctx, t)
  12. user, err := createTestingHostUser(ctx, ts)
  13. require.NoError(t, err)
  14. create := &store.Activity{
  15. CreatorID: user.ID,
  16. Type: store.ActivityTypeMemoComment,
  17. Level: store.ActivityLevelInfo,
  18. Payload: &storepb.ActivityPayload{},
  19. }
  20. activity, err := ts.CreateActivity(ctx, create)
  21. require.NoError(t, err)
  22. require.NotNil(t, activity)
  23. activities, err := ts.ListActivities(ctx, &store.FindActivity{
  24. ID: &activity.ID,
  25. })
  26. require.NoError(t, err)
  27. require.Equal(t, 1, len(activities))
  28. require.Equal(t, activity, activities[0])
  29. ts.Close()
  30. }