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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « logdog/common/types/streamaddr.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/common/types/streamaddr_test.go
diff --git a/logdog/common/types/streamaddr_test.go b/logdog/common/types/streamaddr_test.go
index f58be1d23ec86e73b413c6263b50a9b5e17924a1..1f8a9b2dec21fa07b06d281397ccd70d8db64cd7 100644
--- a/logdog/common/types/streamaddr_test.go
+++ b/logdog/common/types/streamaddr_test.go
@@ -5,6 +5,7 @@
package types
import (
+ "flag"
"fmt"
"net/url"
"testing"
@@ -57,4 +58,25 @@ func TestStreamAddr(t *testing.T) {
})
}
})
+
+ Convey(`StreamAddr is a flag.Value`, t, func() {
+ fs := flag.NewFlagSet("testing", flag.ContinueOnError)
+ a := &StreamAddr{}
+
+ fs.Var(a, "addr", "its totally an address of a thing")
+
+ Convey(`good`, func() {
+ So(fs.Parse([]string{"-addr", "logdog://host/project/a/+/b"}), ShouldBeNil)
+ So(a, ShouldResemble, &StreamAddr{
+ "host",
+ "project",
+ "a/+/b",
+ })
+ })
+
+ Convey(`bad`, func() {
+ So(fs.Parse([]string{"-addr", "://host/project/a/+/b"}), ShouldErrLike,
+ "failed to parse URL")
+ })
+ })
}
« 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