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

Unified Diff: milo/appengine/settings/config_test.go

Issue 2238883003: Milo: Use luci-cfg for defining projects and console view. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: review Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/settings/config.go ('k') | milo/common/config/generate.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/settings/config_test.go
diff --git a/milo/appengine/settings/config_test.go b/milo/appengine/settings/config_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..b38e98f599f469b68b3c1c33b194293b901a3041
--- /dev/null
+++ b/milo/appengine/settings/config_test.go
@@ -0,0 +1,89 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package settings
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/luci/gae/impl/memory"
+ lucicfg "github.com/luci/luci-go/common/config"
+ memcfg "github.com/luci/luci-go/common/config/impl/memory"
+ "github.com/luci/luci-go/common/logging/gologger"
+ "golang.org/x/net/context"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestConfig(t *testing.T) {
+ t.Parallel()
+
+ Convey("Test Environment", t, func() {
+ c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
+ c = gologger.StdConfig.Use(c)
+
+ Convey("Send update", func() {
+ c = lucicfg.SetImplementation(c, memcfg.New(mockedConfigs))
+ // Send update here
+ err := update(c)
+ So(err, ShouldBeNil)
+
+ Convey("Check Project config updated", func() {
+ p, err := GetProject(c, "foo")
+ So(err, ShouldBeNil)
+ So(p.ID, ShouldEqual, "foo")
+ So(p.Readers, ShouldResemble, []string{"public", "foo@bar.com"})
+ So(p.Writers, ShouldResemble, []string(nil))
+ })
+
+ Convey("Check Console config updated", func() {
+ cs, err := GetConsole(c, "foo", "default")
+ So(err, ShouldBeNil)
+ So(cs.Name, ShouldEqual, "default")
+ So(cs.RepoURL, ShouldEqual, "https://chromium.googlesource.com/foo/bar")
+ })
+ })
+
+ Convey("Reject duplicate configs.", func() {
+ mockedConfigs["projects/bar.git"] = memcfg.ConfigSet{"luci-milo.cfg": barCfg}
+ c = lucicfg.SetImplementation(c, memcfg.New(mockedConfigs))
+ err := update(c)
+ So(strings.HasPrefix(err.Error(), "Duplicate project ID"), ShouldEqual, true)
+ })
+ })
+}
+
+var fooCfg = `
+ID: "foo"
+Readers: "public"
+Readers: "foo@bar.com"
+Consoles: {
+ Name: "default"
+ RepoURL: "https://chromium.googlesource.com/foo/bar"
+ Branch: "master"
+ Builders: {
+ Module: "buildbucket"
+ Name: "luci.foo.something"
+ Category: "main|something"
+ ShortName: "s"
+ }
+ Builders: {
+ Module: "buildbucket"
+ Name: "luci.foo.other"
+ Category: "main|other"
+ ShortName: "o"
+ }
+}
+`
+
+var barCfg = `
+ID: "foo"
+`
+
+var mockedConfigs = map[string]memcfg.ConfigSet{
+ "projects/foo.git": {
+ "luci-milo.cfg": fooCfg,
+ },
+}
« no previous file with comments | « milo/appengine/settings/config.go ('k') | milo/common/config/generate.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698