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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « go/src/infra/tools/kitchen/cook_logdog.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package main
6
7 import (
8 "testing"
9
10 "github.com/luci/luci-go/common/environ"
11 "github.com/luci/luci-go/common/logdog/types"
12
13 . "github.com/luci/luci-go/common/testing/assertions"
14 . "github.com/smartystreets/goconvey/convey"
15 )
16
17 func TestCookLogDogPrefix(t *testing.T) {
18 Convey(`With a fake environment`, t, func() {
19 var (
20 p cookLogDogParams
21
22 env = environ.New([]string{
23 "SWARMING_SERVER=server.appspot.com",
24 "SWARMING_TASK_ID=1234567890abcdef",
25 })
26 )
27
28 Convey(`Will prefer command-line prefix`, func() {
29 p.prefix = "foo/bar"
30
31 pfx, err := p.getPrefix(env)
32 So(err, ShouldBeNil)
33 So(pfx, ShouldEqual, types.StreamName("foo/bar"))
34 })
35
36 Convey(`Can generate a LogDog prefix`, func() {
37 pfx, err := p.getPrefix(env)
38 So(err, ShouldBeNil)
39 So(pfx, ShouldEqual, types.StreamName("swarm/server.apps pot.com/1234567890abcdef"))
40 })
41
42 Convey(`If Swarming server is missing from the environment, will fail.`, func() {
43 env.Set("SWARMING_SERVER", "")
44
45 _, err := p.getPrefix(env)
46 So(err, ShouldErrLike, "missing or empty SWARMING_SERVER ")
47 })
48
49 Convey(`If Swarming task ID is missing from the environment, wil l fail.`, func() {
50 env.Set("SWARMING_TASK_ID", "")
51
52 _, err := p.getPrefix(env)
53 So(err, ShouldErrLike, "missing or empty SWARMING_TASK_I D")
54 })
55 })
56 }
OLDNEW
« 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