Last active
August 29, 2015 14:17
-
-
Save mackee/36c208f6909eefd0a7e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mizar | |
import ( | |
"testing" | |
) | |
type Table1 struct { | |
Id DBInteger `db:"id"` | |
Name DBVarchar `db:"name"` | |
Description DBVarchar | |
} | |
func (t1 Table1) TableName() string { | |
return "t1" | |
} | |
func TestSearchFullColumn(t *testing.T) { | |
mi := &Mizar{} | |
rs, err := mi.Search( | |
Table1{ | |
Id: NewDBInteger(1), | |
Name: NewDBVarchar("hogehoge"), | |
Description: NewDBVarchar("barbar"), | |
}, | |
) | |
if err != nil { | |
t.Error("unexpected Search() error:", err) | |
} | |
q, args, err := rs.ToSql() | |
if err != nil { | |
t.Error("unexpected ToSql() error:", err) | |
} | |
if q != "SELECT * FROM t1 WHERE id = ? AND name = ?" { | |
t.Error("unexpected query:", q) | |
} | |
if args[0].(int64) != 1 { | |
t.Error("unexpected args[0]:", args[0]) | |
} | |
if args[1].(string) != "hogehoge" { | |
t.Error("unexpected args[1]:", args[1]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment