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

Side by Side Diff: logdog/common/types/streamaddr_test.go

Issue 2895233004: [logdog/common/types] make StreamAddr implement flag.Value. (Closed)
Patch Set: Created 3 years, 7 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 | « logdog/common/types/streamaddr.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 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
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 }
OLDNEW
« no previous file with comments | « logdog/common/types/streamaddr.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698