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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package types
6
7 import (
8 "fmt"
9 "net/url"
10 "testing"
11
12 . "github.com/luci/luci-go/common/testing/assertions"
13 . "github.com/smartystreets/goconvey/convey"
14 )
15
16 func TestStreamAddr(t *testing.T) {
17 t.Parallel()
18
19 var successes = []struct {
20 s string
21 exp StreamAddr
22 }{
23 {"logdog://host/project/a/+/b", StreamAddr{"host", "project", "a /+/b"}},
24 {"logdog://host.example.com/project/foo/bar/+/baz", StreamAddr{" host.example.com", "project", "foo/bar/+/baz"}},
25 }
26
27 var failures = []struct {
28 s string
29 err string
30 }{
31 {"://project/prefix/+/name", "failed to parse URL"},
32 {"http://example.com/foo/bar/+/baz", "is not logdog"},
33 {"logdog://example.com/foo", "URL path does not include both pro ject and path components"},
34 {"logdog://example.com/foo@d/bar", "invalid project name"},
35 {"logdog://example.com/foo/bar", "invalid stream path"},
36 {"logdog://example.com/foo/bar/+/ba!", "invalid stream path"},
37 }
38
39 Convey(`Testing StreamAddr`, t, func() {
40
41 for _, tc := range successes {
42 Convey(fmt.Sprintf(`Success: %q`, tc.s), func() {
43 addr, err := ParseURL(tc.s)
44 So(err, ShouldBeNil)
45 So(addr, ShouldResemble, &tc.exp)
46
47 u, err := url.Parse(tc.s)
48 So(err, ShouldBeNil)
49 So(addr.URL(), ShouldResemble, u)
50 })
51 }
52
53 for _, tc := range failures {
54 Convey(fmt.Sprintf(`Failure: %q fails like: %q`, tc.s, t c.err), func() {
55 _, err := ParseURL(tc.s)
56 So(err, ShouldErrLike, tc.err)
57 })
58 }
59 })
60 }
OLDNEW
« 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