memos/test/store/system_setting_test.go

40 lines
1.1 KiB
Go
Raw Normal View History

2023-04-03 04:53:36 +03:00
package teststore
import (
"context"
"testing"
"github.com/stretchr/testify/require"
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)
_, 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)
_, 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)
_, err = ts.UpsertSystemSetting(ctx, &store.SystemSetting{
Name: apiv1.SystemSettingAllowSignUpName.String(),
2023-04-03 04:53:36 +03:00
Value: "true",
})
require.NoError(t, err)
_, 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
}