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

Unified Diff: logdog/common/types/streamaddr_test.go

Issue 2695383002: milo: Enable Swarming LogDog log loading. (Closed)
Patch Set: Comments, fix links. Created 3 years, 10 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') | logdog/common/types/streamname_test.go » ('j') | 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
new file mode 100644
index 0000000000000000000000000000000000000000..f58be1d23ec86e73b413c6263b50a9b5e17924a1
--- /dev/null
+++ b/logdog/common/types/streamaddr_test.go
@@ -0,0 +1,60 @@
+// Copyright 2015 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package types
+
+import (
+ "fmt"
+ "net/url"
+ "testing"
+
+ . "github.com/luci/luci-go/common/testing/assertions"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestStreamAddr(t *testing.T) {
+ t.Parallel()
+
+ var successes = []struct {
+ s string
+ exp StreamAddr
+ }{
+ {"logdog://host/project/a/+/b", StreamAddr{"host", "project", "a/+/b"}},
+ {"logdog://host.example.com/project/foo/bar/+/baz", StreamAddr{"host.example.com", "project", "foo/bar/+/baz"}},
+ }
+
+ var failures = []struct {
+ s string
+ err string
+ }{
+ {"://project/prefix/+/name", "failed to parse URL"},
+ {"http://example.com/foo/bar/+/baz", "is not logdog"},
+ {"logdog://example.com/foo", "URL path does not include both project and path components"},
+ {"logdog://example.com/foo@d/bar", "invalid project name"},
+ {"logdog://example.com/foo/bar", "invalid stream path"},
+ {"logdog://example.com/foo/bar/+/ba!", "invalid stream path"},
+ }
+
+ Convey(`Testing StreamAddr`, t, func() {
+
+ for _, tc := range successes {
+ Convey(fmt.Sprintf(`Success: %q`, tc.s), func() {
+ addr, err := ParseURL(tc.s)
+ So(err, ShouldBeNil)
+ So(addr, ShouldResemble, &tc.exp)
+
+ u, err := url.Parse(tc.s)
+ So(err, ShouldBeNil)
+ So(addr.URL(), ShouldResemble, u)
+ })
+ }
+
+ for _, tc := range failures {
+ Convey(fmt.Sprintf(`Failure: %q fails like: %q`, tc.s, tc.err), func() {
+ _, err := ParseURL(tc.s)
+ So(err, ShouldErrLike, tc.err)
+ })
+ }
+ })
+}
« no previous file with comments | « logdog/common/types/streamaddr.go ('k') | logdog/common/types/streamname_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698