-
Notifications
You must be signed in to change notification settings - Fork 92
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
test: resultx ut #738
test: resultx ut #738
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov ReportPatch coverage has no change and project coverage change:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## master #738 +/- ##
==========================================
+ Coverage 36.67% 37.07% +0.39%
==========================================
Files 247 248 +1
Lines 26157 26217 +60
==========================================
+ Hits 9594 9720 +126
+ Misses 15518 15422 -96
- Partials 1045 1075 +30 ☔ View full report in Codecov by Sentry. |
* limitations under the License. | ||
*/ | ||
|
||
package resultx |
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.
加点异常case吧,比如有 ds 的时候,也有 InsertID 应该是什么返回。
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.
这个代码没法加异常呀,这个确定不了...,对这个不太懂,我理解的是这个覆盖率能达到就好
func TestEmptyResult(t *testing.T) { | ||
res := New() | ||
defer Drain(res) | ||
assert.Empty(t, res) | ||
dataset, err := res.Dataset() | ||
assert.NoError(t, err) | ||
assert.Empty(t, dataset) | ||
affected, err := res.RowsAffected() | ||
assert.NoError(t, err) | ||
assert.Equal(t, affected, uint64(0)) | ||
id, err := res.LastInsertId() | ||
assert.NoError(t, err) | ||
assert.Equal(t, id, uint64(0)) | ||
} | ||
|
||
func TestSlimResult(t *testing.T) { | ||
res := New(WithLastInsertID(1)) | ||
defer Drain(res) | ||
assert.NotEmpty(t, res) | ||
dataset, err := res.Dataset() | ||
assert.NoError(t, err) | ||
assert.Empty(t, dataset) | ||
affected, err := res.RowsAffected() | ||
assert.NoError(t, err) | ||
assert.Equal(t, affected, uint64(0)) | ||
id, err := res.LastInsertId() | ||
assert.NoError(t, err) | ||
assert.Equal(t, id, uint64(1)) | ||
} | ||
|
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.
方便的话也加点注释吧,其实 Empty 和 Slim 是 Exec 的时候执行的,Empty 更像创表,等行为,Slim 像 insert,update等行为。
What this PR does:
Which issue(s) this PR fixes:
Fixes #728
Special notes for your reviewer:
Does this PR introduce a user-facing change?: