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

Issue 90 unittest #95

Conversation

fanhousanbu
Copy link
Collaborator

Which changes (Bug/Feature):

Fixes #90 github action 集成单测

Special notes for reviewers:

1. 单测覆盖率由codecov提供,待项目合并后会在codecov申请项目授权以加载徽章
2. 由于internal包中的model.go会自动运行init方法,导致单测运行时会加载数据库依赖(这就导致单测永远无法通过),需要考虑如何解除两者耦合

fanhousanbu and others added 5 commits March 1, 2022 22:12
Rename codecov to codecov.yml

Update codecov.yml

Update codecov.yml

wip-github-action

wip-github-action

remove tests under internal package
从internal目录下移除测试项目,因为在此包里的单测运行时会依赖外部环境(model.init()方法导致);

issue 90; 修改go ver为1.17

remove test.yml

make a failed case

Revert "make a failed case"

This reverts commit 9f3a7dd.

t#
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2022

Codecov Report

❗ No coverage uploaded for pull request base (v1.5.0-feat-app-refactor@0897f1a). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                     Coverage Diff                     @@
##             v1.5.0-feat-app-refactor      #95   +/-   ##
===========================================================
  Coverage                            ?   42.23%           
===========================================================
  Files                               ?        4           
  Lines                               ?      161           
  Branches                            ?        0           
===========================================================
  Hits                                ?       68           
  Misses                              ?       91           
  Partials                            ?        2           

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 0897f1a...070dc1b. Read the comment docs.

@fanhousanbu fanhousanbu requested review from colynn and sampsonye March 5, 2022 12:34
Copy link
Member

@colynn colynn left a comment

Choose a reason for hiding this comment

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

internal/core/notification/notify_test.go 是无效的test吗,为什么需要移除  @fanhousanbu

@fanhousanbu
Copy link
Collaborator Author

internal/core/notification/notify_test.go 是无效的test吗,为什么需要移除  @fanhousanbu

原因:#95 (comment)
不知道有没有什么方案可以跳过init()方法

@fanhousanbu fanhousanbu requested a review from colynn March 8, 2022 12:43
@colynn
Copy link
Member

colynn commented Mar 10, 2022

internal/core/notification/notify_test.go 是无效的test吗,为什么需要移除  @fanhousanbu

原因:#95 (comment) 不知道有没有什么方案可以跳过init()方法

是否可以将model的init 独立为db的pkg, 将init 转为具体的函数调用

Copy link
Member

@colynn colynn left a comment

Choose a reason for hiding this comment

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

见comments

@fanhousanbu
Copy link
Collaborator Author

  1. 通过判断os.args来绕过单测时对具体环境的依赖
  2. 还原之前移除的单测,并增加httpmock

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.

新增代码 单元测试样例
3 participants