当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.Exactly函数代码示例

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


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

示例1: TestDocDistinctOn

func TestDocDistinctOn(t *testing.T) {
	published := `
		INNER JOIN posts p on (p.author_id = u.id)
		WHERE
			p.state = $1
	`
	sql, args := SelectDoc("u.*, p.*").
		DistinctOn("aa", "bb").
		From(`users u`).
		Scope(published, "published").
		Where(`u.id = $1`, 1).
		ToSQL()
	expected := `
		SELECT row_to_json(dat__item.*)
		FROM (
			SELECT DISTINCT ON (aa, bb)
			u.*, p.*
			FROM users u
				INNER JOIN posts p on (p.author_id = u.id)
			WHERE (u.id = $1) AND ( p.state = $2 )
		) as dat__item
	`
	assert.Equal(t, stripWS(expected), stripWS(sql))
	assert.Exactly(t, args, []interface{}{1, "published"})
}
开发者ID:iPowow,项目名称:lbManager,代码行数:25,代码来源:select_doc_test.go

示例2: TestCommitWithNestedNestedRollback

func TestCommitWithNestedNestedRollback(t *testing.T) {
	log.Suppress(true)
	defer log.Suppress(false)
	installFixtures()
	tx, err := testDB.Begin()
	assert.NoError(t, err)
	err = nestedNestedRollback(tx)
	assert.NoError(t, err)
	err = tx.Commit()
	assert.Exactly(t, ErrTxRollbacked, err)

	var person Person
	err = testDB.
		Select("*").
		From("people").
		Where("email = $1", "[email protected]").
		QueryStruct(&person)
	assert.Exactly(t, sql.ErrNoRows, err)
}
开发者ID:PlanitarInc,项目名称:dat,代码行数:19,代码来源:tx_test.go

示例3: TestErrorInBeginIfRollbacked

func TestErrorInBeginIfRollbacked(t *testing.T) {
	log.Suppress(true)
	defer log.Suppress(false)
	installFixtures()
	tx, err := testDB.Begin()
	assert.NoError(t, err)
	err = tx.Rollback()
	assert.NoError(t, err)

	_, err = tx.Begin()
	assert.Exactly(t, ErrTxRollbacked, err)
}
开发者ID:PlanitarInc,项目名称:dat,代码行数:12,代码来源:tx_test.go

示例4: TestInnerJoin

func TestInnerJoin(t *testing.T) {
	sql, args := Select("u.*, p.*").
		From(`
			users u
			INNER JOIN posts p on (p.author_id = u.id)
		`).
		Where(`u.id = $1`, 1).
		ToSQL()
	sql = str.Clean(sql)
	assert.Equal(t, sql, "SELECT u.*, p.* FROM users u INNER JOIN posts p on (p.author_id = u.id) WHERE (u.id = $1)")
	assert.Exactly(t, args, []interface{}{1})
}
开发者ID:syreclabs,项目名称:dat,代码行数:12,代码来源:select_test.go

示例5: TestScopeJoinOnly

func TestScopeJoinOnly(t *testing.T) {
	published := `
		INNER JOIN posts p on (p.author_id = u.id)
	`

	sql, args := Select("u.*, p.*").
		From(`users u`).
		Scope(published).
		Where(`u.id = $1`, 1).
		ToSQL()
	sql = str.Clean(sql)
	assert.Equal(t, "SELECT u.*, p.* FROM users u INNER JOIN posts p on (p.author_id = u.id) WHERE (u.id = $1)", sql)
	assert.Exactly(t, args, []interface{}{1})
}
开发者ID:syreclabs,项目名称:dat,代码行数:14,代码来源:select_test.go

示例6: TestInsertBytes

func TestInsertBytes(t *testing.T) {
	b := []byte{0, 0, 0}
	var image []byte
	var id int32
	sql := `
		INSERT INTO people (name, image)
		VALUES ($1, $2)
		RETURNING id, image
	`
	dat.EnableInterpolation = true
	err := testDB.SQL(sql, "foo", b).QueryScalar(&id, &image)
	assert.NoError(t, err)
	assert.Exactly(t, b, image)
	dat.EnableInterpolation = false
}
开发者ID:syreclabs,项目名称:dat,代码行数:15,代码来源:insert_exec_test.go

示例7: TestDistinctOn

func TestDistinctOn(t *testing.T) {
	published := `
		INNER JOIN posts p on (p.author_id = u.id)
	`

	sql, args := Select("u.*, p.*").
		DistinctOn("foo", "bar").
		From(`users u`).
		Scope(published).
		Where(`u.id = $1`, 1).
		ToSQL()
	assert.Equal(t, stripWS(`
		SELECT DISTINCT ON (foo, bar) u.*, p.*
		FROM users u
			INNER JOIN posts p on (p.author_id = u.id)
		WHERE (u.id = $1)`), stripWS(sql))
	assert.Exactly(t, args, []interface{}{1})
}
开发者ID:syreclabs,项目名称:dat,代码行数:18,代码来源:select_test.go

