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

Add getTotalCount() tests for sorting parameters #1758

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add getTotalCount() test on empty result for list() method
This is for consistency with the test for the criteria.
  • Loading branch information
darxriggs committed Oct 1, 2023
commit 0df9ad7c753fe74605d7fe5fd373608843a6a631
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ package grails.gorm.tests

class PagedResultSpec extends GormDatastoreSpec {

void "Test that a getTotalCount will return 0 on empty result from the list() method"() {
when:"A query is executed that returns no results"
def results = Person.list(max:1)

then:
results.size() == 0
results.totalCount == 0
}

void "Test that a paged result list is returned from the list() method with pagination params"() {
given:"Some people"
createPeople()
Expand All @@ -17,16 +26,17 @@ class PagedResultSpec extends GormDatastoreSpec {
results.totalCount == 6
}

void "Test that a getTotalCount will return 0 on empty result"() {
void "Test that a getTotalCount will return 0 on empty result from the criteria"() {
given:"Some people"
createPeople()

when:"A query is executed that returns no results"
def results = Person.createCriteria().list(max: 1) {
eq 'lastName', 'NotFound'
def results = Person.createCriteria().list(max: 1) {
eq 'lastName', 'NotFound'
}

then:
results.size() == 0
results.totalCount == 0
}

Expand Down