| OLD | NEW |
| 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 viewer | 5 package viewer |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "testing" | 9 "testing" |
| 10 | 10 |
| 11 "github.com/luci/luci-go/common/config" | |
| 12 "github.com/luci/luci-go/logdog/common/types" | 11 "github.com/luci/luci-go/logdog/common/types" |
| 12 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 13 | 13 |
| 14 . "github.com/smartystreets/goconvey/convey" | 14 . "github.com/smartystreets/goconvey/convey" |
| 15 ) | 15 ) |
| 16 | 16 |
| 17 func TestGetURL(t *testing.T) { | 17 func TestGetURL(t *testing.T) { |
| 18 t.Parallel() | 18 t.Parallel() |
| 19 | 19 |
| 20 Convey(`Testing viewer URL generation`, t, func() { | 20 Convey(`Testing viewer URL generation`, t, func() { |
| 21 for _, tc := range []struct { | 21 for _, tc := range []struct { |
| 22 host string | 22 host string |
| 23 » » » project config.ProjectName | 23 » » » project cfgtypes.ProjectName |
| 24 paths []types.StreamPath | 24 paths []types.StreamPath |
| 25 url string | 25 url string |
| 26 }{ | 26 }{ |
| 27 {"example.appspot.com", "test", []types.StreamPath{"foo/
bar/+/baz"}, | 27 {"example.appspot.com", "test", []types.StreamPath{"foo/
bar/+/baz"}, |
| 28 "https://example.appspot.com/v/?s=test%2Ffoo%2Fb
ar%2F%2B%2Fbaz"}, | 28 "https://example.appspot.com/v/?s=test%2Ffoo%2Fb
ar%2F%2B%2Fbaz"}, |
| 29 {"example.appspot.com", "test", []types.StreamPath{"foo/
bar/+/baz", "qux/+/quux"}, | 29 {"example.appspot.com", "test", []types.StreamPath{"foo/
bar/+/baz", "qux/+/quux"}, |
| 30 "https://example.appspot.com/v/?s=test%2Ffoo%2Fb
ar%2F%2B%2Fbaz&s=test%2Fqux%2F%2B%2Fquux"}, | 30 "https://example.appspot.com/v/?s=test%2Ffoo%2Fb
ar%2F%2B%2Fbaz&s=test%2Fqux%2F%2B%2Fquux"}, |
| 31 {"example.appspot.com", "test", []types.StreamPath{"quer
y/*/+/**"}, | 31 {"example.appspot.com", "test", []types.StreamPath{"quer
y/*/+/**"}, |
| 32 "https://example.appspot.com/v/?s=test%2Fquery%2
F%2A%2F%2B%2F%2A%2A"}, | 32 "https://example.appspot.com/v/?s=test%2Fquery%2
F%2A%2F%2B%2F%2A%2A"}, |
| 33 } { | 33 } { |
| 34 Convey(fmt.Sprintf(`Can generate a URL for host %q, proj
ect %q, paths %q: [%s]`, tc.host, tc.project, tc.paths, tc.url), func() { | 34 Convey(fmt.Sprintf(`Can generate a URL for host %q, proj
ect %q, paths %q: [%s]`, tc.host, tc.project, tc.paths, tc.url), func() { |
| 35 So(GetURL(tc.host, tc.project, tc.paths...), Sho
uldEqual, tc.url) | 35 So(GetURL(tc.host, tc.project, tc.paths...), Sho
uldEqual, tc.url) |
| 36 }) | 36 }) |
| 37 } | 37 } |
| 38 }) | 38 }) |
| 39 } | 39 } |
| OLD | NEW |