| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 cfgclient | 5 package cfgclient |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/url" | 9 "net/url" |
| 10 "testing" | 10 "testing" |
| 11 | 11 |
| 12 "github.com/luci/luci-go/common/config" |
| 12 "github.com/luci/luci-go/common/errors" | 13 "github.com/luci/luci-go/common/errors" |
| 13 "github.com/luci/luci-go/luci_config/server/cfgclient/backend" | 14 "github.com/luci/luci-go/luci_config/server/cfgclient/backend" |
| 14 | 15 |
| 15 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
| 16 | 17 |
| 17 . "github.com/smartystreets/goconvey/convey" | 18 . "github.com/smartystreets/goconvey/convey" |
| 18 ) | 19 ) |
| 19 | 20 |
| 20 // testingBackend is a Backend implementation that ignores Authority. | 21 // testingBackend is a Backend implementation that ignores Authority. |
| 21 type testingBackend struct { | 22 type testingBackend struct { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 47 return nil, tb.err | 48 return nil, tb.err |
| 48 } | 49 } |
| 49 return tb.cloneItems(), nil | 50 return tb.cloneItems(), nil |
| 50 } | 51 } |
| 51 | 52 |
| 52 func (tb *testingBackend) ConfigSetURL(c context.Context, configSet string, p ba
ckend.Params) (url.URL, error) { | 53 func (tb *testingBackend) ConfigSetURL(c context.Context, configSet string, p ba
ckend.Params) (url.URL, error) { |
| 53 tb.lastParams = p | 54 tb.lastParams = p |
| 54 return tb.url, tb.err | 55 return tb.url, tb.err |
| 55 } | 56 } |
| 56 | 57 |
| 58 func (tb *testingBackend) GetConfigInterface(c context.Context, a backend.Author
ity) config.Interface { |
| 59 panic("not supported") |
| 60 } |
| 61 |
| 57 func (tb *testingBackend) cloneItems() []*backend.Item { | 62 func (tb *testingBackend) cloneItems() []*backend.Item { |
| 58 clones := make([]*backend.Item, len(tb.items)) | 63 clones := make([]*backend.Item, len(tb.items)) |
| 59 for i, it := range tb.items { | 64 for i, it := range tb.items { |
| 60 clone := *it | 65 clone := *it |
| 61 clones[i] = &clone | 66 clones[i] = &clone |
| 62 } | 67 } |
| 63 return clones | 68 return clones |
| 64 } | 69 } |
| 65 | 70 |
| 66 type errorMultiResolver struct { | 71 type errorMultiResolver struct { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 panic(err) | 224 panic(err) |
| 220 } | 225 } |
| 221 | 226 |
| 222 tb.url = *u | 227 tb.url = *u |
| 223 uv, err := GetConfigSetURL(c, AsService, "") | 228 uv, err := GetConfigSetURL(c, AsService, "") |
| 224 So(err, ShouldBeNil) | 229 So(err, ShouldBeNil) |
| 225 So(uv, ShouldResemble, url.URL{Scheme: "https", Host: "e
xample.com", Path: "/foo/bar"}) | 230 So(uv, ShouldResemble, url.URL{Scheme: "https", Host: "e
xample.com", Path: "/foo/bar"}) |
| 226 }) | 231 }) |
| 227 }) | 232 }) |
| 228 } | 233 } |
| OLD | NEW |