-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Expand file tree
/
Copy pathadmin_test.go
More file actions
40 lines (30 loc) · 929 Bytes
/
admin_test.go
File metadata and controls
40 lines (30 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package setting
import (
"testing"
"code.gitea.io/gitea/modules/test"
"github.com/stretchr/testify/assert"
)
func TestLoadAdminOrgDisabledFeatures(t *testing.T) {
defer test.MockVariableValue(&Admin)()
cfg, err := NewConfigProviderFromData(`
[admin]
ORG_DISABLED_FEATURES = danger_zone
`)
assert.NoError(t, err)
loadAdminFrom(cfg)
assert.True(t, Admin.OrgDisabledFeatures.Contains(OrgFeatureDangerZone))
assert.False(t, CanManageOrgDangerZone(false))
assert.True(t, CanManageOrgDangerZone(true))
}
func TestLoadAdminOrgDisabledFeaturesDefault(t *testing.T) {
defer test.MockVariableValue(&Admin)()
cfg, err := NewConfigProviderFromData(`
[admin]
`)
assert.NoError(t, err)
loadAdminFrom(cfg)
assert.False(t, Admin.OrgDisabledFeatures.Contains(OrgFeatureDangerZone))
assert.True(t, CanManageOrgDangerZone(false))
}