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

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

Issue 2695383002: milo: Enable Swarming LogDog log loading. (Closed)
Patch Set: 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
Index: logdog/common/types/url_test.go
diff --git a/logdog/common/types/url_test.go b/logdog/common/types/url_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..bb9633db35400762abbb22653a6b945a00c8cced
--- /dev/null
+++ b/logdog/common/types/url_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 TestURL(t *testing.T) {
+ t.Parallel()
+
+ var successes = []struct {
+ s string
+ exp Stream
+ }{
+ {"logdog://host/project/a/+/b", Stream{"host", "project", "a/+/b"}},
+ {"logdog://host.example.com/project/foo/bar/+/baz", Stream{"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 stream URL`, t, func() {
+
+ for _, tc := range successes {
+ Convey(fmt.Sprintf(`Success: %q`, tc.s), func() {
+ stream, err := ParseURL(tc.s)
+ So(err, ShouldBeNil)
+ So(stream, ShouldResemble, &tc.exp)
+
+ u, err := url.Parse(tc.s)
+ So(err, ShouldBeNil)
+ So(stream.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)
+ })
+ }
+ })
+}

Powered by Google App Engine
This is Rietveld 408576698