mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
Do not create the global configuration in homedir by-default, as, correctly, requested on chat. Use iris.WithGlobalConfiguration with a pre-defined iris.yml file on your home directory, existing users will not have any issues, new one will have to create the file before
Former-commit-id: 033f7e96693b13f87b44b445ed166328fea6e0a0
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// $ go test -v -run TestConfiguration*
|
||||
@@ -89,7 +91,30 @@ func TestConfigurationOptionsDeep(t *testing.T) {
|
||||
t.Fatalf("DEEP configuration is not the same after New expected:\n %#v \ngot:\n %#v", expected, has)
|
||||
}
|
||||
}
|
||||
|
||||
func createGlobalConfiguration(t *testing.T) {
|
||||
filename := homeConfigurationFilename(".yml")
|
||||
c, err := parseYAML(filename)
|
||||
if err != nil {
|
||||
// this error will be occurred the first time that the configuration
|
||||
// file doesn't exist.
|
||||
// Create the YAML-ONLY global configuration file now using the default configuration 'c'.
|
||||
// This is useful when we run multiple iris servers that share the same
|
||||
// configuration, even with custom values at its "Other" field.
|
||||
out, err := yaml.Marshal(&c)
|
||||
|
||||
if err == nil {
|
||||
err = ioutil.WriteFile(filename, out, os.FileMode(0666))
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("error while writing the global configuration field at: %s. Trace: %v\n", filename, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigurationGlobal(t *testing.T) {
|
||||
createGlobalConfiguration(t)
|
||||
|
||||
testConfigurationGlobal(t, WithGlobalConfiguration)
|
||||
// globalConfigurationKeyword = "~""
|
||||
testConfigurationGlobal(t, WithConfiguration(YAML(globalConfigurationKeyword)))
|
||||
|
||||
Reference in New Issue
Block a user