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

Side by Side Diff: go/src/infra/tools/kitchen/cook_logdog_test.go

Issue 2154953002: Add infraenv, setup creds and tee for Kitchen. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Add coverage file, restrict platforms to actual Infra platforms. 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 9
10 "github.com/luci/luci-go/common/environ" 10 "github.com/luci/luci-go/common/environ"
11 "github.com/luci/luci-go/common/logdog/types" 11 "github.com/luci/luci-go/common/logdog/types"
12 12
13 . "github.com/luci/luci-go/common/testing/assertions" 13 . "github.com/luci/luci-go/common/testing/assertions"
14 . "github.com/smartystreets/goconvey/convey" 14 . "github.com/smartystreets/goconvey/convey"
15 ) 15 )
16 16
17 func TestCookLogDogPrefix(t *testing.T) { 17 func TestCookLogDogPrefix(t *testing.T) {
18 Convey(`With a fake environment`, t, func() { 18 Convey(`With a fake environment`, t, func() {
19 var ( 19 var (
20 p cookLogDogParams 20 p cookLogDogParams
21 21
22 env = environ.New([]string{ 22 env = environ.New([]string{
23 » » » » "SWARMING_SERVER=server.appspot.com", 23 » » » » "SWARMING_SERVER=https://example.appspot.com",
24 "SWARMING_TASK_ID=1234567890abcdef", 24 "SWARMING_TASK_ID=1234567890abcdef",
25 }) 25 })
26 ) 26 )
27 27
28 Convey(`Will prefer command-line prefix`, func() { 28 Convey(`Will prefer command-line prefix`, func() {
29 p.prefix = "foo/bar" 29 p.prefix = "foo/bar"
30 30
31 pfx, err := p.getPrefix(env) 31 pfx, err := p.getPrefix(env)
32 So(err, ShouldBeNil) 32 So(err, ShouldBeNil)
33 So(pfx, ShouldEqual, types.StreamName("foo/bar")) 33 So(pfx, ShouldEqual, types.StreamName("foo/bar"))
34 }) 34 })
35 35
36 Convey(`Can generate a LogDog prefix`, func() { 36 Convey(`Can generate a LogDog prefix`, func() {
37 pfx, err := p.getPrefix(env) 37 pfx, err := p.getPrefix(env)
38 So(err, ShouldBeNil) 38 So(err, ShouldBeNil)
39 » » » So(pfx, ShouldEqual, types.StreamName("swarm/server.apps pot.com/1234567890abcdef")) 39 » » » So(pfx, ShouldEqual, types.StreamName("swarm/example.app spot.com/1234567890abcdef"))
40 » » })
41
42 » » Convey(`Can generate a LogDog prefix from a host instead of a se rver URL`, func() {
43 » » » env.Set("SWARMING_SERVER", "example.appspot.com")
44
45 » » » pfx, err := p.getPrefix(env)
46 » » » So(err, ShouldBeNil)
47 » » » So(pfx, ShouldEqual, types.StreamName("swarm/example.app spot.com/1234567890abcdef"))
40 }) 48 })
41 49
42 Convey(`If Swarming server is missing from the environment, will fail.`, func() { 50 Convey(`If Swarming server is missing from the environment, will fail.`, func() {
43 env.Set("SWARMING_SERVER", "") 51 env.Set("SWARMING_SERVER", "")
44 52
45 _, err := p.getPrefix(env) 53 _, err := p.getPrefix(env)
46 So(err, ShouldErrLike, "missing or empty SWARMING_SERVER ") 54 So(err, ShouldErrLike, "missing or empty SWARMING_SERVER ")
47 }) 55 })
48 56
49 Convey(`If Swarming task ID is missing from the environment, wil l fail.`, func() { 57 Convey(`If Swarming task ID is missing from the environment, wil l fail.`, func() {
50 env.Set("SWARMING_TASK_ID", "") 58 env.Set("SWARMING_TASK_ID", "")
51 59
52 _, err := p.getPrefix(env) 60 _, err := p.getPrefix(env)
53 So(err, ShouldErrLike, "missing or empty SWARMING_TASK_I D") 61 So(err, ShouldErrLike, "missing or empty SWARMING_TASK_I D")
54 }) 62 })
55 }) 63 })
56 } 64 }
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