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

Side by Side Diff: dm/appengine/distributor/fake/fake.go

Issue 2575383002: Add server/cache support to gaeconfig. (Closed)
Patch Set: Un-collapse. Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « dm/appengine/deps/auth.go ('k') | dm/appengine/distributor/registry.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package fake 5 package fake
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "fmt" 9 "fmt"
10 "net/http" 10 "net/http"
11 "sync" 11 "sync"
12 "time" 12 "time"
13 13
14 "github.com/golang/protobuf/proto"
15 "github.com/luci/luci-go/common/config"
16 config_mem "github.com/luci/luci-go/common/config/impl/memory" 14 config_mem "github.com/luci/luci-go/common/config/impl/memory"
17 "github.com/luci/luci-go/common/gcloud/pubsub" 15 "github.com/luci/luci-go/common/gcloud/pubsub"
18 googlepb "github.com/luci/luci-go/common/proto/google" 16 googlepb "github.com/luci/luci-go/common/proto/google"
19 "github.com/luci/luci-go/common/testing/assertions" 17 "github.com/luci/luci-go/common/testing/assertions"
20 dm "github.com/luci/luci-go/dm/api/service/v1" 18 dm "github.com/luci/luci-go/dm/api/service/v1"
21 "github.com/luci/luci-go/dm/appengine/distributor" 19 "github.com/luci/luci-go/dm/appengine/distributor"
22 "github.com/luci/luci-go/dm/appengine/model" 20 "github.com/luci/luci-go/dm/appengine/model"
21 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig "
23 "github.com/luci/luci-go/server/auth" 22 "github.com/luci/luci-go/server/auth"
24 "github.com/luci/luci-go/server/auth/authtest" 23 "github.com/luci/luci-go/server/auth/authtest"
25 "github.com/luci/luci-go/server/auth/identity" 24 "github.com/luci/luci-go/server/auth/identity"
26 "github.com/luci/luci-go/server/secrets/testsecrets" 25 "github.com/luci/luci-go/server/secrets/testsecrets"
27 "github.com/luci/luci-go/tumble" 26 "github.com/luci/luci-go/tumble"
27
28 "github.com/golang/protobuf/proto"
28 "github.com/smartystreets/goconvey/convey" 29 "github.com/smartystreets/goconvey/convey"
29 "golang.org/x/net/context" 30 "golang.org/x/net/context"
30 ) 31 )
31 32
32 // Setup creates a new combination of testing and context objects: 33 // Setup creates a new combination of testing and context objects:
33 // * ttest - a tumble.Testing to allow you to control tumble's processing 34 // * ttest - a tumble.Testing to allow you to control tumble's processing
34 // state 35 // state
35 // * c - a context which includes a testing distributor registry, testsecrets, 36 // * c - a context which includes a testing distributor registry, testsecrets,
36 // as well as everything that tumble.Testing.Context adds (datastore, 37 // as well as everything that tumble.Testing.Context adds (datastore,
37 // memcache, etc.) 38 // memcache, etc.)
(...skipping 10 matching lines...) Expand all
48 // writers: "writer_group" 49 // writers: "writer_group"
49 // 50 //
50 // Usage: 51 // Usage:
51 // ttest, c, dist := fake.Setup(mutate.FinishExecutionFn) 52 // ttest, c, dist := fake.Setup(mutate.FinishExecutionFn)
52 // s := deps.NewDecoratedServer() 53 // s := deps.NewDecoratedServer()
53 // # your tests 54 // # your tests
54 func Setup(fn distributor.FinishExecutionFn) (ttest *tumble.Testing, c context.C ontext, dist *Distributor) { 55 func Setup(fn distributor.FinishExecutionFn) (ttest *tumble.Testing, c context.C ontext, dist *Distributor) {
55 ttest = &tumble.Testing{} 56 ttest = &tumble.Testing{}
56 c = ttest.Context() 57 c = ttest.Context()
57 c = testsecrets.Use(c) 58 c = testsecrets.Use(c)
58 » c = config.SetImplementation(c, config_mem.New(map[string]config_mem.Con figSet{ 59
60 » c = testconfig.WithCommonClient(c, config_mem.New(map[string]config_mem. ConfigSet{
59 "services/app": { 61 "services/app": {
60 "acls.cfg": ` 62 "acls.cfg": `
61 » » » readers: "reader_group" 63 » » » » readers: "reader_group"
62 » » » writers: "writer_group" 64 » » » » writers: "writer_group"
63 `, 65 `,
64 }, 66 },
65 })) 67 }))
66 c = auth.WithState(c, &authtest.FakeState{ 68 c = auth.WithState(c, &authtest.FakeState{
67 Identity: identity.AnonymousIdentity, 69 Identity: identity.AnonymousIdentity,
68 }) 70 })
69 dist = &Distributor{} 71 dist = &Distributor{}
70 reg := distributor.NewTestingRegistry(distributor.TestFactoryMap{ 72 reg := distributor.NewTestingRegistry(distributor.TestFactoryMap{
71 "fakeDistributor": func(c context.Context, cfg *distributor.Conf ig) distributor.D { 73 "fakeDistributor": func(c context.Context, cfg *distributor.Conf ig) distributor.D {
72 return &BoundDistributor{dist, c, cfg} 74 return &BoundDistributor{dist, c, cfg}
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 panic(fmt.Errorf("expected 1 arg on rhs, got %d", len(ex pect))) 486 panic(fmt.Errorf("expected 1 arg on rhs, got %d", len(ex pect)))
485 } 487 }
486 e := expect[0].(*dm.GraphData) 488 e := expect[0].(*dm.GraphData)
487 ret, err := s.WalkGraph(c, r) 489 ret, err := s.WalkGraph(c, r)
488 if nilExpect := assertions.ShouldErrLike(err, nil); nilExpect != "" { 490 if nilExpect := assertions.ShouldErrLike(err, nil); nilExpect != "" {
489 return nilExpect 491 return nilExpect
490 } 492 }
491 return convey.ShouldResemble(normalize(ret), e) 493 return convey.ShouldResemble(normalize(ret), e)
492 } 494 }
493 } 495 }
OLDNEW
« no previous file with comments | « dm/appengine/deps/auth.go ('k') | dm/appengine/distributor/registry.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698