mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-09 15:32:54 +01:00
More tests coverage for client.go
This commit is contained in:
parent
d17decfdc2
commit
fe3925c1e6
2 changed files with 37 additions and 25 deletions
|
@ -133,7 +133,6 @@ func NewClient(h string, o ...Option) (*Client, error) {
|
|||
// Some settings in a Client cannot be empty/unset
|
||||
if c.host == "" {
|
||||
return c, ErrNoHostname
|
||||
|
||||
}
|
||||
|
||||
return c, nil
|
||||
|
|
|
@ -13,8 +13,19 @@ const DefaultHost = "localhost"
|
|||
// TestNewClient tests the NewClient() method with its default options
|
||||
func TestNewClient(t *testing.T) {
|
||||
host := "mail.example.com"
|
||||
c, err := NewClient(host)
|
||||
if err != nil {
|
||||
tests := []struct {
|
||||
name string
|
||||
host string
|
||||
shouldfail bool
|
||||
}{
|
||||
{"Default", "mail.example.com", false},
|
||||
{"Empty host should fail", "", true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c, err := NewClient(tt.host)
|
||||
if err != nil && !tt.shouldfail {
|
||||
t.Errorf("failed to create new client: %s", err)
|
||||
return
|
||||
}
|
||||
|
@ -39,6 +50,8 @@ func TestNewClient(t *testing.T) {
|
|||
t.Errorf("failed to create new client. TLS config min versino expected: %d, got: %d",
|
||||
DefaultTLSMinVersion, c.tlsconfig.MinVersion)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewClient tests the NewClient() method with its custom options
|
||||
|
|
Loading…
Reference in a new issue