mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Generalize loadConfig method to avoid reading from disk (#5819)
As we move to multiple config backends like local disk and etcd, config file should not be read from the disk, instead the quick package should load and verify for duplicate entries.
This commit is contained in:
committed by
Harshavardhana
parent
57b8db2088
commit
638f01f9e4
@@ -24,7 +24,6 @@ import (
|
||||
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/event/target"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func TestServerConfig(t *testing.T) {
|
||||
@@ -126,34 +125,6 @@ func TestServerConfigWithEnvs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckDupJSONKeys(t *testing.T) {
|
||||
testCases := []struct {
|
||||
json string
|
||||
shouldPass bool
|
||||
}{
|
||||
{`{}`, true},
|
||||
{`{"version" : "13"}`, true},
|
||||
{`{"version" : "13", "version": "14"}`, false},
|
||||
{`{"version" : "13", "credential": {"accessKey": "12345"}}`, true},
|
||||
{`{"version" : "13", "credential": {"accessKey": "12345", "accessKey":"12345"}}`, false},
|
||||
{`{"version" : "13", "notify": {"amqp": {"1"}, "webhook":{"3"}}}`, true},
|
||||
{`{"version" : "13", "notify": {"amqp": {"1"}, "amqp":{"3"}}}`, false},
|
||||
{`{"version" : "13", "notify": {"amqp": {"1":{}, "2":{}}}}`, true},
|
||||
{`{"version" : "13", "notify": {"amqp": {"1":{}, "1":{}}}}`, false},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
err := doCheckDupJSONKeys(gjson.Result{}, gjson.Parse(testCase.json))
|
||||
if testCase.shouldPass && err != nil {
|
||||
t.Errorf("Test %d, should pass but it failed with err = %v", i+1, err)
|
||||
}
|
||||
if !testCase.shouldPass && err == nil {
|
||||
t.Errorf("Test %d, should fail but it succeed.", i+1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Tests config validator..
|
||||
func TestValidateConfig(t *testing.T) {
|
||||
rootPath, err := newTestConfig(globalMinioDefaultRegion)
|
||||
|
||||
Reference in New Issue
Block a user