本文整理匯總了Golang中github.com/pgpst/pgpst/internal/gopkg/in/check/v1.C.Fatalf方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Fatalf方法的具體用法?Golang C.Fatalf怎麽用?Golang C.Fatalf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pgpst/pgpst/internal/gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.Fatalf方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestCursorReuseResult
func (s *RethinkSuite) TestCursorReuseResult(c *test.C) {
// Test query
query := Expr([]interface{}{
map[string]interface{}{
"A": "a",
},
map[string]interface{}{
"B": 1,
},
map[string]interface{}{
"A": "a",
},
map[string]interface{}{
"B": 1,
},
map[string]interface{}{
"A": "a",
"B": 1,
},
})
res, err := query.Run(session)
c.Assert(err, test.IsNil)
var i int
var result SimpleT
for res.Next(&result) {
switch i {
case 0:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 0,
})
case 1:
c.Assert(result, test.DeepEquals, SimpleT{
A: "",
B: 1,
})
case 2:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 0,
})
case 3:
c.Assert(result, test.DeepEquals, SimpleT{
A: "",
B: 1,
})
case 4:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 1,
})
default:
c.Fatalf("Unexpected number of results")
}
i++
}
c.Assert(res.Err(), test.IsNil)
}
示例2: TestConcurrentSelectManyRows
func (s *RethinkSuite) TestConcurrentSelectManyRows(c *test.C) {
if testing.Short() {
c.Skip("Skipping long test")
}
// Ensure table + database exist
DBCreate("test").RunWrite(session)
DB("test").TableCreate("TestMany").RunWrite(session)
DB("test").Table("TestMany").Delete().RunWrite(session)
// Insert rows
for i := 0; i < 100; i++ {
DB("test").Table("TestMany").Insert(map[string]interface{}{
"i": i,
}).Exec(session)
}
// Test queries concurrently
attempts := 10
waitChannel := make(chan error, attempts)
for i := 0; i < attempts; i++ {
go func(i int, c chan error) {
res, err := DB("test").Table("TestMany").Run(session)
if err != nil {
c <- err
return
}
var response []map[string]interface{}
err = res.All(&response)
if err != nil {
c <- err
return
}
if len(response) != 100 {
c <- fmt.Errorf("expected response length 100, received %d", len(response))
return
}
res.Close()
c <- nil
}(i, waitChannel)
}
for i := 0; i < attempts; i++ {
ret := <-waitChannel
if ret != nil {
c.Fatalf("non-nil error returned (%s)", ret)
}
}
}
示例3: TestConcurrentSelectManyWorkers
func (s *RethinkSuite) TestConcurrentSelectManyWorkers(c *test.C) {
if testing.Short() {
c.Skip("Skipping long test")
}
rand.Seed(time.Now().UnixNano())
sess, _ := Connect(ConnectOpts{
Address: url,
AuthKey: authKey,
MaxOpen: 200,
MaxIdle: 200,
})
// Ensure table + database exist
DBCreate("test").RunWrite(sess)
DB("test").TableDrop("TestConcurrent").RunWrite(sess)
DB("test").TableCreate("TestConcurrent").RunWrite(sess)
DB("test").TableDrop("TestConcurrent2").RunWrite(sess)
DB("test").TableCreate("TestConcurrent2").RunWrite(sess)
// Insert rows
for j := 0; j < 200; j++ {
DB("test").Table("TestConcurrent").Insert(map[string]interface{}{
"id": j,
"i": j,
}).Exec(sess)
DB("test").Table("TestConcurrent2").Insert(map[string]interface{}{
"j": j,
"k": j * 2,
}).Exec(sess)
}
// Test queries concurrently
numQueries := 1000
numWorkers := 10
queryChan := make(chan int)
doneChan := make(chan error)
// Start workers
for i := 0; i < numWorkers; i++ {
go func() {
for _ = range queryChan {
res, err := DB("test").Table("TestConcurrent2").EqJoin("j", DB("test").Table("TestConcurrent")).Zip().Run(sess)
if err != nil {
doneChan <- err
return
}
var response []map[string]interface{}
err = res.All(&response)
if err != nil {
doneChan <- err
return
}
if err := res.Close(); err != nil {
doneChan <- err
return
}
if len(response) != 200 {
doneChan <- fmt.Errorf("expected response length 200, received %d", len(response))
return
}
res, err = DB("test").Table("TestConcurrent").Get(response[rand.Intn(len(response))]["id"]).Run(sess)
if err != nil {
doneChan <- err
return
}
err = res.All(&response)
if err != nil {
doneChan <- err
return
}
if err := res.Close(); err != nil {
doneChan <- err
return
}
if len(response) != 1 {
doneChan <- fmt.Errorf("expected response length 1, received %d", len(response))
return
}
doneChan <- nil
}
}()
}
go func() {
for i := 0; i < numQueries; i++ {
queryChan <- i
}
}()
for i := 0; i < numQueries; i++ {
ret := <-doneChan
if ret != nil {
c.Fatalf("non-nil error returned (%s)", ret)
//.........這裏部分代碼省略.........