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

fix: 修正單元測試程式,修正覆蓋率問題與通過 mongoose v7 版本 #58

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

trylovetom
Copy link
Collaborator

@trylovetom trylovetom commented Sep 19, 2023

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

前景提要
我觀察到 egg-mongoose 升級至 v4 版本 PR #54後,測試覆蓋率雖然高達 100%,但只測試到 lib/filterURLPassword.js,其他 test case 被跳過了,以下為連結與截圖:
https://app.codecov.io/gh/eggjs/egg-mongoose/pull/57/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eggjs
image

修正方向

  1. test case 中的 function*yield 改為 asyncawait 語法,修改後可正常測試,以下為截圖。
image
  1. mongoose 降級版本為 v5 版本,因為目前 test case 並沒有升級至 v7 版本,像是:
image image image image

討論
建議將 mongosse 加入 peerDependenciesdevDependencies,讓用戶自行選擇版本,因為 egg-mongoose 只負責掛載。

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage has no change and project coverage change: -1.16% ⚠️

Comparison is base (a0425a4) 100.00% compared to head (7762841) 98.84%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##            master      #58      +/-   ##
===========================================
- Coverage   100.00%   98.84%   -1.16%     
===========================================
  Files            1        6       +5     
  Lines           14      173     +159     
  Branches         4       36      +32     
===========================================
+ Hits            14      171     +157     
- Misses           0        2       +2     
Files Changed Coverage Δ
lib/mongoose.js 98.40% <ø> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fengmk2
Copy link
Member

fengmk2 commented Sep 20, 2023

#54 发布的是一个 major 版本,确实它的单测有问题,需要修复,我们应该修复单测,而不是将 mongoose 的版本降级回去。
egg-mongoose v3 还是可以继续使用。

1 similar comment
@fengmk2

This comment was marked as duplicate.

@trylovetom
Copy link
Collaborator Author

trylovetom commented Sep 20, 2023

#54 发布的是一个 major 版本,确实它的单测有问题,需要修复,我们应该修复单测,而不是将 mongoose 的版本降级回去。 egg-mongoose v3 还是可以继续使用。

@fengmk2 單元測試我會再修正,關於 mongoose 版本,看看要不要參考一下我提供的建議:

將 mongosse 加入 peerDependencies 與 devDependencies,讓用戶自行選擇版本,因為 egg-mongoose 只負責掛載。
這樣好處是,不用再手動更新 mongoose 版本

@trylovetom trylovetom changed the title fix: 修正測試程式覆蓋率問題,與修改 mongoose 版本至原本的 v5 版本(目前的測試程式無法通過) fix: 修正測試程式覆蓋率問題,與修改單元測試以通過 mongoose v7 版本 Sep 21, 2023
@trylovetom trylovetom changed the title fix: 修正測試程式覆蓋率問題,與修改單元測試以通過 mongoose v7 版本 fix: 修正單元測試程式,修正覆蓋率問題與通過 mongoose v7 版本 Sep 21, 2023
@trylovetom
Copy link
Collaborator Author

@fengmk2 已修正,在麻煩確認一下,謝謝

Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

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

+1

@fengmk2 fengmk2 merged commit 5b2b3f9 into eggjs:master Sep 21, 2023
6 of 7 checks passed
fengmk2 pushed a commit that referenced this pull request Sep 21, 2023
[skip ci]

## [4.0.1](v4.0.0...v4.0.1) (2023-09-21)

### Bug Fixes

* use eggjs/github-actions to release ([4d95371](4d95371))
* 修正單元測試程式,修正覆蓋率問題與通過 mongoose v7 版本 ([#58](#58)) ([5b2b3f9](5b2b3f9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants