From 29ac961c10694864b6d03569697c4c6d68bd6108 Mon Sep 17 00:00:00 2001 From: Steeve Chailloux Date: Mon, 9 Nov 2015 19:39:47 -0600 Subject: [PATCH 1/3] fix postgres syntax error during migration --- migration/migration.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/migration.go b/migration/migration.go index 2206569c..1591bc50 100644 --- a/migration/migration.go +++ b/migration/migration.go @@ -104,7 +104,7 @@ func (m *Migration) addOrUpdateRecord(name, status string) error { o := orm.NewOrm() if status == "down" { status = "rollback" - p, err := o.Raw("update migrations set `status` = ?, `rollback_statements` = ?, `created_at` = ? where name = ?").Prepare() + p, err := o.Raw("update migrations set status = ?, rollback_statements = ?, created_at = ? where name = ?").Prepare() if err != nil { return nil } @@ -112,7 +112,7 @@ func (m *Migration) addOrUpdateRecord(name, status string) error { return err } status = "update" - p, err := o.Raw("insert into migrations(`name`, `created_at`, `statements`, `status`) values(?,?,?,?)").Prepare() + p, err := o.Raw("insert into migrations(name, created_at, statements, status) values(?,?,?,?)").Prepare() if err != nil { return err } From 83696a40f6d37af56caadde97b90032937817237 Mon Sep 17 00:00:00 2001 From: nkbai Date: Fri, 20 Nov 2015 11:18:45 +0800 Subject: [PATCH 2/3] fix #1433 --- memzipfile.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/memzipfile.go b/memzipfile.go index cc5e3851..33152ba6 100644 --- a/memzipfile.go +++ b/memzipfile.go @@ -109,7 +109,7 @@ type memFileInfo struct { // Name returns the compressed filename. func (fi *memFileInfo) Name() string { - return fi.Name() + return fi.FileInfo.Name() } // Size returns the raw file content size, not compressed size. @@ -119,7 +119,7 @@ func (fi *memFileInfo) Size() int64 { // Mode returns file mode. func (fi *memFileInfo) Mode() os.FileMode { - return fi.Mode() + return fi.FileInfo.Mode() } // ModTime returns the last modified time of raw file. @@ -129,7 +129,7 @@ func (fi *memFileInfo) ModTime() time.Time { // IsDir returns the compressing file is a directory or not. func (fi *memFileInfo) IsDir() bool { - return fi.IsDir() + return fi.FileInfo.IsDir() } // return nil. implement the os.FileInfo interface method. From 5e915cb614c1e8590c146a398cf08638de797b96 Mon Sep 17 00:00:00 2001 From: nkbai Date: Tue, 24 Nov 2015 14:55:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?controller=5Ftest.go=20=E6=97=A2=E7=84=B6?= =?UTF-8?q?=E5=8F=ABtest=EF=BC=8C=E9=82=A3=E5=B0=B1=E6=8C=89=E7=85=A7go?= =?UTF-8?q?=E7=9A=84=E8=A7=84=E5=88=99=E8=BF=9B=E8=A1=8Ctest=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller_test.go | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/controller_test.go b/controller_test.go index 15938cdc..4156bd29 100644 --- a/controller_test.go +++ b/controller_test.go @@ -17,42 +17,48 @@ package beego import ( "fmt" "github.com/astaxie/beego/context" + "testing" ) -func ExampleGetInt() { +func TestGetInt(t *testing.T) { i := &context.BeegoInput{Params: map[string]string{"age": "40"}} ctx := &context.Context{Input: i} ctrlr := Controller{Ctx: ctx} val, _ := ctrlr.GetInt("age") - fmt.Printf("%T", val) - //Output: int + + if (val != 40) { + t.Errorf("TestGetInt expect 40,get %T,%v", val, val) + } } -func ExampleGetInt8() { +func TestGetInt8(t *testing.T) { i := &context.BeegoInput{Params: map[string]string{"age": "40"}} ctx := &context.Context{Input: i} ctrlr := Controller{Ctx: ctx} val, _ := ctrlr.GetInt8("age") - fmt.Printf("%T", val) + if val != 40 { + t.Errorf("TestGetInt8 expect 40,get %T,%v", val, val) + } //Output: int8 } -func ExampleGetInt16() { +func TestGetInt16(t *testing.T) { i := &context.BeegoInput{Params: map[string]string{"age": "40"}} ctx := &context.Context{Input: i} ctrlr := Controller{Ctx: ctx} val, _ := ctrlr.GetInt16("age") - fmt.Printf("%T", val) - //Output: int16 + if val != 40 { + t.Errorf("TestGetInt16 expect 40,get %T,%v", val, val) + } } -func ExampleGetInt32() { +func TestGetInt32(t *testing.T) { i := &context.BeegoInput{Params: map[string]string{"age": "40"}} ctx := &context.Context{Input: i} @@ -60,16 +66,19 @@ func ExampleGetInt32() { val, _ := ctrlr.GetInt32("age") fmt.Printf("%T", val) - //Output: int32 + if val != 40 { + t.Errorf("TestGetInt32 expect 40,get %T,%v", val, val) + } } -func ExampleGetInt64() { +func TestGetInt64(t *testing.T) { i := &context.BeegoInput{Params: map[string]string{"age": "40"}} ctx := &context.Context{Input: i} ctrlr := Controller{Ctx: ctx} val, _ := ctrlr.GetInt64("age") - fmt.Printf("%T", val) - //Output: int64 + if val != 40 { + t.Errorf("TestGeetInt64 expect 40,get %T,%v", val, val) + } }