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