本文整理汇总了Golang中github.com/pgpst/pgpst/internal/gopkg/in/check/v1.C类的典型用法代码示例。如果您正苦于以下问题:Golang C类的具体用法?Golang C怎么用?Golang C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestStringMatchFail
func (s *RethinkSuite) TestStringMatchFail(c *test.C) {
query := Expr("id:0,foo:bar").Match("name:(\\w+)")
res, err := query.Run(session)
c.Assert(err, test.IsNil)
c.Assert(res.IsNil(), test.Equals, true)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:7,代码来源:query_string_test.go
示例2: TestGeospatialEncodeGeometryPseudoType
func (s *RethinkSuite) TestGeospatialEncodeGeometryPseudoType(c *test.C) {
encoded, err := encode(types.Geometry{
Type: "Polygon",
Lines: types.Lines{
types.Line{
types.Point{Lon: -122.423246, Lat: 37.779388},
types.Point{Lon: -122.423246, Lat: 37.329898},
types.Point{Lon: -121.88642, Lat: 37.329898},
types.Point{Lon: -121.88642, Lat: 37.779388},
types.Point{Lon: -122.423246, Lat: 37.779388},
},
},
})
c.Assert(err, test.IsNil)
c.Assert(encoded, jsonEquals, map[string]interface{}{
"$reql_type$": "GEOMETRY",
"type": "Polygon",
"coordinates": []interface{}{
[]interface{}{
[]interface{}{-122.423246, 37.779388},
[]interface{}{-122.423246, 37.329898},
[]interface{}{-121.88642, 37.329898},
[]interface{}{-121.88642, 37.779388},
[]interface{}{-122.423246, 37.779388},
},
},
})
}
开发者ID:pgpst,项目名称:pgpst,代码行数:28,代码来源:query_geospatial_test.go
示例3: 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
}
}
}
}
开发者ID:pgpst,项目名称:pgpst,代码行数:28,代码来源:cluster_integration_test.go
示例4: TestOrderByJoinEq
func (s *RethinkSuite) TestOrderByJoinEq(c *test.C) {
type Map map[string]interface{}
var err error
// Ensure table + database exist
DBCreate("test").Exec(session)
DB("test").TableCreate("test").Exec(session)
DB("test").TableCreate("test2").Exec(session)
tab := DB("test").Table("test")
tab2 := DB("test").Table("test2")
// insert rows
err = tab.Insert(Map{"S": "s1", "T": 2}).Exec(session)
err = tab.Insert(Map{"S": "s1", "T": 1}).Exec(session)
err = tab.Insert(Map{"S": "s1", "T": 3}).Exec(session)
err = tab.Insert(Map{"S": "s2", "T": 3}).Exec(session)
c.Assert(err, test.IsNil)
err = tab2.Insert(Map{"id": "s1", "N": "Rob"}).Exec(session)
err = tab2.Insert(Map{"id": "s2", "N": "Zar"}).Exec(session)
c.Assert(err, test.IsNil)
// Test query
var response []Map
res, err := tab.OrderBy("T").EqJoin("S", tab2).Run(session)
c.Assert(err, test.IsNil)
err = res.All(&response)
c.Assert(err, test.IsNil)
c.Check(len(response), test.Equals, 4, test.Commentf("%v", response))
}
开发者ID:pgpst,项目名称:pgpst,代码行数:31,代码来源:query_join_test.go
示例5: doConcurrentTest
func doConcurrentTest(c *test.C, ct func()) {
maxProcs, numReqs := 1, 150
if testing.Short() {
maxProcs, numReqs = 4, 50
}
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs))
var wg sync.WaitGroup
wg.Add(numReqs)
reqs := make(chan bool)
defer close(reqs)
for i := 0; i < maxProcs*2; i++ {
go func() {
for _ = range reqs {
ct()
if c.Failed() {
wg.Done()
continue
}
wg.Done()
}
}()
}
for i := 0; i < numReqs; i++ {
reqs <- true
}
wg.Wait()
}
开发者ID:pgpst,项目名称:pgpst,代码行数:32,代码来源:gorethink_test.go
示例6: BenchmarkGetStruct
func (s *RethinkSuite) BenchmarkGetStruct(c *test.C) {
// Ensure table + database exist
DBCreate("test").RunWrite(session)
DB("test").TableCreate("TestMany").RunWrite(session)
DB("test").Table("TestMany").Delete().RunWrite(session)
// Insert rows
data := []interface{}{}
for i := 0; i < 100; i++ {
data = append(data, map[string]interface{}{
"id": i,
"name": "Object 1",
"Attrs": []interface{}{map[string]interface{}{
"Name": "attr 1",
"Value": "value 1",
}},
})
}
DB("test").Table("TestMany").Insert(data).Run(session)
for i := 0; i < c.N; i++ {
n := rand.Intn(100)
// Test query
var resObj object
query := DB("test").Table("TestMany").Get(n)
res, err := query.Run(session)
c.Assert(err, test.IsNil)
err = res.One(&resObj)
c.Assert(err, test.IsNil)
}
}
开发者ID:pgpst,项目名称:pgpst,代码行数:34,代码来源:gorethink_test.go
示例7: TestSelectGetAllCompoundIndex
func (s *RethinkSuite) TestSelectGetAllCompoundIndex(c *test.C) {
// Ensure table + database exist
DBCreate("test").Exec(session)
DB("test").TableDrop("TableCompound").Exec(session)
DB("test").TableCreate("TableCompound").Exec(session)
write, err := DB("test").Table("TableCompound").IndexCreateFunc("full_name", func(row Term) interface{} {
return []interface{}{row.Field("first_name"), row.Field("last_name")}
}).RunWrite(session)
DB("test").Table("TableCompound").IndexWait().Exec(session)
c.Assert(err, test.IsNil)
c.Assert(write.Created, test.Equals, 1)
// Insert rows
DB("test").Table("TableCompound").Insert(nameList).Exec(session)
// Test query
var response interface{}
query := DB("test").Table("TableCompound").GetAllByIndex("full_name", []interface{}{"John", "Smith"})
res, err := query.Run(session)
c.Assert(err, test.IsNil)
err = res.One(&response)
c.Assert(err, test.IsNil)
c.Assert(response, jsonEquals, map[string]interface{}{"id": 1, "first_name": "John", "last_name": "Smith", "gender": "M"})
res.Close()
}
开发者ID:pgpst,项目名称:pgpst,代码行数:28,代码来源:query_select_test.go
示例8: TestJoinInnerJoin
func (s *RethinkSuite) TestJoinInnerJoin(c *test.C) {
// Ensure table + database exist
DBCreate("test").Exec(session)
DB("test").TableCreate("Join1").Exec(session)
DB("test").TableCreate("Join2").Exec(session)
// Insert rows
DB("test").Table("Join1").Insert(joinTable1).Exec(session)
DB("test").Table("Join2").Insert(joinTable2).Exec(session)
// Test query
var response []interface{}
query := DB("test").Table("Join1").InnerJoin(DB("test").Table("Join2"), func(a, b Term) Term {
return a.Field("id").Eq(b.Field("id"))
})
res, err := query.Run(session)
c.Assert(err, test.IsNil)
err = res.All(&response)
c.Assert(response, jsonEquals, []interface{}{
map[string]interface{}{
"right": map[string]interface{}{"title": "goof", "id": 0},
"left": map[string]interface{}{"name": "bob", "id": 0},
},
map[string]interface{}{
"right": map[string]interface{}{"title": "lmoe", "id": 2},
"left": map[string]interface{}{"name": "joe", "id": 2},
},
})
}
开发者ID:pgpst,项目名称:pgpst,代码行数:30,代码来源:query_join_test.go
示例9: TestSessionConnectError
func (s *RethinkSuite) TestSessionConnectError(c *test.C) {
var err error
_, err = Connect(ConnectOpts{
Address: "nonexistanturl",
Timeout: time.Second,
})
c.Assert(err, test.NotNil)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:8,代码来源:session_test.go
示例10: BenchmarkNoReplyExpr
func (s *RethinkSuite) BenchmarkNoReplyExpr(c *test.C) {
for i := 0; i < c.N; i++ {
// Test query
query := Expr(true)
err := query.Exec(session, ExecOpts{NoReply: true})
c.Assert(err, test.IsNil)
}
}
开发者ID:pgpst,项目名称:pgpst,代码行数:8,代码来源:gorethink_test.go
示例11: TestTableCreate
func (s *RethinkSuite) TestTableCreate(c *test.C) {
DB("test").TableDrop("test").Exec(session)
// Test database creation
query := DB("test").TableCreate("test")
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.TablesCreated, jsonEquals, 1)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:10,代码来源:query_table_test.go
示例12: TestTableCompoundIndexCreate
func (s *RethinkSuite) TestTableCompoundIndexCreate(c *test.C) {
DBCreate("test").Exec(session)
DB("test").TableDrop("TableCompound").Exec(session)
DB("test").TableCreate("TableCompound").Exec(session)
response, err := DB("test").Table("TableCompound").IndexCreateFunc("full_name", func(row Term) interface{} {
return []interface{}{row.Field("first_name"), row.Field("last_name")}
}).RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.Created, test.Equals, 1)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:10,代码来源:query_table_test.go
示例13: TestWriteDelete
func (s *RethinkSuite) TestWriteDelete(c *test.C) {
query := DB("test").Table("test").Insert(map[string]interface{}{"num": 1})
_, err := query.Run(session)
c.Assert(err, test.IsNil)
// Delete the first row in the table
query = DB("test").Table("test").Sample(1).Delete()
_, err = query.Run(session)
c.Assert(err, test.IsNil)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:10,代码来源:query_write_test.go
示例14: 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)
}
}
}
开发者ID:pgpst,项目名称:pgpst,代码行数:54,代码来源:query_select_test.go
示例15: TestDbCreate
func (s *RethinkSuite) TestDbCreate(c *test.C) {
// Delete the test2 database if it already exists
DBDrop("test").Exec(session)
// Test database creation
query := DBCreate("test")
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.DBsCreated, jsonEquals, 1)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:11,代码来源:query_db_test.go
示例16: TestTableCreateSoftDurability
func (s *RethinkSuite) TestTableCreateSoftDurability(c *test.C) {
DB("test").TableDrop("testOpts").Exec(session)
// Test database creation
query := DB("test").TableCreate("testOpts", TableCreateOpts{
Durability: "soft",
})
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.TablesCreated, jsonEquals, 1)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:12,代码来源:query_table_test.go
示例17: TestTableIndexCreate
func (s *RethinkSuite) TestTableIndexCreate(c *test.C) {
DB("test").TableCreate("test").Exec(session)
DB("test").Table("test").IndexDrop("test").Exec(session)
// Test database creation
query := DB("test").Table("test").IndexCreate("test", IndexCreateOpts{
Multi: true,
})
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.Created, jsonEquals, 1)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:13,代码来源:query_table_test.go
示例18: TestTableIndexRename
func (s *RethinkSuite) TestTableIndexRename(c *test.C) {
DB("test").TableDrop("test").Exec(session)
DB("test").TableCreate("test").Exec(session)
DB("test").Table("test").IndexCreate("test").Exec(session)
DB("test").Table("test").IndexWait().Exec(session)
// Test index rename
query := DB("test").Table("test").IndexRename("test", "test2")
response, err := query.RunWrite(session)
c.Assert(err, test.IsNil)
c.Assert(response.Renamed, jsonEquals, 1)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:13,代码来源:query_table_test.go
示例19: TestGeospatialDecodeGeometryPseudoType
func (s *RethinkSuite) TestGeospatialDecodeGeometryPseudoType(c *test.C) {
var response types.Geometry
// setup coordinates
coords := [][][]float64{
{
{-122.423246, 37.779388},
{-122.423246, 37.329898},
{-121.88642, 37.329898},
{-121.88642, 37.329898},
{-122.423246, 37.779388},
},
}
gt := "Polygon"
res, err := Expr(map[string]interface{}{
"$reql_type$": "GEOMETRY",
"type": "Polygon",
"coordinates": coords,
}).Run(session)
c.Assert(err, test.IsNil)
err = res.One(&response)
c.Assert(err, test.IsNil)
// test shape
if response.Type != gt {
c.Errorf("expected [%v], instead [%v]", gt, response.Type)
}
// assert points are within threshold
c.Assert(response, geometryEquals, "Polygon", coords)
}
开发者ID:pgpst,项目名称:pgpst,代码行数:33,代码来源:query_geospatial_test.go
示例20: TestAggregationGroupMapReduceTable
func (s *RethinkSuite) TestAggregationGroupMapReduceTable(c *test.C) {
// Ensure table + database exist
DBCreate("test").Exec(session)
DB("test").TableCreate("TestAggregationGroupedMapReduceTable").Exec(session)
// Insert rows
err := DB("test").Table("TestAggregationGroupedMapReduceTable").Insert(objList).Exec(session)
c.Assert(err, test.IsNil)
var response []interface{}
query := DB("test").Table("TestAggregationGroupedMapReduceTable").Group(func(row Term) Term {
return row.Field("id").Mod(2).Eq(0)
}).Map(func(row Term) Term {
return row.Field("num")
}).Reduce(func(acc, num Term) Term {
return acc.Add(num)
})
res, err := query.Run(session)
c.Assert(err, test.IsNil)
err = res.All(&response)
c.Assert(err, test.IsNil)
c.Assert(response, jsonEquals, []interface{}{
map[string]interface{}{"reduction": 135, "group": false},
map[string]interface{}{"reduction": 70, "group": true},
})
}
开发者ID:pgpst,项目名称:pgpst,代码行数:28,代码来源:query_aggregation_test.go
注:本文中的github.com/pgpst/pgpst/internal/gopkg/in/check/v1.C类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论