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

Unified 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: rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/cmd/rpc/main.go ('k') | client/cmd/rpc/printer.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/rpc/main_test.go
diff --git a/client/cmd/rpc/main_test.go b/client/cmd/rpc/main_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..cf3ad38f7956a1af4eec0b929917196bee927bae
--- /dev/null
+++ b/client/cmd/rpc/main_test.go
@@ -0,0 +1,75 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package main
+
+import (
+ "net/url"
+ "testing"
+
+ . "github.com/luci/luci-go/common/testing/assertions"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestMain(t *testing.T) {
+ t.Parallel()
+
+ Convey("parseServer", t, func() {
+ test := func(host string, expectedErr interface{}, expectedURL *url.URL) {
+ Convey(host, func() {
+ u, err := parseServer(host)
+ So(err, ShouldErrLike, expectedErr)
+ So(u, ShouldResembleV, expectedURL)
+ })
+ }
+
+ test("", "unspecified", nil)
+
+ // Localhost is http, everything else is https.
+ test("localhost", nil, &url.URL{
+ Scheme: "http",
+ Host: "localhost",
+ })
+ test("localhost:8080", nil, &url.URL{
+ Scheme: "http",
+ Host: "localhost:8080",
+ })
+ test("127.0.0.1", nil, &url.URL{
+ Scheme: "http",
+ Host: "127.0.0.1",
+ })
+ test("127.0.0.1:8080", nil, &url.URL{
+ Scheme: "http",
+ Host: "127.0.0.1:8080",
+ })
+ test("example.com", nil, &url.URL{
+ Scheme: "https",
+ Host: "example.com",
+ })
+ test("example.com:8080", nil, &url.URL{
+ Scheme: "https",
+ Host: "example.com:8080",
+ })
+
+ // Short syntax for localhost.
+ test(":", nil, &url.URL{
+ Scheme: "http",
+ Host: "localhost:",
+ })
+ test(":8080", nil, &url.URL{
+ Scheme: "http",
+ Host: "localhost:8080",
+ })
+
+ // No explicit scheme.
+ test("http://example.com", "must not have scheme", nil)
+ test("https://example.com", "must not have scheme", nil)
+ test("ftp://example.com", "must not have scheme", nil)
+
+ // Extra URL components.
+ test("example.com/a", "must not have query, path or fragment", nil)
+ test("example.com?a", "must not have query, path or fragment", nil)
+ test("example.com#a", "must not have query, path or fragment", nil)
+ })
+}
« 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