system_setting_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package teststore
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/require"
  6. "github.com/usememos/memos/api"
  7. "github.com/usememos/memos/store"
  8. )
  9. func TestSystemSettingStore(t *testing.T) {
  10. ctx := context.Background()
  11. ts := NewTestingStore(ctx, t)
  12. _, err := ts.UpsertSystemSetting(ctx, &api.SystemSettingUpsert{
  13. Name: api.SystemSettingServerIDName,
  14. Value: "test_server_id",
  15. })
  16. require.NoError(t, err)
  17. _, err = ts.UpsertSystemSetting(ctx, &api.SystemSettingUpsert{
  18. Name: api.SystemSettingSecretSessionName,
  19. Value: "test_secret_session_name",
  20. })
  21. require.NoError(t, err)
  22. _, err = ts.UpsertSystemSetting(ctx, &api.SystemSettingUpsert{
  23. Name: api.SystemSettingAllowSignUpName,
  24. Value: "true",
  25. })
  26. require.NoError(t, err)
  27. _, err = ts.UpsertSystemSetting(ctx, &api.SystemSettingUpsert{
  28. Name: api.SystemSettingLocalStoragePathName,
  29. Value: "/tmp/memos",
  30. })
  31. require.NoError(t, err)
  32. list, err := ts.ListSystemSettings(ctx, &store.FindSystemSetting{})
  33. require.NoError(t, err)
  34. require.Equal(t, 4, len(list))
  35. }