New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement mailgun provider #207
feat: Implement mailgun provider #207
Conversation
Codecov Report
@@ Coverage Diff @@
## development #207 +/- ##
===============================================
+ Coverage 45.30% 46.18% +0.87%
===============================================
Files 27 28 +1
Lines 1342 1375 +33
===============================================
+ Hits 608 635 +27
- Misses 646 649 +3
- Partials 88 91 +3
Continue to review full report at Codecov.
|
internal/mail/mailgun.go
Outdated
return err | ||
} | ||
|
||
if notGood(resp.StatusCode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只須判斷200就好,我看 mailgun api 文件也是只有 200 才算成功。
200以外的不要判斷,避免它新增了其他含意 statu code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好啊 這段是我從他的go sdk抄過來的 因為我沒真的打過也不知道會回哪些
我再改一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改好了
internal/mail/mailgun.go
Outdated
} | ||
} | ||
return true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只須判斷 200 就好,所以這個該移除
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改好了
"testing" | ||
) | ||
|
||
func TestNewMailProvider_WithSMTP(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我記得不是已經有一個 smtp_test.go 了嗎?
不需要特別為了 mail 去寫重複的測試
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個部份是我個人的想法 我有在PR message 提到。
差別就是 smtp_test 是 call NewMailProvider() mailgun_test 是 call newMailgunProvider()
這邊其實也沒有所謂的對錯 單純就是 test 要寫在哪裡
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是這樣的話我就沒有意見,我覺得都可以
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我也覺得都可以XD
所以先做上來 蒐集大家的想法
} | ||
} | ||
|
||
func TestNewMailProvider_WithMailgun(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
👏 解決掉的 issue / Resolved Issues
📝 相關的 issue / Related Issues
⛏ 變更內容 / Details of Changes
mail.go
- 新增 case 呼叫新增 mailgun providermail_test.go
- 新增兩個測試關於NewMailProvider()
mailgun.go
- mailgun provider 實作mailgun_test.go
- 測試 mailgun provider其他
關於 mailgun provider test,我是用自己起一個 https server 的作法去測,這樣 Send 成功以及失敗就都可以被測到。
測試成功的部份有在 handler function 裡面對 request 做一些檢查,如果覺得這個部分不需要,其實也可以拿掉。
另外我新增了
mail_test.go
的想法是覺得NewMailProvider()
裡面的邏輯 應該是要在這個 test file 裡面驗證。