| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package coordinatorTest | |
| 6 | |
| 7 import ( | |
| 8 "fmt" | |
| 9 | |
| 10 "github.com/golang/protobuf/proto" | |
| 11 "github.com/luci/luci-go/appengine/logdog/coordinator/config" | |
| 12 "github.com/luci/luci-go/common/config/impl/memory" | |
| 13 "github.com/luci/luci-go/common/proto/logdog/svcconfig" | |
| 14 "github.com/luci/luci-go/server/settings" | |
| 15 "golang.org/x/net/context" | |
| 16 ) | |
| 17 | |
| 18 // UseConfig installs a Coordinator configuration into the current context. | |
| 19 func UseConfig(c context.Context, cc *svcconfig.Coordinator) context.Context { | |
| 20 c = settings.Use(c, settings.New(&settings.MemoryStorage{})) | |
| 21 gcfg := config.GlobalConfig{ | |
| 22 ConfigServiceURL: "https://example.com", | |
| 23 ConfigSet: "services/logdog-test", | |
| 24 ConfigPath: "coordinator-test.cfg", | |
| 25 } | |
| 26 if err := gcfg.Store(c, "test setup"); err != nil { | |
| 27 panic(fmt.Errorf("failed to store test configuration: %v", err)) | |
| 28 } | |
| 29 | |
| 30 cmap := map[string]memory.ConfigSet{ | |
| 31 "services/logdog-test": map[string]string{}, | |
| 32 } | |
| 33 if cc != nil { | |
| 34 cfg := svcconfig.Config{ | |
| 35 Coordinator: cc, | |
| 36 } | |
| 37 cmap["services/logdog-test"]["coordinator-test.cfg"] = proto.Mar
shalTextString(&cfg) | |
| 38 } | |
| 39 return memory.Use(c, cmap) | |
| 40 } | |
| OLD | NEW |