Add tests

This commit is contained in:
Manfred Touron 2015-11-01 19:32:07 +01:00
parent c7186d44ee
commit 5e0bbea2c1
No known key found for this signature in database
GPG Key ID: 0DCB9CE0CABAE1B5
2 changed files with 42 additions and 0 deletions

View File

@ -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)

41
gotty-client_test.go Normal file
View File

@ -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)
})
})
}