forgejo/modules/setting/admin_test.go
Renovate Bot fed2d81c44
Some checks failed
/ release (push) Waiting to run
testing / backend-checks (push) Has been skipped
testing / frontend-checks (push) Has been skipped
testing / test-unit (push) Has been skipped
testing / test-e2e (push) Has been skipped
testing / test-mysql (push) Has been skipped
testing / test-pgsql (push) Has been skipped
testing / test-sqlite (push) Has been skipped
testing / test-remote-cacher (redis) (push) Has been skipped
testing / test-remote-cacher (valkey) (push) Has been skipped
testing / test-remote-cacher (garnet) (push) Has been skipped
testing / test-remote-cacher (redict) (push) Has been skipped
testing / security-check (push) Has been skipped
Integration tests for the release process / release-simulation (push) Has been cancelled
Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367)
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
2025-03-28 22:22:21 +00:00

33 lines
873 B
Go

// Copyright The Forgejo Authors.
// SPDX-License-Identifier: MIT
package setting
import (
"testing"
"forgejo.org/modules/container"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_loadAdminFrom(t *testing.T) {
iniStr := `
[admin]
DISABLE_REGULAR_ORG_CREATION = true
DEFAULT_EMAIL_NOTIFICATIONS = z
SEND_NOTIFICATION_EMAIL_ON_NEW_USER = true
USER_DISABLED_FEATURES = a,b
EXTERNAL_USER_DISABLE_FEATURES = x,y
`
cfg, err := NewConfigProviderFromData(iniStr)
require.NoError(t, err)
loadAdminFrom(cfg)
assert.True(t, Admin.DisableRegularOrgCreation)
assert.Equal(t, "z", Admin.DefaultEmailNotification)
assert.True(t, Admin.SendNotificationEmailOnNewUser)
assert.Equal(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
assert.Equal(t, container.SetOf("x", "y"), Admin.ExternalUserDisableFeatures)
}