-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated sendgrid binding to add the option to add names for the to an… (
#1751) * Updated sendgrid binding to add the option to add names for the to and from addresses. This commit relates to #1749 Signed-off-by: Adam Rahja <[email protected]> * Updated sendgrid binding from code suggestion. Signed-off-by: Adam Rahja <[email protected]>
- Loading branch information
Showing
2 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,21 @@ func TestParseMetadata(t *testing.T) { | |
assert.Equal(t, "hello", sgMeta.Subject) | ||
}) | ||
} | ||
|
||
func TestParseMetadataWithOptionalNames(t *testing.T) { | ||
logger := logger.NewLogger("test") | ||
|
||
t.Run("Has correct metadata", func(t *testing.T) { | ||
m := bindings.Metadata{} | ||
m.Properties = map[string]string{"apiKey": "123", "emailFrom": "[email protected]", "emailFromName": "test 1", "emailTo": "[email protected]", "emailToName": "test 2", "subject": "hello"} | ||
r := SendGrid{logger: logger} | ||
sgMeta, err := r.parseMetadata(m) | ||
assert.Nil(t, err) | ||
assert.Equal(t, "123", sgMeta.APIKey) | ||
assert.Equal(t, "[email protected]", sgMeta.EmailFrom) | ||
assert.Equal(t, "test 1", sgMeta.EmailFromName) | ||
assert.Equal(t, "[email protected]", sgMeta.EmailTo) | ||
assert.Equal(t, "test 2", sgMeta.EmailToName) | ||
assert.Equal(t, "hello", sgMeta.Subject) | ||
}) | ||
} |