func TestEngine(t *testing.T, n string, e storage.Engine) { p := "test" k := "hello" v := "world" if err := e.Set(p, k, []byte(v)); err != nil { t.Fatal(err) } b, err := e.Get(p, k) if err != nil { t.Fatal(err) } if string(b) != v { t.Errorf("%s: expected %s, got %s", n, v, string(b)) } id, err := e.Incr(p, "counter") if err != nil { t.Fatalf("%s: incr error %s", n, err) } if id != 1 { t.Errorf("%s: expected 1, got %v", n, id) } id, err = e.Incr(p, "counter") if err != nil { t.Fatalf("%s: incr error %s", n, err) } if id != 2 { t.Errorf("%s: expected 2, got %v", n, id) } if err = e.Delete(p, "counter"); err != nil { t.Errorf("%s: %s", n, err) } if v, err := e.Get(p, "counter"); v != nil { t.Errorf("%s: expected delete", n) } else if err != nil { t.Errorf("%s: %s", n, err) } }
func BenchmarkEngineDelete(b *testing.B, n string, e storage.Engine) { p := "test" k := "data" // Mimicking a 1000 facts at 150 bytes each v := randSeq(150 * 1000) b.ResetTimer() for i := 0; i < b.N; i++ { b.StopTimer() e.Set(p, k, v) b.StartTimer() e.Delete(p, k) } }