本文整理匯總了Golang中github.com/pgpst/pgpst/internal/gopkg/in/check/v1.C.Fatal方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Fatal方法的具體用法?Golang C.Fatal怎麽用?Golang C.Fatal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pgpst/pgpst/internal/gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.Fatal方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestClusterRecoverAfterNoNodes
func (s *RethinkSuite) TestClusterRecoverAfterNoNodes(c *test.C) {
session, err := Connect(ConnectOpts{
Addresses: []string{url, url2},
DiscoverHosts: true,
NodeRefreshInterval: time.Second,
})
c.Assert(err, test.IsNil)
t := time.NewTimer(time.Second * 30)
hasHadZeroNodes := false
for {
select {
// Fail if deadline has passed
case <-t.C:
c.Fatal("No node was added to the cluster")
default:
// Check if there are no nodes
if len(session.cluster.GetNodes()) == 0 {
hasHadZeroNodes = true
}
// Pass if another node was added
if len(session.cluster.GetNodes()) >= 1 && hasHadZeroNodes {
return
}
}
}
}
示例2: TestTableChangesExitNoResults
func (s *RethinkSuite) TestTableChangesExitNoResults(c *test.C) {
DB("test").TableDrop("changes").Exec(session)
DB("test").TableCreate("changes").Exec(session)
var n int
res, err := DB("test").Table("changes").Changes().Run(session)
if err != nil {
c.Fatal(err.Error())
}
c.Assert(res.Type(), test.Equals, "Feed")
change := make(chan ChangeResponse)
// Close cursor after one second
go func() {
<-time.After(time.Second)
res.Close()
}()
// Listen for changes
res.Listen(change)
for _ = range change {
n++
}
if res.Err() == nil {
c.Fatal("No error returned, expected connection closed")
}
c.Assert(n, test.Equals, 0)
}
示例3: TestTableChanges
func (s *RethinkSuite) TestTableChanges(c *test.C) {
DB("test").TableDrop("changes").Exec(session)
DB("test").TableCreate("changes").Exec(session)
var n int
res, err := DB("test").Table("changes").Changes().Run(session)
if err != nil {
c.Fatal(err.Error())
}
c.Assert(res.Type(), test.Equals, "Feed")
wg := &sync.WaitGroup{}
wg.Add(1)
// Use goroutine to wait for changes. Prints the first 10 results
go func() {
var response interface{}
for n < 10 && res.Next(&response) {
n++
}
if res.Err() != nil {
c.Fatal(res.Err())
}
wg.Done()
}()
DB("test").Table("changes").Insert(map[string]interface{}{"n": 1}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 2}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 3}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 4}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 5}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 6}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 7}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 8}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 9}).Exec(session)
DB("test").Table("changes").Insert(map[string]interface{}{"n": 10}).Exec(session)
wg.Wait()
c.Assert(n, test.Equals, 10)
}
示例4: TestClusterDetectNewNode
func (s *RethinkSuite) TestClusterDetectNewNode(c *test.C) {
session, err := Connect(ConnectOpts{
Addresses: []string{url, url2},
DiscoverHosts: true,
NodeRefreshInterval: time.Second,
})
c.Assert(err, test.IsNil)
t := time.NewTimer(time.Second * 30)
for {
select {
// Fail if deadline has passed
case <-t.C:
c.Fatal("No node was added to the cluster")
default:
// Pass if another node was added
if len(session.cluster.GetNodes()) >= 3 {
return
}
}
}
}