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

Unified Diff: appengine/cmd/dm/distributor/test_registry.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: fix imports and make dummy.go a real file Created 4 years, 6 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 | « appengine/cmd/dm/distributor/task_description.go ('k') | appengine/cmd/dm/distributor/tq_handler.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cmd/dm/distributor/test_registry.go
diff --git a/appengine/cmd/dm/distributor/test_registry.go b/appengine/cmd/dm/distributor/test_registry.go
new file mode 100644
index 0000000000000000000000000000000000000000..ab7f94fba3f1f1b5d9a1e34ae8d9e54610014a73
--- /dev/null
+++ b/appengine/cmd/dm/distributor/test_registry.go
@@ -0,0 +1,40 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package distributor
+
+import (
+ "fmt"
+
+ "github.com/luci/luci-go/appengine/tumble"
+ "github.com/luci/luci-go/common/api/dm/service/v1"
+ "golang.org/x/net/context"
+)
+
+type testRegistry struct {
+ finishExecutionImpl FinishExecutionFn
+ data map[string]D
+}
+
+var _ Registry = (*testRegistry)(nil)
+
+// NewTestingRegistry returns a new testing registry.
+//
+// The mocks dictionary maps from cfgName to a mock implementation of the
+// distributor.
+func NewTestingRegistry(mocks map[string]D, fFn FinishExecutionFn) Registry {
+ return &testRegistry{fFn, mocks}
+}
+
+func (t *testRegistry) FinishExecution(c context.Context, eid *dm.Execution_ID, rslt *TaskResult) ([]tumble.Mutation, error) {
+ return t.finishExecutionImpl(c, eid, rslt)
+}
+
+func (t *testRegistry) MakeDistributor(_ context.Context, cfgName string) (D, string, error) {
+ ret, ok := t.data[cfgName]
+ if !ok {
+ return nil, "", fmt.Errorf("unknown distributor configuration: %q", cfgName)
+ }
+ return ret, "testing", nil
+}
« no previous file with comments | « appengine/cmd/dm/distributor/task_description.go ('k') | appengine/cmd/dm/distributor/tq_handler.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698