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

Function TestGetTwoQuick

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

Source from the content-addressed store, hash-verified

347}
348
349func TestGetTwoQuick(t *testing.T) {
350 kms.Unittest = true
351 utils.RemoveAll(testStorePath + "*")
352 kms.ResetBucket()
353
354 x, _ := InitConsistent(testStorePath, new(KMSStorage), false)
355 defer utils.RemoveAll(testStorePath + "*")
356 x.Add(NewNodeFromString("0000000000000000000000000000000000000000000000000000000000000000"))
357 x.Add(NewNodeFromString("1111111111111111111111111111111111111111111111111111111111111111"))
358 x.Add(NewNodeFromString("2222222222222222222222222222222222222222222222222222222222222222"))
359 f := func(s string) bool {
360 a, b, err := x.GetTwoNeighbors(s)
361 if err != nil {
362 t.Logf("error: %v", err)
363 return false
364 }
365 if a.ID == b.ID {
366 t.Log("a.ID == b.ID")
367 return false
368 }
369 if a.ID != "0000000000000000000000000000000000000000000000000000000000000000" && a.ID != "1111111111111111111111111111111111111111111111111111111111111111" && a.ID != "2222222222222222222222222222222222222222222222222222222222222222" {
370 t.Logf("invalid a: %v", a)
371 return false
372 }
373
374 if b.ID != "0000000000000000000000000000000000000000000000000000000000000000" && b.ID != "1111111111111111111111111111111111111111111111111111111111111111" && b.ID != "2222222222222222222222222222222222222222222222222222222222222222" {
375 t.Logf("invalid b: %v", b)
376 return false
377 }
378 return true
379 }
380 if err := quick.Check(f, nil); err != nil {
381 t.Fatal(err)
382 }
383}
384
385func TestGetTwoOnlyTwoQuick(t *testing.T) {
386 kms.Unittest = true

Callers

nothing calls this directly

Calls 8

RemoveAllFunction · 0.92
ResetBucketFunction · 0.92
InitConsistentFunction · 0.85
NewNodeFromStringFunction · 0.85
GetTwoNeighborsMethod · 0.80
FatalMethod · 0.80
CheckMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected