user_setting_test.go 690 B

12345678910111213141516171819202122232425262728
  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 TestUserSettingStore(t *testing.T) {
  10. ctx := context.Background()
  11. ts := NewTestingStore(ctx, t)
  12. user, err := createTestingHostUser(ctx, ts)
  13. require.NoError(t, err)
  14. _, err = ts.UpsertUserSetting(ctx, &storepb.UserSetting{
  15. UserId: user.ID,
  16. Key: storepb.UserSettingKey_LOCALE,
  17. Value: &storepb.UserSetting_Locale{Locale: "en"},
  18. })
  19. require.NoError(t, err)
  20. list, err := ts.ListUserSettings(ctx, &store.FindUserSetting{})
  21. require.NoError(t, err)
  22. require.Equal(t, 1, len(list))
  23. ts.Close()
  24. }