2024-09-21 16:20:19 +01:00
|
|
|
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))
|
2025-01-10 23:52:43 +00:00
|
|
|
assert.Equal(t, "Jane Doe", fromAddress.Name)
|
|
|
|
assert.Equal(t, "jane@example.com", fromAddress.Address)
|
2024-09-21 16:20:19 +01:00
|
|
|
})
|
|
|
|
t.Run("yaml", func(t *testing.T) {
|
|
|
|
var fromAddress FromAddress
|
|
|
|
assert.NoError(t, yaml.Unmarshal([]byte(`"Jane Doe <jane@example.com>"`), &fromAddress))
|
2025-01-10 23:52:43 +00:00
|
|
|
assert.Equal(t, "Jane Doe", fromAddress.Name)
|
|
|
|
assert.Equal(t, "jane@example.com", fromAddress.Address)
|
2024-09-21 16:20:19 +01:00
|
|
|
})
|
|
|
|
}
|