mirror of
https://github.com/1f349/simplemail.git
synced 2024-12-22 08:04:11 +00:00
24 lines
739 B
Go
24 lines
739 B
Go
package simplemail
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/stretchr/testify/assert"
|
|
"gopkg.in/yaml.v3"
|
|
"testing"
|
|
)
|
|
|
|
func TestFromAddress_UnmarshalText(t *testing.T) {
|
|
t.Run("json", func(t *testing.T) {
|
|
var fromAddress FromAddress
|
|
assert.NoError(t, json.Unmarshal([]byte(`"Jane Doe <jane@example.com>"`), &fromAddress))
|
|
assert.Equal(t, "Jane Doe", fromAddress.Address.Name)
|
|
assert.Equal(t, "jane@example.com", fromAddress.Address.Address)
|
|
})
|
|
t.Run("yaml", func(t *testing.T) {
|
|
var fromAddress FromAddress
|
|
assert.NoError(t, yaml.Unmarshal([]byte(`"Jane Doe <jane@example.com>"`), &fromAddress))
|
|
assert.Equal(t, "Jane Doe", fromAddress.Address.Name)
|
|
assert.Equal(t, "jane@example.com", fromAddress.Address.Address)
|
|
})
|
|
}
|