nginx-proxy-manager-zh/backend/internal/model/pageinfo_test.go

32 lines
600 B
Go
Raw Normal View History

2023-07-28 02:10:44 -04:00
package model
import (
"testing"
"github.com/stretchr/testify/assert"
2023-11-07 18:57:15 -05:00
"go.uber.org/goleak"
2023-07-28 02:10:44 -04:00
)
func TestPageInfoGetSort(t *testing.T) {
2023-11-07 18:57:15 -05:00
// goleak is used to detect goroutine leaks
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("testing.tRunner.func1"))
2023-07-28 02:10:44 -04:00
t.Parallel()
pi := PageInfo{}
def := Sort{
Field: "name",
Direction: "asc",
}
defined := Sort{
Field: "nickname",
Direction: "desc",
}
// default
sort := pi.GetSort(def)
assert.Equal(t, sort, []Sort{def})
// defined
pi.Sort = []Sort{defined}
sort = pi.GetSort(def)
assert.Equal(t, sort, []Sort{defined})
}