| 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 common | 5 package common |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "strings" | 9 "strings" |
| 10 "testing" | 10 "testing" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 err := UpdateServiceConfig(c) | 51 err := UpdateServiceConfig(c) |
| 52 So(err, ShouldBeNil) | 52 So(err, ShouldBeNil) |
| 53 // Send update here | 53 // Send update here |
| 54 err = UpdateProjectConfigs(c) | 54 err = UpdateProjectConfigs(c) |
| 55 So(err, ShouldBeNil) | 55 So(err, ShouldBeNil) |
| 56 | 56 |
| 57 Convey("Check Project config updated", func() { | 57 Convey("Check Project config updated", func() { |
| 58 p, err := GetProject(c, "foo") | 58 p, err := GetProject(c, "foo") |
| 59 So(err, ShouldBeNil) | 59 So(err, ShouldBeNil) |
| 60 So(p.ID, ShouldEqual, "foo") | 60 So(p.ID, ShouldEqual, "foo") |
| 61 So(p.Readers, ShouldResemble, []string{"public",
"foo@bar.com"}) | |
| 62 So(p.Writers, ShouldResemble, []string(nil)) | |
| 63 }) | 61 }) |
| 64 | 62 |
| 65 Convey("Check Console config updated", func() { | 63 Convey("Check Console config updated", func() { |
| 66 cs, err := GetConsole(c, "foo", "default") | 64 cs, err := GetConsole(c, "foo", "default") |
| 67 So(err, ShouldBeNil) | 65 So(err, ShouldBeNil) |
| 68 So(cs.Name, ShouldEqual, "default") | 66 So(cs.Name, ShouldEqual, "default") |
| 69 So(cs.RepoURL, ShouldEqual, "https://chromium.go
oglesource.com/foo/bar") | 67 So(cs.RepoURL, ShouldEqual, "https://chromium.go
oglesource.com/foo/bar") |
| 70 }) | 68 }) |
| 71 }) | 69 }) |
| 72 | 70 |
| 73 Convey("Reject duplicate configs.", func() { | 71 Convey("Reject duplicate configs.", func() { |
| 74 c = testconfig.WithCommonClient(c, memcfg.New(mockedConf
igs)) | 72 c = testconfig.WithCommonClient(c, memcfg.New(mockedConf
igs)) |
| 75 err := UpdateServiceConfig(c) | 73 err := UpdateServiceConfig(c) |
| 76 So(err, ShouldBeNil) | 74 So(err, ShouldBeNil) |
| 77 mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"lu
ci-milo.cfg": barCfg} | 75 mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"lu
ci-milo.cfg": barCfg} |
| 78 | 76 |
| 79 err = UpdateProjectConfigs(c) | 77 err = UpdateProjectConfigs(c) |
| 80 So(strings.HasPrefix(err.Error(), "Duplicate project ID"
), ShouldEqual, true) | 78 So(strings.HasPrefix(err.Error(), "Duplicate project ID"
), ShouldEqual, true) |
| 81 }) | 79 }) |
| 82 }) | 80 }) |
| 83 } | 81 } |
| 84 | 82 |
| 85 var fooCfg = ` | 83 var fooCfg = ` |
| 86 ID: "foo" | 84 ID: "foo" |
| 87 Readers: "public" | |
| 88 Readers: "foo@bar.com" | |
| 89 Consoles: { | 85 Consoles: { |
| 90 Name: "default" | 86 Name: "default" |
| 91 RepoURL: "https://chromium.googlesource.com/foo/bar" | 87 RepoURL: "https://chromium.googlesource.com/foo/bar" |
| 92 Branch: "master" | 88 Branch: "master" |
| 93 Builders: { | 89 Builders: { |
| 94 » » Module: "buildbucket" | 90 » » Name: "buildbucket/luci.foo.something/bar" |
| 95 » » Name: "luci.foo.something" | |
| 96 Category: "main|something" | 91 Category: "main|something" |
| 97 ShortName: "s" | 92 ShortName: "s" |
| 98 } | 93 } |
| 99 Builders: { | 94 Builders: { |
| 100 » » Module: "buildbucket" | 95 » » Name: "buildbucket/luci.foo.other/baz" |
| 101 » » Name: "luci.foo.other" | |
| 102 Category: "main|other" | 96 Category: "main|other" |
| 103 ShortName: "o" | 97 ShortName: "o" |
| 104 } | 98 } |
| 105 } | 99 } |
| 106 ` | 100 ` |
| 107 | 101 |
| 108 var barCfg = ` | 102 var barCfg = ` |
| 109 ID: "foo" | 103 ID: "foo" |
| 110 ` | 104 ` |
| 111 | 105 |
| 112 var settingsCfg = ` | 106 var settingsCfg = ` |
| 113 buildbot: { | 107 buildbot: { |
| 114 internal_reader: "googlers" | 108 internal_reader: "googlers" |
| 115 } | 109 } |
| 116 ` | 110 ` |
| 117 | 111 |
| 118 var mockedConfigs = map[string]memcfg.ConfigSet{ | 112 var mockedConfigs = map[string]memcfg.ConfigSet{ |
| 119 "projects/foo.git": { | 113 "projects/foo.git": { |
| 120 "luci-milo.cfg": fooCfg, | 114 "luci-milo.cfg": fooCfg, |
| 121 }, | 115 }, |
| 122 } | 116 } |
| OLD | NEW |