diff --git a/config/notifiers.go b/config/notifiers.go index afc5be37..e937fd65 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -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. diff --git a/config/notifiers_test.go b/config/notifiers_test.go index a91c874a..73137d1f 100644 --- a/config/notifiers_test.go +++ b/config/notifiers_test.go @@ -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: ''