memos/test/store/user_setting_test.go

33 lines
715 B
Go
Raw Normal View History

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-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-09-29 09:15:54 +08:00
_, err = ts.UpsertUserSetting(ctx, &store.UserSetting{
2023-06-29 22:55:03 +08:00
UserID: user.ID,
Key: "test_key",
Value: "test_value",
})
require.NoError(t, err)
2023-09-29 09:15:54 +08:00
_, err = ts.UpsertUserSetting(ctx, &store.UserSetting{
UserID: user.ID,
Key: "locale",
Value: "zh",
})
require.NoError(t, err)
2023-06-29 22:55:03 +08:00
list, err := ts.ListUserSettings(ctx, &store.FindUserSetting{})
require.NoError(t, err)
require.Equal(t, 2, len(list))
2023-06-29 22:55:03 +08:00
}