aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting/storage_test.go
diff options
context:
space:
mode:
author胡玮文 <huww98@outlook.com>2020-12-22 07:03:18 +0800
committerGitHub <noreply@github.com>2020-12-22 01:03:18 +0200
commitc21a399646e3001841b095c2faa96b17f2483048 (patch)
treeb006e209bab6872f366abe4e953d146f86e5ca4d /modules/setting/storage_test.go
parentaddd4248daf2f90c5ce54f2d37c268ebab491b4a (diff)
downloadgitea-c21a399646e3001841b095c2faa96b17f2483048.tar.gz
gitea-c21a399646e3001841b095c2faa96b17f2483048.zip
more test case for STORAGE_TYPE overrides (and fixes) (#14096)
Signed-off-by: 胡玮文 <huww98@outlook.com>
Diffstat (limited to 'modules/setting/storage_test.go')
-rw-r--r--modules/setting/storage_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/modules/setting/storage_test.go b/modules/setting/storage_test.go
index 00c255a9c9..ffd8b7aa01 100644
--- a/modules/setting/storage_test.go
+++ b/modules/setting/storage_test.go
@@ -77,10 +77,14 @@ MINIO_BUCKET = gitea
func Test_getStorageSpecificOverridesStorage(t *testing.T) {
iniStr := `
[attachment]
+STORAGE_TYPE = minio
MINIO_BUCKET = gitea-attachment
[storage.attachments]
MINIO_BUCKET = gitea
+
+[storage]
+STORAGE_TYPE = local
`
Cfg, _ = ini.Load([]byte(iniStr))
@@ -88,6 +92,7 @@ MINIO_BUCKET = gitea
storageType := sec.Key("STORAGE_TYPE").MustString("")
storage := getStorage("attachments", storageType, sec)
+ assert.EqualValues(t, "minio", storage.Type)
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())
}
}
+
+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)
+}