2023-04-03 09:53:36 +08:00
|
|
|
package teststore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2023-07-02 18:56:25 +08:00
|
|
|
apiv1 "github.com/usememos/memos/api/v1"
|
2023-06-29 22:55:03 +08:00
|
|
|
"github.com/usememos/memos/store"
|
2023-04-03 09:53:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSystemSettingStore(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2023-06-29 22:55:03 +08:00
|
|
|
ts := NewTestingStore(ctx, t)
|
2023-07-02 18:56:25 +08:00
|
|
|
_, err := ts.UpsertSystemSetting(ctx, &store.SystemSetting{
|
|
|
|
Name: apiv1.SystemSettingServerIDName.String(),
|
2023-04-03 09:53:36 +08:00
|
|
|
Value: "test_server_id",
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2023-07-02 18:56:25 +08:00
|
|
|
_, err = ts.UpsertSystemSetting(ctx, &store.SystemSetting{
|
|
|
|
Name: apiv1.SystemSettingSecretSessionName.String(),
|
2023-04-03 09:53:36 +08:00
|
|
|
Value: "test_secret_session_name",
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2023-07-02 18:56:25 +08:00
|
|
|
_, err = ts.UpsertSystemSetting(ctx, &store.SystemSetting{
|
|
|
|
Name: apiv1.SystemSettingAllowSignUpName.String(),
|
2023-04-03 09:53:36 +08:00
|
|
|
Value: "true",
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2023-07-02 18:56:25 +08:00
|
|
|
_, err = ts.UpsertSystemSetting(ctx, &store.SystemSetting{
|
|
|
|
Name: apiv1.SystemSettingLocalStoragePathName.String(),
|
2023-04-03 09:53:36 +08:00
|
|
|
Value: "/tmp/memos",
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
2023-06-29 22:55:03 +08:00
|
|
|
list, err := ts.ListSystemSettings(ctx, &store.FindSystemSetting{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 4, len(list))
|
2023-04-03 09:53:36 +08:00
|
|
|
}
|