Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Unified Diff: service/datastore/testable.go

Issue 1285703002: Add testable interface for datastore. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fixes after Raw change Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/serialize.go ('k') | service/taskqueue/interface.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/testable.go
diff --git a/service/datastore/testable.go b/service/datastore/testable.go
new file mode 100644
index 0000000000000000000000000000000000000000..5887595f742b02b755476f2cddec4c73793d5cbe
--- /dev/null
+++ b/service/datastore/testable.go
@@ -0,0 +1,36 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package datastore
+
+type TestingSnapshot interface{}
+
+// Testable is the testable interface for fake datastore implementations.
+type Testable interface {
+ // AddIndex adds the provided index.
+ // Blocks all datastore access while the index is built.
+ // Panics if any of the IndexDefinition objects are not Compound()
+ AddIndexes(...*IndexDefinition)
+
+ // TakeIndexSnapshot allows you to take a snapshot of the current index
+ // tables, which can be used later with SetIndexSnapshot.
+ TakeIndexSnapshot() TestingSnapshot
+
+ // SetIndexSnapshot allows you to set the state of the current index tables.
+ // Note that this would allow you to create 'non-lienarities' in the precieved
+ // index results (e.g. you could force the indexes to go back in time).
+ //
+ // SetIndexSnapshot takes a reference of the given TestingSnapshot. You're
+ // still responsible for closing the snapshot after this call.
+ SetIndexSnapshot(TestingSnapshot)
+
+ // CatchupIndexes catches the index table up to the current state of the
+ // datastore. This is equivalent to:
+ // idxSnap := TakeIndexSnapshot()
+ // SetIndexSnapshot(idxSnap)
+ //
+ // But depending on the implementation it may implemented with an atomic
+ // operation.
+ CatchupIndexes()
+}
« no previous file with comments | « service/datastore/serialize.go ('k') | service/taskqueue/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698