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

Side by Side Diff: logdog/appengine/coordinator/endpoints/registration/registerPrefix_test.go

Issue 2991253004: [logdog] Remove list functionality. (Closed)
Patch Set: fix test Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 10 matching lines...) Expand all
21 21
22 "github.com/luci/gae/filter/featureBreaker" 22 "github.com/luci/gae/filter/featureBreaker"
23 ds "github.com/luci/gae/service/datastore" 23 ds "github.com/luci/gae/service/datastore"
24 "github.com/luci/luci-go/common/clock" 24 "github.com/luci/luci-go/common/clock"
25 "github.com/luci/luci-go/common/data/rand/cryptorand" 25 "github.com/luci/luci-go/common/data/rand/cryptorand"
26 "github.com/luci/luci-go/common/proto/google" 26 "github.com/luci/luci-go/common/proto/google"
27 "github.com/luci/luci-go/logdog/api/config/svcconfig" 27 "github.com/luci/luci-go/logdog/api/config/svcconfig"
28 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/registration/v 1" 28 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/registration/v 1"
29 "github.com/luci/luci-go/logdog/appengine/coordinator" 29 "github.com/luci/luci-go/logdog/appengine/coordinator"
30 ct "github.com/luci/luci-go/logdog/appengine/coordinator/coordinatorTest " 30 ct "github.com/luci/luci-go/logdog/appengine/coordinator/coordinatorTest "
31 "github.com/luci/luci-go/logdog/appengine/coordinator/hierarchy"
32 "github.com/luci/luci-go/logdog/common/types" 31 "github.com/luci/luci-go/logdog/common/types"
33 "github.com/luci/luci-go/luci_config/common/cfgtypes" 32 "github.com/luci/luci-go/luci_config/common/cfgtypes"
34 33
35 "golang.org/x/net/context" 34 "golang.org/x/net/context"
36 35
37 . "github.com/luci/luci-go/common/testing/assertions" 36 . "github.com/luci/luci-go/common/testing/assertions"
38 . "github.com/smartystreets/goconvey/convey" 37 . "github.com/smartystreets/goconvey/convey"
39 ) 38 )
40 39
41 func TestRegisterPrefix(t *testing.T) { 40 func TestRegisterPrefix(t *testing.T) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ID: pfx.ID, 105 ID: pfx.ID,
107 Prefix: "testing/prefix", 106 Prefix: "testing/prefix",
108 Created: ds.RoundTime(clock.Now(c)), 107 Created: ds.RoundTime(clock.Now(c)),
109 Source: []string{"unit test"}, 108 Source: []string{"unit test"},
110 Secret: randSecret, 109 Secret: randSecret,
111 110
112 // 24 hours is default service prefix expiration . 111 // 24 hours is default service prefix expiration .
113 Expiration: ds.RoundTime(clock.Now(c).Add(24 * t ime.Hour)), 112 Expiration: ds.RoundTime(clock.Now(c).Add(24 * t ime.Hour)),
114 }) 113 })
115 114
116 // Should have registered path components.
117 getComponents := func(b string) []string {
118 l, err := hierarchy.Get(c, hierarchy.Request{Pro ject: "proj-foo", PathBase: b})
119 if err != nil {
120 panic(err)
121 }
122 names := make([]string, len(l.Comp))
123 for i, e := range l.Comp {
124 names[i] = e.Name
125 }
126 return names
127 }
128 So(getComponents(""), ShouldResemble, []string{"testing" })
129 So(getComponents("testing"), ShouldResemble, []string{"p refix"})
130 So(getComponents("testing/prefix"), ShouldResemble, []st ring{"+"})
131 So(getComponents("testing/prefix/+"), ShouldResemble, [] string{})
132
133 Convey(`Will refuse to register it again.`, func() { 115 Convey(`Will refuse to register it again.`, func() {
134 _, err := svr.RegisterPrefix(c, &req) 116 _, err := svr.RegisterPrefix(c, &req)
135 So(err, ShouldBeRPCAlreadyExists) 117 So(err, ShouldBeRPCAlreadyExists)
136 }) 118 })
137 }) 119 })
138 120
139 Convey(`Uses the correct prefix expiration`, func() { 121 Convey(`Uses the correct prefix expiration`, func() {
140 122
141 Convey(`When service, project, and request have expirati on, chooses smallest.`, func() { 123 Convey(`When service, project, and request have expirati on, chooses smallest.`, func() {
142 env.ModProjectConfig(c, project, func(pcfg *svcc onfig.ProjectConfig) { 124 env.ModProjectConfig(c, project, func(pcfg *svcc onfig.ProjectConfig) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 }) 159 })
178 }) 160 })
179 161
180 Convey(`Will fail to register the prefix if Put is broken.`, fun c() { 162 Convey(`Will fail to register the prefix if Put is broken.`, fun c() {
181 fb.BreakFeatures(errors.New("test error"), "PutMulti") 163 fb.BreakFeatures(errors.New("test error"), "PutMulti")
182 _, err := svr.RegisterPrefix(c, &req) 164 _, err := svr.RegisterPrefix(c, &req)
183 So(err, ShouldBeRPCInternal) 165 So(err, ShouldBeRPCInternal)
184 }) 166 })
185 }) 167 })
186 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698