Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Mar 14, 2014
1 parent df3bda5 commit 1c81f52
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
28 changes: 18 additions & 10 deletions base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,36 +331,44 @@ func update(engine *Engine, t *testing.T) {
panic(err)
}

cnt, err = engine.Insert(&Article{0, "1", "2", "3", "4", "5", 2})
defer func() {
err = engine.DropTables(&Article{})
if err != nil {
t.Error(err)
panic(err)
}
}()

a := &Article{0, "1", "2", "3", "4", "5", 2}
cnt, err = engine.Insert(a)
if err != nil {
t.Error(err)
panic(err)
}

if cnt != 1 {
err = errors.New("insert not returned 1")
err = errors.New(fmt.Sprintf("insert not returned 1 but %d", cnt))
t.Error(err)
panic(err)
return
}

cnt, err = engine.Id(1).Update(&Article{Name: "6"})
if err != nil {
if a.Id == 0 {
err = errors.New("insert returned id is 0")
t.Error(err)
panic(err)
}

if cnt != 1 {
err = errors.New("update not returned 1")
cnt, err = engine.Id(a.Id).Update(&Article{Name: "6"})
if err != nil {
t.Error(err)
panic(err)
return
}

err = engine.DropTables(&Article{})
if err != nil {
if cnt != 1 {
err = errors.New(fmt.Sprintf("insert not returned 1 but %d", cnt))
t.Error(err)
panic(err)
return
}
}

Expand Down
13 changes: 7 additions & 6 deletions xorm/reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package main
import (
"bytes"
"fmt"
_ "github.com/bylevel/pq"
"github.com/dvirsky/go-pylog/logging"
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
_ "github.com/ziutek/mymysql/godrv"
"io/ioutil"
"os"
"path"
"path/filepath"
"strconv"
"strings" //[SWH|+]
"text/template"

"github.com/dvirsky/go-pylog/logging"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
"github.com/lunny/xorm"
_ "github.com/mattn/go-sqlite3"
_ "github.com/ziutek/mymysql/godrv"
)

var CmdReverse = &Command{
Expand Down

0 comments on commit 1c81f52

Please sign in to comment.