(t *testing.T)
| 16 | } |
| 17 | |
| 18 | func TestLoad(t *testing.T) { |
| 19 | // loading empty data |
| 20 | conf, err := Load([]byte(""), flags.GlobalFlagsConfigFileFormatYAML, "app1") |
| 21 | assert.Nil(t, err) |
| 22 | assert.NotNil(t, conf) |
| 23 | assert.Equal(t, "app1", conv.S(conf.Name)) |
| 24 | conf, err = Load([]byte("{}"), flags.GlobalFlagsConfigFileFormatJSON, "app1") |
| 25 | assert.Nil(t, err) |
| 26 | assert.NotNil(t, conf) |
| 27 | assert.Equal(t, "app1", conv.S(conf.Name)) |
| 28 | |
| 29 | // empty data and empty app name |
| 30 | conf, err = Load([]byte(""), flags.GlobalFlagsConfigFileFormatYAML, "") |
| 31 | assert.NotNil(t, err) |
| 32 | conf, err = Load([]byte(""), flags.GlobalFlagsConfigFileFormatJSON, "") |
| 33 | assert.NotNil(t, err) |
| 34 | |
| 35 | // loading "name" only data |
| 36 | conf, err = Load([]byte("name: app2"), flags.GlobalFlagsConfigFileFormatYAML, "app3") |
| 37 | assert.Nil(t, err) |
| 38 | assert.NotNil(t, conf) |
| 39 | assert.Equal(t, "app2", conv.S(conf.Name)) |
| 40 | conf, err = Load([]byte("{\"name\":\"app2\"}"), flags.GlobalFlagsConfigFileFormatJSON, "app3") |
| 41 | assert.Nil(t, err) |
| 42 | assert.NotNil(t, conf) |
| 43 | assert.Equal(t, "app2", conv.S(conf.Name)) |
| 44 | |
| 45 | // reference config data (YAML) |
| 46 | conf, err = Load([]byte(refConfigYAML), flags.GlobalFlagsConfigFileFormatYAML, "app4") |
| 47 | assert.Nil(t, err) |
| 48 | assert.NotNil(t, conf) |
| 49 | assert.Equal(t, conv.S(refConfig.Name), conv.S(conf.Name)) |
| 50 | assert.Equal(t, refConfig, conf) |
| 51 | |
| 52 | // reference config data (JSON) |
| 53 | conf, err = Load([]byte(refConfigJSON), flags.GlobalFlagsConfigFileFormatJSON, "app5") |
| 54 | assert.Nil(t, err) |
| 55 | assert.NotNil(t, conf) |
| 56 | assert.Equal(t, conv.S(refConfig.Name), conv.S(conf.Name)) |
| 57 | assert.Equal(t, refConfig, conf) |
| 58 | |
| 59 | // partial config data (YAML) |
| 60 | conf, err = Load([]byte(partialConfigYAML), flags.GlobalFlagsConfigFileFormatYAML, "app6") |
| 61 | assert.Nil(t, err) |
| 62 | assert.NotNil(t, conf) |
| 63 | assert.Equal(t, partialConfig.Name, conf.Name) |
| 64 | assert.Equal(t, partialConfig.Port, conf.Port) |
| 65 | assert.Equal(t, partialConfig.CPU, conf.CPU) |
| 66 | assert.Equal(t, partialConfig.Memory, conf.Memory) |
| 67 | assert.Equal(t, partialConfig.LoadBalancer.Enabled, conf.LoadBalancer.Enabled) |
| 68 | defConf := DefaultConfig(conv.S(conf.Name)) |
| 69 | assert.Equal(t, defConf.ClusterName, conf.ClusterName) |
| 70 | assert.Equal(t, defConf.Units, conf.Units) |
| 71 | assert.Equal(t, defConf.AWS, conf.AWS) |
| 72 | assert.Equal(t, defConf.Docker, conf.Docker) |
| 73 | } |
| 74 | |
| 75 | func TestConfig_Defaults(t *testing.T) { |
nothing calls this directly
no test coverage detected