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

Side by Side Diff: client/cmd/rpc/main_test.go

Issue 1587323003: client/cmd/rpc: RPC CLI (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@discovery
Patch Set: check status Created 4 years, 11 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 | « client/cmd/rpc/main.go ('k') | client/cmd/rpc/printer.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 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package main
6
7 import (
8 "net/url"
9 "testing"
10
11 . "github.com/luci/luci-go/common/testing/assertions"
12 . "github.com/smartystreets/goconvey/convey"
13 )
14
15 func TestMain(t *testing.T) {
16 t.Parallel()
17
18 Convey("parseServer", t, func() {
19 test := func(host string, expectedErr interface{}, expectedURL * url.URL) {
20 Convey(host, func() {
21 u, err := parseServer(host)
22 So(err, ShouldErrLike, expectedErr)
23 So(u, ShouldResembleV, expectedURL)
24 })
25 }
26
27 test("", "unspecified", nil)
28
29 // Localhost is http, everything else is https.
30 test("localhost", nil, &url.URL{
31 Scheme: "http",
32 Host: "localhost",
33 })
34 test("localhost:8080", nil, &url.URL{
35 Scheme: "http",
36 Host: "localhost:8080",
37 })
38 test("127.0.0.1", nil, &url.URL{
39 Scheme: "http",
40 Host: "127.0.0.1",
41 })
42 test("127.0.0.1:8080", nil, &url.URL{
43 Scheme: "http",
44 Host: "127.0.0.1:8080",
45 })
46 test("example.com", nil, &url.URL{
47 Scheme: "https",
48 Host: "example.com",
49 })
50
51 // Short syntax for localhost.
52 test(":", nil, &url.URL{
53 Scheme: "http",
54 Host: "localhost:",
55 })
56 test(":8080", nil, &url.URL{
57 Scheme: "http",
58 Host: "localhost:8080",
59 })
iannucci 2016/01/15 23:20:09 can we add a test for "example.com:8080" too?
nodir 2016/01/15 23:47:25 Done.
60
61 // No explicit scheme.
62 test("http://example.com", "must not have scheme", nil)
63 test("https://example.com", "must not have scheme", nil)
64 test("ftp://example.com", "must not have scheme", nil)
65
66 // Extra URL components.
67 test("example.com/a", "must not have query, path or fragment", n il)
68 test("example.com?a", "must not have query, path or fragment", n il)
69 test("example.com#a", "must not have query, path or fragment", n il)
70 })
71 }
OLDNEW
« no previous file with comments | « client/cmd/rpc/main.go ('k') | client/cmd/rpc/printer.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698