| OLD | NEW |
| (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 env := environ.New([]string{ |
| 20 "SWARMING_SERVER=server.appspot.com", |
| 21 "SWARMING_TASK_ID=1234567890abcdef", |
| 22 }) |
| 23 |
| 24 Convey(`Can generate a LogDog prefix`, func() { |
| 25 p, err := getLogdogPrefix(env) |
| 26 So(err, ShouldBeNil) |
| 27 So(p, ShouldEqual, types.StreamName("swarm/server.appspo
t.com/1234567890abcdef")) |
| 28 }) |
| 29 |
| 30 Convey(`If Swarming server is missing from the environment, will
fail.`, func() { |
| 31 env.Set("SWARMING_SERVER", "") |
| 32 |
| 33 _, err := getLogdogPrefix(env) |
| 34 So(err, ShouldErrLike, "failed to get swarming task para
meters") |
| 35 }) |
| 36 |
| 37 Convey(`If Swarming task ID is missing from the environment, wil
l fail.`, func() { |
| 38 env.Set("SWARMING_TASK_ID", "") |
| 39 |
| 40 _, err := getLogdogPrefix(env) |
| 41 So(err, ShouldErrLike, "failed to get swarming task para
meters") |
| 42 }) |
| 43 }) |
| 44 } |
| OLD | NEW |