user_setting_test.go 664 B

123456789101112131415161718192021222324252627
  1. package teststore
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/require"
  6. "github.com/usememos/memos/store"
  7. )
  8. func TestUserSettingStore(t *testing.T) {
  9. ctx := context.Background()
  10. ts := NewTestingStore(ctx, t)
  11. user, err := createTestingHostUser(ctx, ts)
  12. require.NoError(t, err)
  13. _, err = ts.UpsertUserSetting(ctx, &store.UserSetting{
  14. UserID: user.ID,
  15. Key: "test_key",
  16. Value: "test_value",
  17. })
  18. require.NoError(t, err)
  19. list, err := ts.ListUserSettings(ctx, &store.FindUserSetting{})
  20. require.NoError(t, err)
  21. require.Equal(t, 1, len(list))
  22. require.Equal(t, "test_key", list[0].Key)
  23. require.Equal(t, "test_value", list[0].Value)
  24. }