本文整理汇总了Golang中github.com/rzajac/goassert/assert.Tspy.Failed方法的典型用法代码示例。如果您正苦于以下问题:Golang Tspy.Failed方法的具体用法?Golang Tspy.Failed怎么用?Golang Tspy.Failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rzajac/goassert/assert.Tspy
的用法示例。
在下文中一共展示了Tspy.Failed方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Test_LoadFixture
func Test_LoadFixture(t *testing.T) {
TruncateTable("test_1")
myT := new(assert.Tspy)
LoadFixture(myT, "/not/existing/fixture")
if !myT.Failed() {
t.Fatalf("Expected error loading not existing fixture")
}
myT = new(assert.Tspy)
LoadFixture(myT, "fixtures/fixture.sql")
if myT.Failed() {
t.Fatalf("Did not expect any error: %s", myT.GetMsg(0))
}
rows, res, err := dbcon.Query("SELECT * FROM test_1 ORDER BY Field ASC")
if err != nil {
t.Fatal("Did not expect error: " + err.Error())
}
if len(rows) != 3 {
t.Fatal("Expected three rows in the database.")
}
for idx, row := range rows {
if idx != row.Int(res.Map("Field")) {
t.Fatalf("Expected row %d Field to be equal to %d", idx, row.Int(res.Map("Field")))
}
}
}
示例2: Test_ErrorCode
func Test_ErrorCode(t *testing.T) {
err1 := new(mysql.Error)
err1.Code = 123
err1.Msg = []byte("Test1")
myT := new(assert.Tspy)
ErrorCode(myT, err1, 1234)
if !myT.Failed() {
t.Fatal("Expected ErrorCode to fail.")
}
myT = new(assert.Tspy)
ErrorCode(myT, err1, 123)
if myT.Failed() {
t.Fatal("Expected ErrorCode not to fail.")
}
err2 := errors.New("Test1")
myT = new(assert.Tspy)
ErrorCode(myT, err2, 1234)
if !myT.Failed() {
t.Fatal("Expected ErrorCode to fail.")
}
myT = new(assert.Tspy)
ErrorCode(myT, nil, 1234)
if !myT.Failed() {
t.Fatal("Expected ErrorCode to fail.")
}
}
示例3: Test_RowDoesNotExists
func Test_RowDoesNotExists(t *testing.T) {
// Row exists
myT := new(assert.Tspy)
RowDoesNotExists(myT, "test_1", "Id", 12)
if !myT.Failed() {
t.Fatal("Expected RowExists to fail.")
}
// Row does not exist
myT = new(assert.Tspy)
RowDoesNotExists(myT, "test_1", "Id", 1234)
if myT.Failed() {
t.Fatal("Expected RowExists not to fail.")
}
// Row does not exist
myT = new(assert.Tspy)
RowDoesNotExists(myT, "test_1s", "Id", "xyz")
if myT.Failed() {
t.Fatal("Expected RowExists not to fail.")
}
// Row exists
myT = new(assert.Tspy)
RowDoesNotExists(myT, "test_1s", "Id", "abc")
if !myT.Failed() {
t.Fatal("Expected RowExists to fail.")
}
}
示例4: Test_TableCount
func Test_TableCount(t *testing.T) {
myT := new(assert.Tspy)
TableCount(myT, 100)
if !myT.Failed() {
t.Fatal("Expected TableCount to fail.")
}
myT = new(assert.Tspy)
TableCount(myT, 6)
if myT.Failed() {
t.Fatal("Expected TableCount not to fail.")
}
}
示例5: Test_RowExists
func Test_RowExists(t *testing.T) {
// Prepare test
err := InsertToTestTable("test_1", 12, 123)
if err != nil {
t.Fatal("Did not expect database error: " + err.Error())
}
// Row does not exist
myT := new(assert.Tspy)
RowExists(myT, "test_1", "Id", 111)
if !myT.Failed() {
t.Fatal("Expected RowExists to fail.")
}
// Row exists
myT = new(assert.Tspy)
RowExists(myT, "test_1", "Id", 12)
if myT.Failed() {
t.Fatal("Expected RowExists not to fail.")
}
// Test string keys - prepare table and data
createSql := `
CREATE TABLE %s (
Id char(5) NOT NULL,
Field int(11) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=%s`
_, _, err = dbcon.Query(createSql, "test_1s", TEST_DB_ENGINE)
if err != nil {
t.Fatal("Did not expect database error: " + err.Error())
}
insertSql := fmt.Sprintf("INSERT INTO test_1s VALUES ('abc', 1)")
_, _, err = dbcon.Query(insertSql)
if err != nil {
t.Fatal("Did not expect database error: " + err.Error())
}
// Row does not exist
myT = new(assert.Tspy)
RowExists(myT, "test_1s", "Id", "xyz")
if !myT.Failed() {
t.Fatal("Expected RowExists to fail.")
}
// Row exists
myT = new(assert.Tspy)
RowExists(myT, "test_1s", "Id", "abc")
if myT.Failed() {
t.Fatal("Expected RowExists not to fail.")
}
}
示例6: Test_TableDoesNotExists
func Test_TableDoesNotExists(t *testing.T) {
myT := new(assert.Tspy)
TableDoesNotExists(myT, "not_existing_table")
if myT.Failed() {
t.Fatal("Expected TableDoesNotExists not to fail.")
}
myT = new(assert.Tspy)
TableDoesNotExists(myT, "test_1")
if !myT.Failed() {
t.Fatal("Expected TableDoesNotExists to fail.")
}
}
示例7: Test_NotError
func Test_NotError(t *testing.T) {
err1 := errors.New("Test1")
err2 := new(mysql.Error)
myT := new(assert.Tspy)
NotError(myT, err2, "Custom message")
if !myT.Failed() {
t.Fatal("Expected NotError to fail.")
}
myT = new(assert.Tspy)
NotError(myT, err1)
if myT.Failed() {
t.Fatal("Expected NotError not to fail.")
}
}
示例8: Test_TableNotEmpty
func Test_TableNotEmpty(t *testing.T) {
// Table empty
myT := new(assert.Tspy)
TableNotEmpty(myT, "test0")
if !myT.Failed() {
t.Fatal("Expected TableNotEmpty to fail.")
}
// Table not empty
myT = new(assert.Tspy)
TableNotEmpty(myT, "test_1")
if myT.Failed() {
t.Fatal("Expected TableNotEmpty to fail.")
}
}
示例9: Test_TableExists
func Test_TableExists(t *testing.T) {
myT := new(assert.Tspy)
TableExists(myT, "not_existing_table")
if !myT.Failed() {
t.Fatal("Expected TableExists to fail.")
}
err := CreateTestTable("test_1", TEST_DB_ENGINE)
if err != nil {
t.Fatal("Did not expect database error: " + err.Error())
}
myT = new(assert.Tspy)
TableExists(myT, "test_1")
if myT.Failed() {
t.Fatal("Expected TableExists not to fail.")
}
}
示例10: Test_TableRowCount
func Test_TableRowCount(t *testing.T) {
myT := new(assert.Tspy)
TableRowCount(myT, "test_1", 100)
if !myT.Failed() {
t.Fatal("Expected TableRowCount to fail.")
}
myT = new(assert.Tspy)
TableRowCount(myT, "test_1", 1)
if myT.Failed() {
t.Fatal("Expected TableRowCount not to fail.")
}
InsertToTestTable("test_1", 2, 456)
myT = new(assert.Tspy)
TableRowCount(myT, "test_1", 2)
if myT.Failed() {
t.Fatal("Expected TableRowCount not to fail.")
}
}