diff --git a/cmd/vela-slack/plugin.go b/cmd/vela-slack/plugin.go index 10c5c8e..4b186c6 100644 --- a/cmd/vela-slack/plugin.go +++ b/cmd/vela-slack/plugin.go @@ -84,6 +84,7 @@ func (p *Plugin) Exec() error { attachments []slack.Attachment err error ) + logrus.Debug("running plugin with provided configuration") // clean up newlines that could invalidate JSON @@ -105,9 +106,9 @@ func (p *Plugin) Exec() error { // parse the slack message file if len(p.Path) != 0 { logrus.Infof("Parsing provided template file, %s", p.Path) + if p.Remote { attachments, err = getRemoteAttachment(p) - } else { attachments, err = getAttachmentFromFile(p) } diff --git a/cmd/vela-slack/plugin_test.go b/cmd/vela-slack/plugin_test.go index e6037ae..3bd588f 100644 --- a/cmd/vela-slack/plugin_test.go +++ b/cmd/vela-slack/plugin_test.go @@ -116,7 +116,11 @@ func TestSlack_Plugin_Exec_Remote_Attachment(t *testing.T) { if err != nil { t.Errorf("ReadFile error: %v", err) } - w.Write(bytes) + _, err = w.Write(bytes) + if err != nil { + t.Errorf("Write error: %v", err) + } + w.WriteHeader(http.StatusOK) })) defer ta.Close() @@ -171,7 +175,11 @@ func TestSlack_Plugin_Exec_Bad_Remote_Attachment_Parse(t *testing.T) { if err != nil { t.Errorf("ReadFile error: %v", err) } - w.Write(bytes) + _, err = w.Write(bytes) + if err != nil { + t.Errorf("Write error: %v", err) + } + w.WriteHeader(http.StatusOK) })) defer ta.Close() @@ -205,7 +213,12 @@ func TestSlack_Plugin_Exec_Bad_Remote_Attachment(t *testing.T) { if err != nil { t.Errorf("ReadFile error: %v", err) } - w.Write(bytes) + + _, err = w.Write(bytes) + if err != nil { + t.Errorf("Write error: %v", err) + } + w.WriteHeader(http.StatusOK) })) defer ta.Close() @@ -239,7 +252,12 @@ func TestSlack_Plugin_Exec_Bad_Remote_Attachment_Unmarshal(t *testing.T) { if err != nil { t.Errorf("ReadFile error: %v", err) } - w.Write(bytes) + + _, err = w.Write(bytes) + if err != nil { + t.Errorf("Write error: %v", err) + } + w.WriteHeader(http.StatusOK) })) defer ta.Close()