From 78203ad208c227b0094c328f59c79b171cdedee7 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Sun, 21 Feb 2016 22:13:06 -0600 Subject: [PATCH] Added tests for SMTP --- models/models_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/models/models_test.go b/models/models_test.go index ec84a5b6..e69733ff 100644 --- a/models/models_test.go +++ b/models/models_test.go @@ -61,6 +61,40 @@ func (s *ModelsSuite) TestPostGroupNoTargets(c *check.C) { c.Assert(err, check.Equals, ErrNoTargetsSpecified) } +func (s *ModelsSuite) TestPostSMTP(c *check.C) { + smtp := SMTP{ + Name: "Test SMTP", + Host: "1.1.1.1:25", + FromAddress: "Foo Bar ", + UserId: 1, + } + err = PostSMTP(&smtp) + c.Assert(err, check.Equals, nil) + ss, err := GetSMTPs(1) + c.Assert(err, check.Equals, nil) + c.Assert(len(ss), check.Equals, 1) +} + +func (s *ModelsSuite) TestPostSMTPNoHost(c *check.C) { + smtp := SMTP{ + Name: "Test SMTP", + FromAddress: "Foo Bar ", + UserId: 1, + } + err = PostSMTP(&smtp) + c.Assert(err, check.Equals, ErrHostNotSpecified) +} + +func (s *ModelsSuite) TestPostSMTPNoFrom(c *check.C) { + smtp := SMTP{ + Name: "Test SMTP", + UserId: 1, + Host: "1.1.1.1:25", + } + err = PostSMTP(&smtp) + c.Assert(err, check.Equals, ErrFromAddressNotSpecified) +} + func (s *ModelsSuite) TestPutUser(c *check.C) { u, err := GetUser(1) u.Username = "admin_changed"