memos/test/store/user_setting_test.go
boojack 66e65e4dc1
refactor: migrate definition to api v1 (#1879)
* refactor: user api v1

* refactor: system setting to apiv1

* chore: remove unused definition

* chore: update

* chore: refactor: system setting

* chore: update

* refactor: migrate tag

* feat: migrate activity store

* refactor: migrate shortcut apiv1

* chore: update
2023-07-02 18:56:25 +08:00

33 lines
820 B
Go

package teststore
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"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)
testSetting, err := ts.UpsertUserSetting(ctx, &store.UserSetting{
UserID: user.ID,
Key: "test_key",
Value: "test_value",
})
require.NoError(t, err)
localeSetting, err := ts.UpsertUserSetting(ctx, &store.UserSetting{
UserID: user.ID,
Key: "locale",
Value: "zh",
})
require.NoError(t, err)
list, err := ts.ListUserSettings(ctx, &store.FindUserSetting{})
require.NoError(t, err)
require.Equal(t, 2, len(list))
require.Equal(t, testSetting, list[0])
require.Equal(t, localeSetting, list[1])
}