config: fix Wechat global parameters (#1813)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2019-03-29 12:21:59 +01:00 committed by Max Inden
parent 19ab388d93
commit 0f754cdef3
2 changed files with 1 additions and 44 deletions

View File

@ -444,16 +444,7 @@ type WechatConfig struct {
func (c *WechatConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
*c = DefaultWechatConfig
type plain WechatConfig
if err := unmarshal((*plain)(c)); err != nil {
return err
}
if c.APISecret == "" {
return fmt.Errorf("missing Wechat APISecret in Wechat config")
}
if c.CorpID == "" {
return fmt.Errorf("missing Wechat CorpID in Wechat config")
}
return nil
return unmarshal((*plain)(c))
}
// OpsGenieConfig configures notifications via OpsGenie.

View File

@ -236,40 +236,6 @@ http_config:
}
}
func TestWechatAPIKeyIsPresent(t *testing.T) {
in := `
api_secret: ''
`
var cfg WechatConfig
err := yaml.UnmarshalStrict([]byte(in), &cfg)
expected := "missing Wechat APISecret in Wechat config"
if err == nil {
t.Fatalf("no error returned, expected:\n%v", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%v\ngot:\n%v", expected, err.Error())
}
}
func TestWechatCorpIDIsPresent(t *testing.T) {
in := `
api_secret: 'api_secret'
corp_id: ''
`
var cfg WechatConfig
err := yaml.UnmarshalStrict([]byte(in), &cfg)
expected := "missing Wechat CorpID in Wechat config"
if err == nil {
t.Fatalf("no error returned, expected:\n%v", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%v\ngot:\n%v", expected, err.Error())
}
}
func TestVictorOpsRoutingKeyIsPresent(t *testing.T) {
in := `
routing_key: ''