diff options
| author | Shulhan <ms@kilabit.info> | 2019-01-15 22:55:08 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-01-15 22:55:08 +0700 |
| commit | bf0b63db74108f61da2e305c3cec99d68cc804fe (patch) | |
| tree | c0dd9e020a6754f79c9f65b3165e31e52381515e | |
| parent | 05b758f6283c8307c99ea82a2a5f4291f3e75a41 (diff) | |
| download | pakakeh.go-bf0b63db74108f61da2e305c3cec99d68cc804fe.tar.xz | |
lib/smtp: add unit test for NewClient
| -rw-r--r-- | lib/smtp/client_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/smtp/client_test.go b/lib/smtp/client_test.go index 43e03f5c..22e68633 100644 --- a/lib/smtp/client_test.go +++ b/lib/smtp/client_test.go @@ -13,6 +13,31 @@ import ( "github.com/shuLhan/share/lib/test" ) +func TestNewClient(t *testing.T) { + cases := []struct { + desc string + raddr string + expErr string + }{{ + desc: "With invalid IP", + raddr: "!", + expErr: "lookup !: no such host", + }, { + desc: "With no MX", + raddr: "example.com", + expErr: "", + }} + + for _, c := range cases { + t.Log(c.desc) + + _, err := NewClient(c.raddr) + if err != nil { + test.Assert(t, "error", c.expErr, err.Error(), true) + } + } +} + func TestConnect(t *testing.T) { time.Sleep(1 * time.Second) |
