2023-06-29 22:55:03 +08:00
|
|
|
package teststore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2023-09-17 22:55:13 +08:00
|
|
|
|
2023-12-08 22:41:47 +08:00
|
|
|
storepb "github.com/usememos/memos/proto/gen/store"
|
2023-06-29 22:55:03 +08:00
|
|
|
"github.com/usememos/memos/store"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUserSettingStore(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
ts := NewTestingStore(ctx, t)
|
|
|
|
user, err := createTestingHostUser(ctx, ts)
|
|
|
|
require.NoError(t, err)
|
2023-12-16 12:18:53 +08:00
|
|
|
_, err = ts.UpsertUserSetting(ctx, &storepb.UserSetting{
|
2023-12-08 22:41:47 +08:00
|
|
|
UserId: user.ID,
|
2024-05-13 20:03:04 +08:00
|
|
|
Key: storepb.UserSettingKey_LOCALE,
|
2023-12-08 22:41:47 +08:00
|
|
|
Value: &storepb.UserSetting_Locale{Locale: "en"},
|
2023-06-29 22:55:03 +08:00
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2023-12-16 12:18:53 +08:00
|
|
|
list, err := ts.ListUserSettings(ctx, &store.FindUserSetting{})
|
2023-06-29 22:55:03 +08:00
|
|
|
require.NoError(t, err)
|
2023-12-08 22:41:47 +08:00
|
|
|
require.Equal(t, 1, len(list))
|
2024-01-16 13:51:26 +08:00
|
|
|
ts.Close()
|
2023-06-29 22:55:03 +08:00
|
|
|
}
|