-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_test.go
More file actions
42 lines (33 loc) · 1.09 KB
/
Copy pathadmin_test.go
File metadata and controls
42 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package gadm
import (
"io"
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/leonelquinteros/gotext.v1"
)
func TestPager(t *testing.T) {
is := assert.New(t)
r := Result{Query: &Query{Page: 1, PageSize: 10, default_page_size: 10}, Total: 100}
is.Equal(10, r.NumPages())
ps := r.PageItems()
is.Len(ps, 11)
is.NotEmpty(r.PagerHtml())
r = Result{Query: &Query{Page: 5, PageSize: 10}, Total: 100}
r = Result{Query: &Query{Page: 9, PageSize: 10}, Total: 100}
r = Result{Query: &Query{Page: 0, PageSize: 10}, Total: 4}
r = Result{Query: &Query{Page: 0, PageSize: 10}, Total: 11}
r = Result{Query: &Query{Page: 1, PageSize: 10}, Total: 11}
r = Result{Query: &Query{Page: 0, PageSize: 1}, Total: 1}
}
func TestText(t *testing.T) {
is := assert.New(t)
gotext.Configure("translations", "zh_Hant_TW", "admin")
is.Equal("首頁", gotext.Get("Home"))
is.Equal(`檔案 "foo" 已經存在。`, gotext.Get(`File "%s" already exists.`, "foo"))
}
func TestGen(t *testing.T) {
is := assert.New(t)
g := NewGenerator("sqlite:examples/sqla/sample.db")
err := g.Run(nil, io.Discard)
is.Nil(err)
}