2024-02-23 00:26:49 +00:00
|
|
|
// Copyright 2024 The Forgjo Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2020-06-09 01:19:14 +01:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2024-02-23 00:26:49 +00:00
|
|
|
package forgejo
|
2020-06-09 01:19:14 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetGlobalSettings(t *testing.T) {
|
|
|
|
log.Println("== TestGetGlobalSettings ==")
|
|
|
|
c := newTestClient()
|
2020-06-30 21:29:09 +01:00
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
uiSettings, _, err := c.GetGlobalUISettings()
|
2020-06-09 01:19:14 +01:00
|
|
|
assert.NoError(t, err)
|
|
|
|
expectedAllowedReactions := []string{"+1", "-1", "laugh", "hooray", "confused", "heart", "rocket", "eyes"}
|
2020-06-30 21:29:09 +01:00
|
|
|
assert.ElementsMatch(t, expectedAllowedReactions, uiSettings.AllowedReactions)
|
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
repoSettings, _, err := c.GetGlobalRepoSettings()
|
2020-06-30 21:29:09 +01:00
|
|
|
assert.NoError(t, err)
|
2020-09-07 04:09:10 +01:00
|
|
|
assert.EqualValues(t, &GlobalRepoSettings{
|
|
|
|
HTTPGitDisabled: false,
|
|
|
|
MirrorsDisabled: false,
|
2021-07-01 16:10:21 +01:00
|
|
|
LFSDisabled: true,
|
2020-09-07 04:09:10 +01:00
|
|
|
}, repoSettings)
|
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
apiSettings, _, err := c.GetGlobalAPISettings()
|
2020-09-07 04:09:10 +01:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.EqualValues(t, &GlobalAPISettings{
|
|
|
|
MaxResponseItems: 50,
|
|
|
|
DefaultPagingNum: 30,
|
|
|
|
DefaultGitTreesPerPage: 1000,
|
|
|
|
DefaultMaxBlobSize: 10485760,
|
|
|
|
}, apiSettings)
|
2020-09-07 23:19:38 +01:00
|
|
|
|
2020-09-14 03:37:09 +01:00
|
|
|
attachSettings, _, err := c.GetGlobalAttachmentSettings()
|
2020-09-07 23:19:38 +01:00
|
|
|
assert.NoError(t, err)
|
2022-07-29 11:51:05 +01:00
|
|
|
if assert.NotEmpty(t, attachSettings.AllowedTypes) {
|
|
|
|
attachSettings.AllowedTypes = ""
|
|
|
|
}
|
2020-09-07 23:19:38 +01:00
|
|
|
assert.EqualValues(t, &GlobalAttachmentSettings{
|
2022-07-29 11:51:05 +01:00
|
|
|
Enabled: true,
|
2024-01-06 05:14:12 +00:00
|
|
|
MaxSize: 2048,
|
2022-07-29 11:51:05 +01:00
|
|
|
MaxFiles: 5,
|
2020-09-07 23:19:38 +01:00
|
|
|
}, attachSettings)
|
2020-06-09 01:19:14 +01:00
|
|
|
}
|