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

test: resultx ut #738

Merged
merged 1 commit into from
Aug 24, 2023
Merged

test: resultx ut #738

merged 1 commit into from
Aug 24, 2023

Conversation

baerwang
Copy link
Contributor

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?:

NONE

@sonarcloud
Copy link

sonarcloud bot commented Aug 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: +0.39% 🎉

Comparison is base (3ea47a2) 36.67% compared to head (09a2709) 37.07%.

❗ 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     

see 4 files with indirect coverage changes

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

@dongzl dongzl added the test Unit test. label Aug 14, 2023
@dongzl dongzl added this to the 0.2.0 milestone Aug 14, 2023
* limitations under the License.
*/

package resultx
Copy link
Contributor

Choose a reason for hiding this comment

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

加点异常case吧,比如有 ds 的时候,也有 InsertID 应该是什么返回。

Copy link
Contributor Author

@baerwang baerwang Aug 21, 2023

Choose a reason for hiding this comment

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

这个代码没法加异常呀,这个确定不了...,对这个不太懂,我理解的是这个覆盖率能达到就好

Comment on lines +32 to +61
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))
}

Copy link
Contributor

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等行为。

@dongzl dongzl merged commit 9cbe6a1 into arana-db:master Aug 24, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Unit test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Test] add unit test for /arana/pkg/resultx/... package.
5 participants