Skip to content
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

Merged

Conversation

SivWatt
Copy link
Contributor

@SivWatt SivWatt commented May 14, 2021

👏 解決掉的 issue / Resolved Issues

📝 相關的 issue / Related Issues

⛏ 變更內容 / Details of Changes

  • mail.go - 新增 case 呼叫新增 mailgun provider
  • mail_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 裡面驗證。

@codecov-commenter
Copy link

codecov-commenter commented May 14, 2021

Codecov Report

Merging #207 (6c2c208) into development (5111844) will increase coverage by 0.87%.
The diff coverage is 81.81%.

Impacted file tree graph

@@               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     
Impacted Files Coverage Δ
internal/mail/mailgun.go 80.64% <80.64%> (ø)
internal/mail/mail.go 58.33% <100.00%> (+8.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5111844...6c2c208. Read the comment docs.

return err
}

if notGood(resp.StatusCode) {
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好啊 這段是我從他的go sdk抄過來的 因為我沒真的打過也不知道會回哪些
我再改一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改好了

}
}
return true
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只須判斷 200 就好,所以這個該移除

Copy link
Contributor Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我記得不是已經有一個 smtp_test.go 了嗎?
不需要特別為了 mail 去寫重複的測試

Copy link
Contributor Author

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 要寫在哪裡

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果是這樣的話我就沒有意見,我覺得都可以

Copy link
Contributor Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@y2468101216
Copy link
Collaborator

LGTM
@PichuChen

Copy link
Member

@PichuChen PichuChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@PichuChen PichuChen merged commit c035425 into Ptt-official-app:development May 18, 2021
@SivWatt SivWatt deleted the feature/#197-mailgun_provider branch May 18, 2021 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[主線] [PTT] 實作Mail Provider - mailgun api
4 participants