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

Unified Diff: go/src/infra/tools/kitchen/cook_logdog_test.go

Issue 2146403002: Kitchen: Generate LogDog prefix from Swarming. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix error strings in tests. Created 4 years, 5 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 | « go/src/infra/tools/kitchen/cook_logdog.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/kitchen/cook_logdog_test.go
diff --git a/go/src/infra/tools/kitchen/cook_logdog_test.go b/go/src/infra/tools/kitchen/cook_logdog_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..272221f1f20266b67f88c2bd9883ba1c705a6c57
--- /dev/null
+++ b/go/src/infra/tools/kitchen/cook_logdog_test.go
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
+
+import (
+ "testing"
+
+ "github.com/luci/luci-go/common/environ"
+ "github.com/luci/luci-go/common/logdog/types"
+
+ . "github.com/luci/luci-go/common/testing/assertions"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestCookLogDogPrefix(t *testing.T) {
+ Convey(`With a fake environment`, t, func() {
+ var (
+ p cookLogDogParams
+
+ env = environ.New([]string{
+ "SWARMING_SERVER=server.appspot.com",
+ "SWARMING_TASK_ID=1234567890abcdef",
+ })
+ )
+
+ Convey(`Will prefer command-line prefix`, func() {
+ p.prefix = "foo/bar"
+
+ pfx, err := p.getPrefix(env)
+ So(err, ShouldBeNil)
+ So(pfx, ShouldEqual, types.StreamName("foo/bar"))
+ })
+
+ Convey(`Can generate a LogDog prefix`, func() {
+ pfx, err := p.getPrefix(env)
+ So(err, ShouldBeNil)
+ So(pfx, ShouldEqual, types.StreamName("swarm/server.appspot.com/1234567890abcdef"))
+ })
+
+ Convey(`If Swarming server is missing from the environment, will fail.`, func() {
+ env.Set("SWARMING_SERVER", "")
+
+ _, err := p.getPrefix(env)
+ So(err, ShouldErrLike, "missing or empty SWARMING_SERVER")
+ })
+
+ Convey(`If Swarming task ID is missing from the environment, will fail.`, func() {
+ env.Set("SWARMING_TASK_ID", "")
+
+ _, err := p.getPrefix(env)
+ So(err, ShouldErrLike, "missing or empty SWARMING_TASK_ID")
+ })
+ })
+}
« no previous file with comments | « go/src/infra/tools/kitchen/cook_logdog.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698