summaryrefslogtreecommitdiffstats
path: root/models/models_test.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-12 02:56:50 -0700
committerUnknwon <u@gogs.io>2016-08-12 02:56:50 -0700
commit5be881756b093534462493520eb8f0600235407c (patch)
tree17ce1707561d69f780d0e79cdc494e4f456827bf /models/models_test.go
parent42964272149e2b8f5f3959100c43210cd508e2f5 (diff)
downloadgitea-5be881756b093534462493520eb8f0600235407c.tar.gz
gitea-5be881756b093534462493520eb8f0600235407c.zip
#3442 add test suites
Diffstat (limited to 'models/models_test.go')
-rw-r--r--models/models_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/models/models_test.go b/models/models_test.go
new file mode 100644
index 0000000000..f68590c509
--- /dev/null
+++ b/models/models_test.go
@@ -0,0 +1,33 @@
+// Copyright 2016 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package models
+
+import (
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func Test_parsePostgreSQLHostPort(t *testing.T) {
+ testSuites := []struct {
+ input string
+ host, port string
+ }{
+ {"127.0.0.1:1234", "127.0.0.1", "1234"},
+ {"127.0.0.1", "127.0.0.1", "5432"},
+ {"[::1]:1234", "[::1]", "1234"},
+ {"[::1]", "[::1]", "5432"},
+ {"/tmp/pg.sock:1234", "/tmp/pg.sock", "1234"},
+ {"/tmp/pg.sock", "/tmp/pg.sock", "5432"},
+ }
+
+ Convey("Parse PostgreSQL host and port", t, func() {
+ for _, suite := range testSuites {
+ host, port := parsePostgreSQLHostPort(suite.input)
+ So(host, ShouldEqual, suite.host)
+ So(port, ShouldEqual, suite.port)
+ }
+ })
+}