From 5e0bbea2c1ce5f66151f73d3ae7857cd94f6f1e8 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Sun, 1 Nov 2015 19:32:07 +0100 Subject: [PATCH] Add tests --- README.md | 1 + gotty-client_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 gotty-client_test.go diff --git a/README.md b/README.md index 04b143f..124b1c7 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ $ brew install https://raw.githubusercontent.com/moul/ssh2docker/master/contrib/ ### master (unreleased) * Flexible parsing of the input URL +* Add tests [full commits list](https://github.com/moul/gotty-client/compare/v1.3.0...master) diff --git a/gotty-client_test.go b/gotty-client_test.go new file mode 100644 index 0000000..e8b2256 --- /dev/null +++ b/gotty-client_test.go @@ -0,0 +1,41 @@ +package gottyclient + +import ( + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestParseURL(t *testing.T) { + Convey("Testing ParseURL", t, func() { + Convey("Complete URLs", func() { + input := "http://test.com:8888/blahblah/blihblih" + output, err := ParseURL(input) + So(err, ShouldBeNil) + So(output, ShouldEqual, input) + + input = "https://test.com:8888/blahblah/blihblih" + output, err = ParseURL(input) + So(err, ShouldBeNil) + So(output, ShouldEqual, input) + + input = "https://test.com:8888" + output, err = ParseURL(input) + So(err, ShouldBeNil) + So(output, ShouldEqual, input) + }) + Convey("Incomplete URLs", func() { + input := "test.com:8888/blahblah/blihblih" + expected := "http://test.com:8888/blahblah/blihblih" + output, err := ParseURL(input) + So(err, ShouldBeNil) + So(output, ShouldEqual, expected) + + input = "test.com" + expected = "http://test.com" + output, err = ParseURL(input) + So(err, ShouldBeNil) + So(output, ShouldEqual, expected) + }) + }) +}