graph: make quadstore init functions idempotent
This commit is contained in:
parent
9658689995
commit
e849da9402
7 changed files with 63 additions and 24 deletions
|
|
@ -153,10 +153,9 @@ func TestLoadDatabase(t *testing.T) {
|
|||
t.Errorf("Unexpected quadstore size, got:%d expect:1", s)
|
||||
}
|
||||
qs.Close()
|
||||
os.RemoveAll(tmpFile.Name())
|
||||
|
||||
err = createNewBolt(tmpFile.Name(), nil)
|
||||
if err != nil {
|
||||
if err != graph.ErrDatabaseExists {
|
||||
t.Fatal("Failed to create Bolt database.", err)
|
||||
}
|
||||
qs, err = newQuadStore(tmpFile.Name(), nil)
|
||||
|
|
@ -172,20 +171,20 @@ func TestLoadDatabase(t *testing.T) {
|
|||
|
||||
//Test horizon
|
||||
horizon := qs.Horizon()
|
||||
if horizon.Int() != 0 {
|
||||
t.Errorf("Unexpected horizon value, got:%d expect:0", horizon.Int())
|
||||
if horizon.Int() != 1 {
|
||||
t.Errorf("Unexpected horizon value, got:%d expect:1", horizon.Int())
|
||||
}
|
||||
|
||||
w.AddQuadSet(makeQuadSet())
|
||||
if s := qs.Size(); s != 11 {
|
||||
t.Errorf("Unexpected quadstore size, got:%d expect:11", s)
|
||||
if s := qs.Size(); s != 12 {
|
||||
t.Errorf("Unexpected quadstore size, got:%d expect:12", s)
|
||||
}
|
||||
if s := ts2.SizeOf(qs.ValueOf("B")); s != 5 {
|
||||
t.Errorf("Unexpected quadstore size, got:%d expect:5", s)
|
||||
}
|
||||
horizon = qs.Horizon()
|
||||
if horizon.Int() != 11 {
|
||||
t.Errorf("Unexpected horizon value, got:%d expect:11", horizon.Int())
|
||||
if horizon.Int() != 12 {
|
||||
t.Errorf("Unexpected horizon value, got:%d expect:12", horizon.Int())
|
||||
}
|
||||
|
||||
w.RemoveQuad(quad.Quad{
|
||||
|
|
@ -194,8 +193,8 @@ func TestLoadDatabase(t *testing.T) {
|
|||
Object: "B",
|
||||
Label: "",
|
||||
})
|
||||
if s := qs.Size(); s != 10 {
|
||||
t.Errorf("Unexpected quadstore size after RemoveQuad, got:%d expect:10", s)
|
||||
if s := qs.Size(); s != 11 {
|
||||
t.Errorf("Unexpected quadstore size after RemoveQuad, got:%d expect:11", s)
|
||||
}
|
||||
if s := ts2.SizeOf(qs.ValueOf("B")); s != 4 {
|
||||
t.Errorf("Unexpected quadstore size, got:%d expect:4", s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue