mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 05:40:50 +01:00
Winni Neessen
31001e87b2
# SUMMARY * Bad licenses: * Deprecated licenses: * Licenses without file extension: * Missing licenses: * Unused licenses: * Used licenses: CC0-1.0, MIT * Read errors: 0 * Files with copyright information: 45 / 45 * Files with license information: 45 / 45 Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// SPDX-FileCopyrightText: 2022 Winni Neessen <winni@neessen.dev>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package mail
|
|
|
|
import "testing"
|
|
|
|
// TestTLSPolicy_String tests the TLSPolicy.String method
|
|
func TestTLSPolicy_String(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
value TLSPolicy
|
|
want int
|
|
}{
|
|
{"TLSPolicy is Mandatory", TLSMandatory, 0},
|
|
{"TLSPolicy is Opportunistic", TLSOpportunistic, 1},
|
|
{"TLSPolicy is NoTLS", NoTLS, 2},
|
|
{"TLSPolicy is Unknown", 3, 3},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c, err := NewClient("mail.example.com", WithTLSPolicy(tt.value))
|
|
if err != nil {
|
|
t.Errorf("failed to create new Client: %s", err)
|
|
return
|
|
}
|
|
|
|
if c.tlspolicy != tt.value {
|
|
t.Errorf("WithTLSPolicy() failed. Expected: %s (%d), got: %s (%d)", tt.value.String(), tt.value,
|
|
c.tlspolicy.String(), c.tlspolicy)
|
|
}
|
|
if c.tlspolicy.String() != tt.value.String() {
|
|
t.Errorf("WithTLSPolicy() failed. Expected: %s (%d), got: %s (%d)", tt.value.String(), tt.value,
|
|
c.tlspolicy.String(), c.tlspolicy)
|
|
}
|
|
})
|
|
}
|
|
}
|