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

Side by Side Diff: milo/appengine/settings/config_test.go

Issue 2575383002: Add server/cache support to gaeconfig. (Closed)
Patch Set: Un-collapse. Created 3 years, 11 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/appengine/settings/config.go ('k') | scheduler/appengine/catalog/catalog.go » ('j') | 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. 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 settings 5 package settings
6 6
7 import ( 7 import (
8 "strings" 8 "strings"
9 "testing" 9 "testing"
10 10
11 "github.com/luci/gae/impl/memory" 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" 12 memcfg "github.com/luci/luci-go/common/config/impl/memory"
14 "github.com/luci/luci-go/common/logging/gologger" 13 "github.com/luci/luci-go/common/logging/gologger"
14 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig "
15
15 "golang.org/x/net/context" 16 "golang.org/x/net/context"
16 17
17 . "github.com/smartystreets/goconvey/convey" 18 . "github.com/smartystreets/goconvey/convey"
18 ) 19 )
19 20
20 func TestConfig(t *testing.T) { 21 func TestConfig(t *testing.T) {
21 t.Parallel() 22 t.Parallel()
22 23
23 Convey("Test Environment", t, func() { 24 Convey("Test Environment", t, func() {
24 c := memory.UseWithAppID(context.Background(), "dev~luci-milo") 25 c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
25 c = gologger.StdConfig.Use(c) 26 c = gologger.StdConfig.Use(c)
27 c = testconfig.WithCommonClient(c, memcfg.New(mockedConfigs))
26 28
27 Convey("Send update", func() { 29 Convey("Send update", func() {
28 c = lucicfg.SetImplementation(c, memcfg.New(mockedConfig s))
29 // Send update here 30 // Send update here
30 err := Update(c) 31 err := Update(c)
31 So(err, ShouldBeNil) 32 So(err, ShouldBeNil)
32 33
33 Convey("Check Project config updated", func() { 34 Convey("Check Project config updated", func() {
34 p, err := GetProject(c, "foo") 35 p, err := GetProject(c, "foo")
35 So(err, ShouldBeNil) 36 So(err, ShouldBeNil)
36 So(p.ID, ShouldEqual, "foo") 37 So(p.ID, ShouldEqual, "foo")
37 So(p.Readers, ShouldResemble, []string{"public", "foo@bar.com"}) 38 So(p.Readers, ShouldResemble, []string{"public", "foo@bar.com"})
38 So(p.Writers, ShouldResemble, []string(nil)) 39 So(p.Writers, ShouldResemble, []string(nil))
39 }) 40 })
40 41
41 Convey("Check Console config updated", func() { 42 Convey("Check Console config updated", func() {
42 cs, err := GetConsole(c, "foo", "default") 43 cs, err := GetConsole(c, "foo", "default")
43 So(err, ShouldBeNil) 44 So(err, ShouldBeNil)
44 So(cs.Name, ShouldEqual, "default") 45 So(cs.Name, ShouldEqual, "default")
45 So(cs.RepoURL, ShouldEqual, "https://chromium.go oglesource.com/foo/bar") 46 So(cs.RepoURL, ShouldEqual, "https://chromium.go oglesource.com/foo/bar")
46 }) 47 })
47 }) 48 })
48 49
49 Convey("Reject duplicate configs.", func() { 50 Convey("Reject duplicate configs.", func() {
50 mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"lu ci-milo.cfg": barCfg} 51 mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"lu ci-milo.cfg": barCfg}
51 » » » c = lucicfg.SetImplementation(c, memcfg.New(mockedConfig s)) 52
52 err := Update(c) 53 err := Update(c)
53 So(strings.HasPrefix(err.Error(), "Duplicate project ID" ), ShouldEqual, true) 54 So(strings.HasPrefix(err.Error(), "Duplicate project ID" ), ShouldEqual, true)
54 }) 55 })
55 }) 56 })
56 } 57 }
57 58
58 var fooCfg = ` 59 var fooCfg = `
59 ID: "foo" 60 ID: "foo"
60 Readers: "public" 61 Readers: "public"
61 Readers: "foo@bar.com" 62 Readers: "foo@bar.com"
(...skipping 18 matching lines...) Expand all
80 81
81 var barCfg = ` 82 var barCfg = `
82 ID: "foo" 83 ID: "foo"
83 ` 84 `
84 85
85 var mockedConfigs = map[string]memcfg.ConfigSet{ 86 var mockedConfigs = map[string]memcfg.ConfigSet{
86 "projects/foo.git": { 87 "projects/foo.git": {
87 "luci-milo.cfg": fooCfg, 88 "luci-milo.cfg": fooCfg,
88 }, 89 },
89 } 90 }
OLDNEW
« no previous file with comments | « milo/appengine/settings/config.go ('k') | scheduler/appengine/catalog/catalog.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698