nginx-proxy-manager-zh/backend/internal/model/pageinfo_test.go
2023-11-08 09:57:15 +10:00

32 lines
600 B
Go

package model
import (
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/goleak"
)
func TestPageInfoGetSort(t *testing.T) {
// goleak is used to detect goroutine leaks
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("testing.tRunner.func1"))
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})
}