示例8: TestEmbeddedStructMapping

func TestEmbeddedStructMapping(t *testing.T) {
	type Realm struct {
		RealmUUID string `db:"realm_uuid"`
	}
	type Group struct {
		GroupUUID string `db:"group_uuid"`
		*Realm
	}

	g := &Group{Realm: &Realm{"11"}, GroupUUID: "22"}

	sql, args := InsertInto("groups").Columns("group_uuid", "realm_uuid").Record(g).ToSQL()
	expected := `
		INSERT INTO groups ("group_uuid", "realm_uuid")
		VALUES ($1, $2)
	`
	assert.Equal(t, stripWS(expected), stripWS(sql))
	assert.Exactly(t, []interface{}{"22", "11"}, args)
}
开发者ID:iPowow,项目名称:lbManager,代码行数:19,代码来源:struct_mapping_test.go

示例9: TestNestedSelecDocWhere

func TestNestedSelecDocWhere(t *testing.T) {
	user := SelectDoc("id", "user_name").
		Many("comments", `SELECT * FROM comments WHERE id = u.id`).
		From("users u").
		Where("u.id = $1", 1)

	sql, args := SelectDoc("id").
		One("user", user).
		From(`games`).
		Where(`id = $1`, 10).
		ToSQL()

	expected := `
		SELECT row_to_json(dat__item.*)
		FROM (
			SELECT id,
				(
					SELECT row_to_json(dat__user.*)
					FROM (
						SELECT id, user_name,
							(
								SELECT array_agg(dat__comments.*)
								FROM (SELECT * FROM comments WHERE id = u.id)
								AS dat__comments
							) AS "comments"
						FROM users u
						WHERE (u.id = $1)
					) AS dat__user
				) AS "user"
			FROM games
			WHERE (id = $2)
		) as dat__item
	`
	assert.Equal(t, stripWS(expected), stripWS(sql))
	assert.Exactly(t, args, []interface{}{1, 10})
}
开发者ID:iPowow,项目名称:lbManager,代码行数:36,代码来源:select_doc_test.go

示例10: TestUpdateWhereExprSql

func TestUpdateWhereExprSql(t *testing.T) {
	expr := Expr("id=$1", 100)
	sql, args := Update("a").Set("b", 10).Where(expr).ToSQL()
	assert.Equal(t, sql, `UPDATE "a" SET "b" = $1 WHERE (id=$2)`)
	assert.Exactly(t, args, []interface{}{10, 100})
}
开发者ID:syreclabs,项目名称:dat,代码行数:6,代码来源:update_test.go

示例11: TestSelectScope

func TestSelectScope(t *testing.T) {
	scope := NewScope("WHERE :TABLE.id = :id and name = :name", M{"id": 1, "name": "foo"})
	sql, args := Select("a").From("b").ScopeMap(scope, M{"name": "mario"}).ToSQL()
	assert.Equal(t, `SELECT a FROM b WHERE ( "b".id = $1 and name = $2)`, sql)
	assert.Exactly(t, args, []interface{}{1, "mario"})
}
开发者ID:syreclabs,项目名称:dat,代码行数:6,代码来源:select_test.go

示例12: TestSelectWhereExprSql

func TestSelectWhereExprSql(t *testing.T) {
	expr := Expr("id=$1", 100)
	sql, args := Select("a").From("b").Where(expr).ToSQL()
	assert.Equal(t, sql, "SELECT a FROM b WHERE (id=$1)")
	assert.Exactly(t, args, []interface{}{100})
}
开发者ID:syreclabs,项目名称:dat,代码行数:6,代码来源:select_test.go

示例13: TestCallSql

func TestCallSql(t *testing.T) {
	sql, args := Call("foo", 1, "two").ToSQL()
	assert.Equal(t, "SELECT * FROM foo($1,$2)", sql)
	assert.Exactly(t, []interface{}{1, "two"}, args)
}
开发者ID:syreclabs,项目名称:dat,代码行数:5,代码来源:call_test.go

示例14: TestDeleteWhereExprSql

func TestDeleteWhereExprSql(t *testing.T) {
	expr := Expr("id=$1", 100)
	sql, args := DeleteFrom("a").Where("foo = $1", "bar").Where(expr).ToSQL()
	assert.Equal(t, sql, `DELETE FROM a WHERE (foo = $1) AND (id=$2)`)
	assert.Exactly(t, args, []interface{}{"bar", 100})
}
开发者ID:syreclabs,项目名称:dat,代码行数:6,代码来源:delete_test.go


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