Finished controller tests.
This commit is contained in:
parent
40f0d7251d
commit
65a9ac9fa5
3 changed files with 113 additions and 14 deletions
|
|
@ -8,24 +8,24 @@ import (
|
|||
)
|
||||
|
||||
func TestNewPager(t *testing.T) {
|
||||
ctx := newContext("/")
|
||||
ctx, _ := newContext("/")
|
||||
pgr := NewPager(ctx, 10)
|
||||
assert.Equal(t, 10, pgr.ItemsPerPage)
|
||||
assert.Equal(t, 1, pgr.Page)
|
||||
assert.Equal(t, 0, pgr.Items)
|
||||
assert.Equal(t, 0, pgr.Pages)
|
||||
|
||||
ctx = newContext(fmt.Sprintf("/abc?%s=%d", PageQueryKey, 2))
|
||||
ctx, _ = newContext(fmt.Sprintf("/abc?%s=%d", PageQueryKey, 2))
|
||||
pgr = NewPager(ctx, 10)
|
||||
assert.Equal(t, 2, pgr.Page)
|
||||
|
||||
ctx = newContext(fmt.Sprintf("/abc?%s=%d", PageQueryKey, -2))
|
||||
ctx, _ = newContext(fmt.Sprintf("/abc?%s=%d", PageQueryKey, -2))
|
||||
pgr = NewPager(ctx, 10)
|
||||
assert.Equal(t, 1, pgr.Page)
|
||||
}
|
||||
|
||||
func TestPager_SetItems(t *testing.T) {
|
||||
ctx := newContext("/")
|
||||
ctx, _ := newContext("/")
|
||||
pgr := NewPager(ctx, 20)
|
||||
pgr.SetItems(100)
|
||||
assert.Equal(t, 100, pgr.Items)
|
||||
|
|
@ -33,7 +33,7 @@ func TestPager_SetItems(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPager_IsBeginning(t *testing.T) {
|
||||
ctx := newContext("/")
|
||||
ctx, _ := newContext("/")
|
||||
pgr := NewPager(ctx, 20)
|
||||
pgr.Pages = 10
|
||||
assert.True(t, pgr.IsBeginning())
|
||||
|
|
@ -44,7 +44,7 @@ func TestPager_IsBeginning(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPager_IsEnd(t *testing.T) {
|
||||
ctx := newContext("/")
|
||||
ctx, _ := newContext("/")
|
||||
pgr := NewPager(ctx, 20)
|
||||
pgr.Pages = 10
|
||||
assert.False(t, pgr.IsEnd())
|
||||
|
|
@ -55,7 +55,7 @@ func TestPager_IsEnd(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPager_GetOffset(t *testing.T) {
|
||||
ctx := newContext("/")
|
||||
ctx, _ := newContext("/")
|
||||
pgr := NewPager(ctx, 20)
|
||||
assert.Equal(t, 0, pgr.GetOffset())
|
||||
pgr.Page = 2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue