| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package settings |
| 6 |
| 7 import ( |
| 8 "strings" |
| 9 "testing" |
| 10 |
| 11 "github.com/luci/gae/impl/memory" |
| 12 lucicfg "github.com/luci/luci-go/common/config" |
| 13 memcfg "github.com/luci/luci-go/common/config/impl/memory" |
| 14 "github.com/luci/luci-go/common/logging/gologger" |
| 15 "golang.org/x/net/context" |
| 16 |
| 17 . "github.com/smartystreets/goconvey/convey" |
| 18 ) |
| 19 |
| 20 func TestConfig(t *testing.T) { |
| 21 t.Parallel() |
| 22 |
| 23 Convey("Test Environment", t, func() { |
| 24 c := memory.UseWithAppID(context.Background(), "dev~luci-milo") |
| 25 c = gologger.StdConfig.Use(c) |
| 26 |
| 27 Convey("Send update", func() { |
| 28 c = lucicfg.SetImplementation(c, memcfg.New(mockedConfig
s)) |
| 29 // Send update here |
| 30 err := update(c) |
| 31 So(err, ShouldBeNil) |
| 32 |
| 33 Convey("Check Project config updated", func() { |
| 34 p, err := GetProject(c, "foo") |
| 35 So(err, ShouldBeNil) |
| 36 So(p.ID, ShouldEqual, "foo") |
| 37 So(p.Readers, ShouldResemble, []string{"public",
"foo@bar.com"}) |
| 38 So(p.Writers, ShouldResemble, []string(nil)) |
| 39 }) |
| 40 |
| 41 Convey("Check Console config updated", func() { |
| 42 cs, err := GetConsole(c, "foo", "default") |
| 43 So(err, ShouldBeNil) |
| 44 So(cs.Name, ShouldEqual, "default") |
| 45 So(cs.RepoURL, ShouldEqual, "https://chromium.go
oglesource.com/foo/bar") |
| 46 }) |
| 47 }) |
| 48 |
| 49 Convey("Reject duplicate configs.", func() { |
| 50 mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"lu
ci-milo.cfg": barCfg} |
| 51 c = lucicfg.SetImplementation(c, memcfg.New(mockedConfig
s)) |
| 52 err := update(c) |
| 53 So(strings.HasPrefix(err.Error(), "Duplicate project ID"
), ShouldEqual, true) |
| 54 }) |
| 55 }) |
| 56 } |
| 57 |
| 58 var fooCfg = ` |
| 59 ID: "foo" |
| 60 Readers: "public" |
| 61 Readers: "foo@bar.com" |
| 62 Consoles: { |
| 63 Name: "default" |
| 64 RepoURL: "https://chromium.googlesource.com/foo/bar" |
| 65 Branch: "master" |
| 66 Builders: { |
| 67 Module: "buildbucket" |
| 68 Name: "luci.foo.something" |
| 69 Category: "main|something" |
| 70 ShortName: "s" |
| 71 } |
| 72 Builders: { |
| 73 Module: "buildbucket" |
| 74 Name: "luci.foo.other" |
| 75 Category: "main|other" |
| 76 ShortName: "o" |
| 77 } |
| 78 } |
| 79 ` |
| 80 |
| 81 var barCfg = ` |
| 82 ID: "foo" |
| 83 ` |
| 84 |
| 85 var mockedConfigs = map[string]memcfg.ConfigSet{ |
| 86 "projects/foo.git": { |
| 87 "luci-milo.cfg": fooCfg, |
| 88 }, |
| 89 } |
| OLD | NEW |