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

Side by Side Diff: milo/common/config_test.go

Issue 2980153002: Milo: Fix project importer so it doesn't error out on a bad config (Closed)
Patch Set: Review Created 3 years, 5 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 | « milo/common/config.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. 1 // Copyright 2016 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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 package common 15 package common
16 16
17 import ( 17 import (
18 "errors" 18 "errors"
19 "strings"
20 "testing" 19 "testing"
21 20
22 "github.com/luci/gae/impl/memory" 21 "github.com/luci/gae/impl/memory"
23 memcfg "github.com/luci/luci-go/common/config/impl/memory" 22 memcfg "github.com/luci/luci-go/common/config/impl/memory"
24 "github.com/luci/luci-go/common/logging/gologger" 23 "github.com/luci/luci-go/common/logging/gologger"
25 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig " 24 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig "
26 25
27 "golang.org/x/net/context" 26 "golang.org/x/net/context"
28 27
29 . "github.com/smartystreets/goconvey/convey" 28 . "github.com/smartystreets/goconvey/convey"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 So(p.ID, ShouldEqual, "foo") 70 So(p.ID, ShouldEqual, "foo")
72 }) 71 })
73 72
74 Convey("Check Console config updated", func() { 73 Convey("Check Console config updated", func() {
75 cs, err := GetConsole(c, "foo", "default") 74 cs, err := GetConsole(c, "foo", "default")
76 So(err, ShouldBeNil) 75 So(err, ShouldBeNil)
77 So(cs.Name, ShouldEqual, "default") 76 So(cs.Name, ShouldEqual, "default")
78 So(cs.RepoURL, ShouldEqual, "https://chromium.go oglesource.com/foo/bar") 77 So(cs.RepoURL, ShouldEqual, "https://chromium.go oglesource.com/foo/bar")
79 }) 78 })
80 }) 79 })
81
82 Convey("Reject duplicate configs.", func() {
83 c = testconfig.WithCommonClient(c, memcfg.New(mockedConf igs))
84 _, err := UpdateServiceConfig(c)
85 So(err, ShouldBeNil)
86 mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"lu ci-milo.cfg": barCfg}
87
88 err = UpdateProjectConfigs(c)
89 So(strings.HasPrefix(err.Error(), "Duplicate project ID" ), ShouldEqual, true)
90 })
91 }) 80 })
92 } 81 }
93 82
94 var fooCfg = ` 83 var fooCfg = `
95 ID: "foo" 84 ID: "foo"
96 Consoles: { 85 Consoles: {
97 Name: "default" 86 Name: "default"
98 RepoURL: "https://chromium.googlesource.com/foo/bar" 87 RepoURL: "https://chromium.googlesource.com/foo/bar"
99 Branch: "master" 88 Branch: "master"
100 Builders: { 89 Builders: {
101 Name: "buildbucket/luci.foo.something/bar" 90 Name: "buildbucket/luci.foo.something/bar"
102 Category: "main|something" 91 Category: "main|something"
103 ShortName: "s" 92 ShortName: "s"
104 } 93 }
105 Builders: { 94 Builders: {
106 Name: "buildbucket/luci.foo.other/baz" 95 Name: "buildbucket/luci.foo.other/baz"
107 Category: "main|other" 96 Category: "main|other"
108 ShortName: "o" 97 ShortName: "o"
109 } 98 }
110 } 99 }
111 ` 100 `
112 101
113 var barCfg = `
114 ID: "foo"
115 `
116
117 var settingsCfg = ` 102 var settingsCfg = `
118 buildbot: { 103 buildbot: {
119 internal_reader: "googlers" 104 internal_reader: "googlers"
120 } 105 }
121 ` 106 `
122 107
123 var mockedConfigs = map[string]memcfg.ConfigSet{ 108 var mockedConfigs = map[string]memcfg.ConfigSet{
124 » "projects/foo.git": { 109 » "projects/foo": {
125 "luci-milo.cfg": fooCfg, 110 "luci-milo.cfg": fooCfg,
126 }, 111 },
127 } 112 }
OLDNEW
« no previous file with comments | « milo/common/config.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698