MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestGetNLess

Function TestGetNLess

consistent/consistent_test.go:510–533  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

508}
509
510func TestGetNLess(t *testing.T) {
511 kms.Unittest = true
512 utils.RemoveAll(testStorePath + "*")
513 kms.ResetBucket()
514
515 x, _ := InitConsistent(testStorePath, new(KMSStorage), false)
516 defer utils.RemoveAll(testStorePath + "*")
517 x.Add(NewNodeFromString("0000000000000000000000000000000000000000000000000000000000000000"))
518 x.Add(NewNodeFromString("1111111111111111111111111111111111111111111111111111111111111111"))
519 x.Add(NewNodeFromString("2222222222222222222222222222222222222222222222222222222222222222"))
520 members, err := x.GetNeighbors("9999999999999999999999999999999999999999999999999999999999999999", 2)
521 if err != nil {
522 t.Fatal(err)
523 }
524 if len(members) != 2 {
525 t.Errorf("expected 2 members instead of %d", len(members))
526 }
527 if members[0].ID != "0000000000000000000000000000000000000000000000000000000000000000" {
528 t.Errorf("wrong members[0]: %v", members[0])
529 }
530 if members[1].ID != "1111111111111111111111111111111111111111111111111111111111111111" {
531 t.Errorf("wrong members[1]: %v", members[1])
532 }
533}
534
535func TestGetNMore(t *testing.T) {
536 kms.Unittest = true

Callers

nothing calls this directly

Calls 8

RemoveAllFunction · 0.92
ResetBucketFunction · 0.92
InitConsistentFunction · 0.85
NewNodeFromStringFunction · 0.85
GetNeighborsMethod · 0.80
FatalMethod · 0.80
ErrorfMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected