本文整理匯總了Golang中github.com/benmills/quiz.Test函數的典型用法代碼示例。如果您正苦於以下問題:Golang Test函數的具體用法?Golang Test怎麽用?Golang Test使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Test函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
}
示例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")
}
示例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`)
}
示例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()
}
示例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")
}
示例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)
}
示例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)
}
示例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)
}
示例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))
}
示例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)
}
示例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)
}
示例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)
}
示例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")
}
示例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()
}
示例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()
}