本文整理汇总了Golang中github.com/benmills/quiz.Test函数的典型用法代码示例。如果您正苦于以下问题:Golang Test函数的具体用法?Golang Test怎么用?Golang Test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Test函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestJoinUpdatesExistingPeers
func TestJoinUpdatesExistingPeers(t *testing.T) {
test := quiz.Test(t)
nodeA := testNode()
defer nodeA.Close()
nodeB := testNode()
defer nodeB.Close()
nodeC := testNode()
defer nodeC.Close()
httpclient.Put(nodeA.URL+"/peers/join", nodeB.URL)
httpclient.Put(nodeA.URL+"/peers/join", nodeC.URL)
var statusCode int
var body string
statusCode, body = httpclient.Get(nodeA.URL+"/peers", "")
test.Expect(statusCode).ToEqual(200)
test.Expect(body).ToContain(nodeB.URL)
test.Expect(body).ToContain(nodeC.URL)
statusCode, body = httpclient.Get(nodeB.URL+"/peers", "")
test.Expect(statusCode).ToEqual(200)
test.Expect(body).ToContain(nodeA.URL)
test.Expect(body).ToContain(nodeC.URL)
statusCode, body = httpclient.Get(nodeC.URL+"/peers", "")
test.Expect(statusCode).ToEqual(200)
test.Expect(body).ToContain(nodeA.URL)
test.Expect(body).ToContain(nodeB.URL)
}
开发者ID:benmills,项目名称:library,代码行数:31,代码来源:peer_test.go
示例2: TestFetchesAcrossNodes
func TestFetchesAcrossNodes(t *testing.T) {
test := quiz.Test(t)
serverA := testServer()
defer serverA.Close()
serverB := testServer()
defer serverB.Close()
httpclient.Put(serverA.URL+"/peers/join", serverB.URL)
// "a"'s hash will be stored on serverB
key := "a"
var statusCode int
var body string
statusCode, _ = httpclient.Put(serverA.URL+"/data/"+key, "bar")
test.Expect(statusCode).ToEqual(201)
statusCode, body = httpclient.Get(serverB.URL+"/data/"+key, "")
test.Expect(statusCode).ToEqual(200)
test.Expect(body).ToEqual("bar")
statusCode, body = httpclient.Get(serverA.URL+"/data/"+key, "")
test.Expect(statusCode).ToEqual(200)
test.Expect(body).ToEqual("bar")
}
开发者ID:benmills,项目名称:goak,代码行数:27,代码来源:server_test.go
示例3: TestNodeSetNValueUpdatesPeersOnJoin
func TestNodeSetNValueUpdatesPeersOnJoin(t *testing.T) {
test := quiz.Test(t)
nodeA := testNode()
defer nodeA.Close()
nodeB := testNode()
defer nodeB.Close()
nodeC := testNode()
defer nodeC.Close()
httpclient.Put(nodeA.URL+"/peers/join", nodeB.URL)
statusCode, _ := httpclient.Put(nodeA.URL+"/settings/n", "1")
test.Expect(statusCode).ToEqual(201)
httpclient.Put(nodeA.URL+"/peers/join", nodeC.URL)
_, body := httpclient.Get(nodeA.URL+"/stats", "")
test.Expect(body).ToContain(`"nValue":1`)
_, body = httpclient.Get(nodeB.URL+"/stats", "")
test.Expect(body).ToContain(`"nValue":1`)
_, body = httpclient.Get(nodeC.URL+"/stats", "")
test.Expect(body).ToContain(`"nValue":1`)
}
开发者ID:benmills,项目名称:library,代码行数:26,代码来源:peer_test.go
示例4: TestResizeCleansUpReplicas
func TestResizeCleansUpReplicas(t *testing.T) {
test := quiz.Test(t)
serverA := testServer()
defer serverA.Close()
serverB := testServer()
defer serverB.Close()
serverC := testServer()
defer serverC.Close()
serverD := testServer()
defer serverD.Close()
httpclient.Put(serverA.URL+"/peers/join", serverB.URL)
httpclient.Put(serverA.URL+"/peers/join", serverC.URL)
httpclient.Put(serverA.URL+"/settings/n", "1")
// this key will be owned by c before and after d joins
// however it's replicas will first by a then d
key := "a"
httpclient.Put(serverA.URL+"/data/"+key, "foo")
httpclient.Put(serverA.URL+"/peers/join", serverD.URL)
_, aHasKey := serverA.node.values[key]
_, cHasKey := serverC.node.values[key]
_, dHasKey := serverD.node.values[key]
test.Expect(aHasKey).ToBeFalse()
test.Expect(cHasKey).ToBeTrue()
test.Expect(dHasKey).ToBeTrue()
}
开发者ID:benmills,项目名称:library,代码行数:31,代码来源:server_test.go
示例5: TestNotifyDown
func TestNotifyDown(t *testing.T) {
test := quiz.Test(t)
peer := New("localhost", map[string]string{}, nullLogger)
peer.addPeer("remote")
peer.NotifyDown("remote")
test.Expect(peer.Peers[0]).ToEqual("dead:remote")
}
开发者ID:benmills,项目名称:library,代码行数:9,代码来源:peer_test.go
示例6: TestErrorOnNGreaterThanTotalPeers
func TestErrorOnNGreaterThanTotalPeers(t *testing.T) {
test := quiz.Test(t)
nodeA := testNode()
defer nodeA.Close()
statusCode, _ := httpclient.Put(nodeA.URL+"/settings/n", "5")
test.Expect(statusCode).ToEqual(422)
}
开发者ID:benmills,项目名称:library,代码行数:9,代码来源:peer_test.go
示例7: TestErrorOnNonIntForNValue
func TestErrorOnNonIntForNValue(t *testing.T) {
test := quiz.Test(t)
nodeA := testNode()
defer nodeA.Close()
statusCode, _ := httpclient.Put(nodeA.URL+"/settings/n", "notint")
test.Expect(statusCode).ToEqual(422)
}
开发者ID:benmills,项目名称:library,代码行数:9,代码来源:peer_test.go
示例8: TestRingCanHaveNodes
func TestRingCanHaveNodes(t *testing.T) {
test := quiz.Test(t)
ring := New()
ring.AddNode("A")
ring.AddNode("B")
test.Expect(ring.NodeCount()).ToEqual(2)
}
开发者ID:benmills,项目名称:library,代码行数:9,代码来源:ring_test.go
示例9: TestNodesHaveCorrectVnodeStart
func TestNodesHaveCorrectVnodeStart(t *testing.T) {
test := quiz.Test(t)
ring := New()
node1 := ring.AddNode("A")
node2 := ring.AddNode("B")
test.Expect(node1.vnodeStart).ToEqual(uint32(0))
test.Expect(node2.vnodeStart).ToEqual(uint32(2147483137))
}
开发者ID:benmills,项目名称:library,代码行数:10,代码来源:ring_test.go
示例10: TestGetPeerWithNoPeer
func TestGetPeerWithNoPeer(t *testing.T) {
test := quiz.Test(t)
node := testNode()
defer node.Close()
statusCode, _ := httpclient.Get(node.URL+"/peers", "")
test.Expect(statusCode).ToEqual(404)
}
开发者ID:benmills,项目名称:library,代码行数:10,代码来源:peer_test.go
示例11: TestFetchUnknownKey
func TestFetchUnknownKey(t *testing.T) {
test := quiz.Test(t)
server := testServer()
defer server.Close()
statusCode, _ := httpclient.Get(server.URL+"/data/mykey", "bar")
test.Expect(statusCode).ToEqual(404)
}
开发者ID:benmills,项目名称:goak,代码行数:10,代码来源:server_test.go
示例12: TestNodesSpiltVnodeMaxCount
func TestNodesSpiltVnodeMaxCount(t *testing.T) {
test := quiz.Test(t)
ring := New()
node1 := ring.AddNode("A")
node2 := ring.AddNode("B")
test.Expect(node1.vnodeCount).ToEqual(512)
test.Expect(node2.vnodeCount).ToEqual(512)
}
开发者ID:benmills,项目名称:library,代码行数:10,代码来源:ring_test.go
示例13: TestSetNodes
func TestSetNodes(t *testing.T) {
test := quiz.Test(t)
ring := New()
ring.SetNodes([]string{"A", "B", "C"})
test.Expect(ring.GetNodes()[0]).ToEqual("A")
test.Expect(ring.GetNodes()[1]).ToEqual("B")
test.Expect(ring.GetNodes()[2]).ToEqual("C")
}
开发者ID:benmills,项目名称:library,代码行数:10,代码来源:ring_test.go
示例14: TestNodeDoesntOwnsKeyOutsideVnodeRange
func TestNodeDoesntOwnsKeyOutsideVnodeRange(t *testing.T) {
test := quiz.Test(t)
node := &Node{
vnodeCount: 1,
vnodeSize: 1,
vnodeStart: 0,
}
test.Expect(node.OwnsKeyHash(2)).ToBeFalse()
}
开发者ID:benmills,项目名称:goak,代码行数:11,代码来源:node_test.go
示例15: TestNodeOwnsKeyInbetweenVnodeRange
func TestNodeOwnsKeyInbetweenVnodeRange(t *testing.T) {
test := quiz.Test(t)
node := &Node{
vnodeCount: 1,
vnodeSize: 10,
vnodeStart: 0,
}
test.Expect(node.OwnsKeyHash(7)).ToBeTrue()
}
开发者ID:benmills,项目名称:goak,代码行数:11,代码来源:node_test.go
示例16: TestNodeDoesntOwnKeyBelowVnodeStart
func TestNodeDoesntOwnKeyBelowVnodeStart(t *testing.T) {
test := quiz.Test(t)
node := &Node{
vnodeCount: 1,
vnodeSize: 10,
vnodeStart: 10,
}
test.Expect(node.OwnsKeyHash(7)).ToBeFalse()
}
开发者ID:benmills,项目名称:goak,代码行数:11,代码来源:node_test.go
示例17: TestNodeOwnsKeyIfKeyIsVnodeStart
func TestNodeOwnsKeyIfKeyIsVnodeStart(t *testing.T) {
test := quiz.Test(t)
node := &Node{
vnodeCount: 1,
vnodeSize: 1,
vnodeStart: 0,
}
test.Expect(node.OwnsKeyHash(0)).ToBeTrue()
}
开发者ID:benmills,项目名称:goak,代码行数:11,代码来源:node_test.go
示例18: TestAddAKey
func TestAddAKey(t *testing.T) {
test := quiz.Test(t)
server := testServer()
defer server.Close()
statusCode, body := httpclient.Put(server.URL+"/data/mykey", "bar")
test.Expect(statusCode).ToEqual(201)
test.Expect(body).ToEqual("bar")
}
开发者ID:benmills,项目名称:goak,代码行数:11,代码来源:server_test.go
示例19: TestGetNodes
func TestGetNodes(t *testing.T) {
test := quiz.Test(t)
ring := New()
ring.AddNode("A")
ring.AddNode("B")
ring.AddNode("C")
test.Expect(ring.GetNodes()[0]).ToEqual("A")
test.Expect(ring.GetNodes()[1]).ToEqual("B")
test.Expect(ring.GetNodes()[2]).ToEqual("C")
}
开发者ID:benmills,项目名称:library,代码行数:12,代码来源:ring_test.go
示例20: TestNodeNext
func TestNodeNext(t *testing.T) {
test := quiz.Test(t)
ring := New()
a := ring.AddNode("A")
b := ring.AddNode("B")
c := ring.AddNode("C")
test.Expect(a.next).ToEqual(b)
test.Expect(b.next).ToEqual(c)
test.Expect(c.next).ToEqual(a)
}
开发者ID:benmills,项目名称:library,代码行数:12,代码来源:ring_test.go
注:本文中的github.com/benmills/quiz.Test函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论