本文整理汇总了Golang中github.com/coocood/assrt.Assert.NotNil方法的典型用法代码示例。如果您正苦于以下问题:Golang Assert.NotNil方法的具体用法?Golang Assert.NotNil怎么用?Golang Assert.NotNil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coocood/assrt.Assert
的用法示例。
在下文中一共展示了Assert.NotNil方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DoTestTransaction
func DoTestTransaction(assert *assrt.Assert, info dialectInfo) {
mg, q := setupDb(assert, info)
type txModel struct {
Id Id
A string
}
table := txModel{
A: "A",
}
mg.dropTableIfExists(&table)
mg.CreateTableIfNotExists(&table)
q.Begin()
assert.NotNil(q.Tx)
_, err := q.Save(&table)
assert.Nil(err)
err = q.Rollback()
assert.Nil(err)
out := new(txModel)
err = q.Find(out)
assert.Nil(err)
assert.Zero(out.Id)
q.Begin()
table.Id = 0
_, err = q.Save(&table)
assert.Nil(err)
err = q.Commit()
assert.Nil(err)
err = q.Find(out)
assert.Nil(err)
assert.Equal("A", out.A)
}
示例2: assertLegitGraph
func assertLegitGraph(assert *assrt.Assert, g *Graph) {
assert.NotNil(g)
gstat, _ := os.Stat(filepath.Join(g.dir))
assert.True(gstat.IsDir())
assert.True(g.HasBranch("hroot/init"))
assert.Equal(
"",
g.cmd("ls-tree")("HEAD").Output(),
)
}
示例3: DoTestFind
func DoTestFind(assert *assrt.Assert, info dialectInfo) {
mg, q := setupDb(assert, info)
defer mg.Close()
defer q.Close()
now := time.Now()
type types struct {
Id int64
Str string
Intgr int64
Flt float64
Bytes []byte
Time time.Time
}
modelData := &types{
Str: "string!",
Intgr: -1,
Flt: 3.8,
Bytes: []byte("bytes!"),
Time: now,
}
mg.dropTableIfExists(modelData)
mg.CreateTableIfNotExists(modelData)
out := new(types)
condition := NewCondition("str = ?", "string!").And("intgr = ?", -1)
err := q.Condition(condition).Find(out)
assert.Equal(sql.ErrNoRows, err)
affected, err := q.Save(modelData)
assert.Nil(err)
assert.Equal(1, affected)
out.Id = modelData.Id
err = q.Condition(condition).Find(out)
assert.Nil(err)
assert.Equal(1, out.Id)
assert.Equal("string!", out.Str)
assert.Equal(-1, out.Intgr)
assert.Equal(3.8, out.Flt)
assert.Equal([]byte("bytes!"), out.Bytes)
diff := now.Sub(out.Time)
assert.True(diff < time.Second && diff > -time.Second)
modelData.Id = 5
modelData.Str = "New row"
_, err = q.Save(modelData)
assert.Nil(err)
out = new(types)
condition = NewCondition("str = ?", "New row").And("flt = ?", 3.8)
err = q.Condition(condition).Find(out)
assert.Nil(err)
assert.Equal(5, out.Id)
out = new(types)
out.Id = 100
err = q.Find(out)
assert.NotNil(err)
allOut := []*types{}
err = q.WhereEqual("intgr", -1).FindAll(&allOut)
assert.Nil(err)
assert.Equal(2, len(allOut))
}