diff --git a/pkg/controller/jenkins/notifications/smtp.go b/pkg/controller/jenkins/notifications/smtp.go index 8b8b0f28..ed06045f 100644 --- a/pkg/controller/jenkins/notifications/smtp.go +++ b/pkg/controller/jenkins/notifications/smtp.go @@ -74,7 +74,6 @@ func (s SMTP) Send(event Event, config v1alpha2.Notification) error { message.SetBody("text/html", htmlMessage) if err := mailer.DialAndSend(message); err != nil { - fmt.Print(err) return err } diff --git a/pkg/controller/jenkins/notifications/smtp_test.go b/pkg/controller/jenkins/notifications/smtp_test.go index 0bfaf7af..55e9492c 100644 --- a/pkg/controller/jenkins/notifications/smtp_test.go +++ b/pkg/controller/jenkins/notifications/smtp_test.go @@ -5,17 +5,20 @@ import ( "errors" "fmt" "github.com/emersion/go-smtp" - "github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2" - "github.com/stretchr/testify/assert" "io" "io/ioutil" "log" - "sigs.k8s.io/controller-runtime/pkg/client/fake" + "mime/quotedprintable" + "regexp" "testing" "time" + "github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkins/v1alpha2" + + "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client/fake" ) const ( @@ -25,6 +28,19 @@ const ( testSMTPPort = 1025 ) +var smtpEvent = Event{ + Jenkins: v1alpha2.Jenkins{ + ObjectMeta: metav1.ObjectMeta{ + Name: testCrName, + Namespace: testNamespace, + }, + }, + Phase: testPhase, + Message: testMessage, + MessagesVerbose: testMessageVerbose, + LogLevel: testLoggingLevel, +} + type testServer struct{} // Login handles a login command with username and password. @@ -54,10 +70,18 @@ func (s *testSession) Rcpt(to string) error { } func (s *testSession) Data(r io.Reader) error { - if b, err := ioutil.ReadAll(r); err != nil { + re := regexp.MustCompile(`\t+