Files
gitea-MIRROR/modules/setting/lfs_test.go
silverwind b1a6cdadc8 enhance: deprecate minio storage naming, switch to rustfs on ci (#37545)
Use provider-neutral S3 naming for object storage and switch CI to
RustFS.

1. Rename `STORAGE_TYPE = minio` to `s3`, `[storage.minio]` to
`[storage.s3]`, and `MINIO_*` keys to `S3_*`. Legacy configs resolve as
before and log deprecation warnings. Explicit `S3_*` keys take
precedence in the same section.
2. Rename `migrate-storage` options to `--storage=s3` and `--s3-*`,
retaining deprecated `minio` aliases.
3. Replace MinIO in CI with RustFS `1.0.6` and rename
`TEST_MINIO_ENDPOINT` to `TEST_S3_ENDPOINT`.

Docs: https://gitea.com/gitea/docs/pulls/659

Assisted-by: Claude Code:claude-opus-5-5

---------

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-11-24 06:13:13 +00:00

112 lines
2.3 KiB
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package setting
import (
"testing"
"gitea.dev/modules/test"
"github.com/stretchr/testify/assert"
)
func Test_getStorageInheritNameSectionTypeForLFS(t *testing.T) {
for _, tt := range []struct {
config, storageType, path string
}{
{`
[storage]
STORAGE_TYPE = s3
`, "s3", "lfs/"},
{`
[server]
LFS_CONTENT_PATH = path_ignored
[lfs]
PATH = path_used
`, "local", "path_used"},
{`
[server]
LFS_CONTENT_PATH = deprecatedpath
`, "local", "deprecatedpath"},
{`
[storage.lfs]
STORAGE_TYPE = s3
`, "s3", "lfs/"},
{`
[lfs]
STORAGE_TYPE = my_s3
[storage.my_s3]
STORAGE_TYPE = s3
`, "s3", "lfs/"},
{`
[lfs]
STORAGE_TYPE = my_s3
S3_BASE_PATH = my_lfs/
[storage.my_s3]
STORAGE_TYPE = s3
`, "s3", "my_lfs/"},
} {
cfg, err := NewConfigProviderFromData(tt.config)
assert.NoError(t, err)
if tt.storageType == "local" {
applyDeprecatedKeys(cfg)
}
assert.NoError(t, loadLFSFrom(cfg))
assert.EqualValues(t, tt.storageType, LFS.Storage.Type)
if tt.storageType == "local" {
assert.Contains(t, LFS.Storage.Path, tt.path)
} else {
assert.Equal(t, tt.path, LFS.Storage.S3Config.BasePath)
}
}
}
func Test_LFSStorage1(t *testing.T) {
iniStr := `
[storage]
STORAGE_TYPE = s3
`
cfg, err := NewConfigProviderFromData(iniStr)
assert.NoError(t, err)
assert.NoError(t, loadLFSFrom(cfg))
assert.EqualValues(t, "s3", LFS.Storage.Type)
assert.Equal(t, "gitea", LFS.Storage.S3Config.Bucket)
assert.Equal(t, "lfs/", LFS.Storage.S3Config.BasePath)
}
func Test_LFSClientServerConfigs(t *testing.T) {
defer test.MockVariableValue(&LFS)()
defer test.MockVariableValue(&LFSClient)()
iniStr := `
[server]
LFS_MAX_BATCH_SIZE = 100
[lfs_client]
# will default to 20
BATCH_SIZE = 0
`
cfg, err := NewConfigProviderFromData(iniStr)
assert.NoError(t, err)
assert.NoError(t, loadLFSFrom(cfg))
assert.Equal(t, 100, LFS.MaxBatchSize)
assert.Equal(t, 20, LFSClient.BatchSize)
assert.Equal(t, 8, LFSClient.BatchOperationConcurrency)
iniStr = `
[lfs_client]
BATCH_SIZE = 50
BATCH_OPERATION_CONCURRENCY = 10
`
cfg, err = NewConfigProviderFromData(iniStr)
assert.NoError(t, err)
assert.NoError(t, loadLFSFrom(cfg))
assert.Equal(t, 50, LFSClient.BatchSize)
assert.Equal(t, 10, LFSClient.BatchOperationConcurrency)
}