|
|
@ -77,10 +77,14 @@ MINIO_BUCKET = gitea |
|
|
|
func Test_getStorageSpecificOverridesStorage(t *testing.T) { |
|
|
|
func Test_getStorageSpecificOverridesStorage(t *testing.T) { |
|
|
|
iniStr := ` |
|
|
|
iniStr := ` |
|
|
|
[attachment] |
|
|
|
[attachment] |
|
|
|
|
|
|
|
STORAGE_TYPE = minio |
|
|
|
MINIO_BUCKET = gitea-attachment |
|
|
|
MINIO_BUCKET = gitea-attachment |
|
|
|
|
|
|
|
|
|
|
|
[storage.attachments] |
|
|
|
[storage.attachments] |
|
|
|
MINIO_BUCKET = gitea |
|
|
|
MINIO_BUCKET = gitea |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[storage] |
|
|
|
|
|
|
|
STORAGE_TYPE = local |
|
|
|
` |
|
|
|
` |
|
|
|
Cfg, _ = ini.Load([]byte(iniStr)) |
|
|
|
Cfg, _ = ini.Load([]byte(iniStr)) |
|
|
|
|
|
|
|
|
|
|
@ -88,6 +92,7 @@ MINIO_BUCKET = gitea |
|
|
|
storageType := sec.Key("STORAGE_TYPE").MustString("") |
|
|
|
storageType := sec.Key("STORAGE_TYPE").MustString("") |
|
|
|
storage := getStorage("attachments", storageType, sec) |
|
|
|
storage := getStorage("attachments", storageType, sec) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.EqualValues(t, "minio", storage.Type) |
|
|
|
assert.EqualValues(t, "gitea-attachment", storage.Section.Key("MINIO_BUCKET").String()) |
|
|
|
assert.EqualValues(t, "gitea-attachment", storage.Section.Key("MINIO_BUCKET").String()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -162,3 +167,31 @@ MINIO_BUCKET = gitea-storage |
|
|
|
assert.EqualValues(t, "gitea-storage", storage.Section.Key("MINIO_BUCKET").String()) |
|
|
|
assert.EqualValues(t, "gitea-storage", storage.Section.Key("MINIO_BUCKET").String()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Test_getStorageInheritStorageType(t *testing.T) { |
|
|
|
|
|
|
|
iniStr := ` |
|
|
|
|
|
|
|
[storage] |
|
|
|
|
|
|
|
STORAGE_TYPE = minio |
|
|
|
|
|
|
|
` |
|
|
|
|
|
|
|
Cfg, _ = ini.Load([]byte(iniStr)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sec := Cfg.Section("attachment") |
|
|
|
|
|
|
|
storageType := sec.Key("STORAGE_TYPE").MustString("") |
|
|
|
|
|
|
|
storage := getStorage("attachments", storageType, sec) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.EqualValues(t, "minio", storage.Type) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Test_getStorageInheritNameSectionType(t *testing.T) { |
|
|
|
|
|
|
|
iniStr := ` |
|
|
|
|
|
|
|
[storage.attachments] |
|
|
|
|
|
|
|
STORAGE_TYPE = minio |
|
|
|
|
|
|
|
` |
|
|
|
|
|
|
|
Cfg, _ = ini.Load([]byte(iniStr)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sec := Cfg.Section("attachment") |
|
|
|
|
|
|
|
storageType := sec.Key("STORAGE_TYPE").MustString("") |
|
|
|
|
|
|
|
storage := getStorage("attachments", storageType, sec) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert.EqualValues(t, "minio", storage.Type) |
|
|
|
|
|
|
|
} |
|
|
|