| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package types | 5 package types |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "flag" |
| 8 "fmt" | 9 "fmt" |
| 9 "net/url" | 10 "net/url" |
| 10 "testing" | 11 "testing" |
| 11 | 12 |
| 12 . "github.com/luci/luci-go/common/testing/assertions" | 13 . "github.com/luci/luci-go/common/testing/assertions" |
| 13 . "github.com/smartystreets/goconvey/convey" | 14 . "github.com/smartystreets/goconvey/convey" |
| 14 ) | 15 ) |
| 15 | 16 |
| 16 func TestStreamAddr(t *testing.T) { | 17 func TestStreamAddr(t *testing.T) { |
| 17 t.Parallel() | 18 t.Parallel() |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 }) | 51 }) |
| 51 } | 52 } |
| 52 | 53 |
| 53 for _, tc := range failures { | 54 for _, tc := range failures { |
| 54 Convey(fmt.Sprintf(`Failure: %q fails like: %q`, tc.s, t
c.err), func() { | 55 Convey(fmt.Sprintf(`Failure: %q fails like: %q`, tc.s, t
c.err), func() { |
| 55 _, err := ParseURL(tc.s) | 56 _, err := ParseURL(tc.s) |
| 56 So(err, ShouldErrLike, tc.err) | 57 So(err, ShouldErrLike, tc.err) |
| 57 }) | 58 }) |
| 58 } | 59 } |
| 59 }) | 60 }) |
| 61 |
| 62 Convey(`StreamAddr is a flag.Value`, t, func() { |
| 63 fs := flag.NewFlagSet("testing", flag.ContinueOnError) |
| 64 a := &StreamAddr{} |
| 65 |
| 66 fs.Var(a, "addr", "its totally an address of a thing") |
| 67 |
| 68 Convey(`good`, func() { |
| 69 So(fs.Parse([]string{"-addr", "logdog://host/project/a/+
/b"}), ShouldBeNil) |
| 70 So(a, ShouldResemble, &StreamAddr{ |
| 71 "host", |
| 72 "project", |
| 73 "a/+/b", |
| 74 }) |
| 75 }) |
| 76 |
| 77 Convey(`bad`, func() { |
| 78 So(fs.Parse([]string{"-addr", "://host/project/a/+/b"}),
ShouldErrLike, |
| 79 "failed to parse URL") |
| 80 }) |
| 81 }) |
| 60 } | 82 } |
| OLD | NEW |