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

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: Kitchen: Generate LogDog prefix from Swarming. 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
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..4afe7d50c9351c47383864c8502cef287b0b1337
--- /dev/null
+++ b/go/src/infra/tools/kitchen/cook_logdog_test.go
@@ -0,0 +1,44 @@
+// 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() {
+ env := environ.New([]string{
+ "SWARMING_SERVER=server.appspot.com",
+ "SWARMING_TASK_ID=1234567890abcdef",
+ })
+
+ Convey(`Can generate a LogDog prefix`, func() {
+ p, err := getLogdogPrefix(env)
+ So(err, ShouldBeNil)
+ So(p, 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 := getLogdogPrefix(env)
+ So(err, ShouldErrLike, "failed to get swarming task parameters")
+ })
+
+ Convey(`If Swarming task ID is missing from the environment, will fail.`, func() {
+ env.Set("SWARMING_TASK_ID", "")
+
+ _, err := getLogdogPrefix(env)
+ So(err, ShouldErrLike, "failed to get swarming task parameters")
+ })
+ })
+}

Powered by Google App Engine
This is Rietveld 408576698