• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Tspy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/rzajac/goassert/assert.Tspy的典型用法代码示例。如果您正苦于以下问题:Golang Tspy类的具体用法?Golang Tspy怎么用?Golang Tspy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Tspy类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:34,代码来源:assertmysql_test.go


示例2: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:34,代码来源:assertmysql_test.go


示例3: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:58,代码来源:assertmysql_test.go


示例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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:15,代码来源:assertmysql_test.go


示例5: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:16,代码来源:assertmysql_test.go


示例6: 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")))
		}
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:32,代码来源:assertmysql_test.go


示例7: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:25,代码来源:assertmysql_test.go


示例8: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:18,代码来源:assertmysql_test.go


示例9: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:18,代码来源:assertmysql_test.go


示例10: 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.")
	}
}
开发者ID:rzajac,项目名称:goassert,代码行数:21,代码来源:assertmysql_test.go



注:本文中的github.com/rzajac/goassert/assert.Tspy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang uritemplates.Expand函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.Equal函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap