Files
gitea/modules/setting/repository_archive_test.go
T
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

90 lines
2.0 KiB
Go

// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package setting
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_getStorageInheritNameSectionTypeForRepoArchive(t *testing.T) {
for _, tc := range []struct {
ini, basePath string
}{
// packages storage inherits from storage if nothing configured
{`
[storage]
STORAGE_TYPE = s3
`, "repo-archive/"},
// we can also configure packages storage directly
{`
[storage.repo-archive]
STORAGE_TYPE = s3
`, "repo-archive/"},
// or we can indicate the storage type in the packages section
{`
[repo-archive]
STORAGE_TYPE = my_s3
[storage.my_s3]
STORAGE_TYPE = s3
`, "repo-archive/"},
// or we can indicate the storage type and S3 base path in the packages section
{`
[repo-archive]
STORAGE_TYPE = my_s3
S3_BASE_PATH = my_archive/
[storage.my_s3]
STORAGE_TYPE = s3
`, "my_archive/"},
} {
cfg, err := NewConfigProviderFromData(tc.ini)
assert.NoError(t, err)
assert.NoError(t, loadRepoArchiveFrom(cfg))
assert.EqualValues(t, "s3", RepoArchive.Storage.Type)
assert.Equal(t, tc.basePath, RepoArchive.Storage.S3Config.BasePath)
}
}
func Test_RepoArchiveStorage(t *testing.T) {
for _, ini := range []string{
`
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[storage]
STORAGE_TYPE = s3
S3_ENDPOINT = s3.my-domain.net
S3_BUCKET = gitea
S3_LOCATION = homenet
S3_USE_SSL = true
S3_ACCESS_KEY_ID = correct_key
S3_SECRET_ACCESS_KEY = correct_key
`,
`
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[storage.repo-archive]
STORAGE_TYPE = s3
[storage.s3]
STORAGE_TYPE = s3
S3_ENDPOINT = s3.my-domain.net
S3_BUCKET = gitea
S3_LOCATION = homenet
S3_USE_SSL = true
S3_ACCESS_KEY_ID = correct_key
S3_SECRET_ACCESS_KEY = correct_key
`,
} {
cfg, err := NewConfigProviderFromData(ini)
assert.NoError(t, err)
assert.NoError(t, loadRepoArchiveFrom(cfg))
storage := RepoArchive.Storage
assert.EqualValues(t, "s3", storage.Type)
assert.Equal(t, "gitea", storage.S3Config.Bucket)
}
}