diff options
author | Joe Mooring <[email protected]> | 2024-06-08 06:45:58 -0700 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-06-08 18:35:14 +0200 |
commit | cba2de6ec91bc60735600ec068c018d9f53ee5ca (patch) | |
tree | 44fed71260583886ddc0ea2edaaa4c87511152bb /resources | |
parent | 9c4e14eb4f890d2a3caad2dcd9209609b7274914 (diff) | |
download | hugo-cba2de6ec91bc60735600ec068c018d9f53ee5ca.tar.gz hugo-cba2de6ec91bc60735600ec068c018d9f53ee5ca.zip |
resources/page: Let GroupByParam return nil instead of error
Closes #12578
Diffstat (limited to 'resources')
-rw-r--r-- | resources/page/pagegroup.go | 2 | ||||
-rw-r--r-- | resources/page/pagegroup_test.go | 13 |
2 files changed, 3 insertions, 12 deletions
diff --git a/resources/page/pagegroup.go b/resources/page/pagegroup.go index 7129fae17..081708d62 100644 --- a/resources/page/pagegroup.go +++ b/resources/page/pagegroup.go @@ -205,7 +205,7 @@ func (p Pages) GroupByParam(key string, order ...string) (PagesGroup, error) { } } if !tmp.IsValid() { - return nil, errors.New("there is no such param") + return nil, nil } for _, e := range p { diff --git a/resources/page/pagegroup_test.go b/resources/page/pagegroup_test.go index 91f05b24a..5008aa720 100644 --- a/resources/page/pagegroup_test.go +++ b/resources/page/pagegroup_test.go @@ -142,15 +142,6 @@ func TestGroupByCalledWithEmptyPages(t *testing.T) { } } -func TestGroupByParamCalledWithUnavailableKey(t *testing.T) { - t.Parallel() - pages := preparePageGroupTestPages(t) - _, err := pages.GroupByParam("UnavailableKey") - if err == nil { - t.Errorf("GroupByParam should return an error but didn't") - } -} - func TestReverse(t *testing.T) { t.Parallel() pages := preparePageGroupTestPages(t) @@ -256,8 +247,8 @@ func TestGroupByParamCalledWithUnavailableParam(t *testing.T) { t.Parallel() pages := preparePageGroupTestPages(t) _, err := pages.GroupByParam("unavailable_param") - if err == nil { - t.Errorf("GroupByParam should return an error but didn't") + if err != nil { + t.Errorf("GroupByParam returned an error when it shouldn't") } } |