From 5866471a0726e3dbab1d7e57e0074cacd07858e5 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Wed, 7 Aug 2013 13:18:07 +0200 Subject: [PATCH] test delta cache with SetLinearImport --- cache/delta_test.go | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/cache/delta_test.go b/cache/delta_test.go index 405fbc8..6d1de85 100644 --- a/cache/delta_test.go +++ b/cache/delta_test.go @@ -20,6 +20,14 @@ func mknode(id int64) element.Node { } func TestReadWriteDeltaCoords(t *testing.T) { + checkReadWriteDeltaCoords(t, false) +} + +func TestReadWriteDeltaCoordsLinearImport(t *testing.T) { + checkReadWriteDeltaCoords(t, true) +} + +func checkReadWriteDeltaCoords(t *testing.T, withLinearImport bool) { cache_dir, _ := ioutil.TempDir("", "goposm_test") defer os.RemoveAll(cache_dir) @@ -28,6 +36,10 @@ func TestReadWriteDeltaCoords(t *testing.T) { t.Fatal() } + if withLinearImport { + cache.SetLinearImport(true) + } + // create list with nodes from Id 0->999 in random order nodeIds := rand.Perm(1000) nodes := make([]element.Node, 1000) @@ -42,11 +54,8 @@ func TestReadWriteDeltaCoords(t *testing.T) { cache.PutCoords(nodes[i : i+10]) } - cache.Close() - - cache, err = newDeltaCoordsCache(cache_dir) - if err != nil { - t.Fatal() + if withLinearImport { + cache.SetLinearImport(false) } for i := 0; i < len(nodes); i++ { @@ -68,12 +77,6 @@ func TestReadWriteDeltaCoords(t *testing.T) { // test delete cache.PutCoords([]element.Node{mknode(999999)}) - cache.Close() - - cache, err = newDeltaCoordsCache(cache_dir) - if err != nil { - t.Fatal() - } _, err = cache.GetCoord(999999) if err == NotFound { @@ -83,17 +86,4 @@ func TestReadWriteDeltaCoords(t *testing.T) { if err != nil { t.Fatal(err) } - cache.Close() - - cache, err = newDeltaCoordsCache(cache_dir) - if err != nil { - t.Fatal() - } - defer cache.Close() - - _, err = cache.GetCoord(999999) - if err != NotFound { - t.Fatal("deleted node returned not NotFound") - } - }