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