1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Use assert in legacy unit tests (#867)

This commit is contained in:
Ethan Koenig
2017-02-08 01:29:07 -05:00
committed by Lunny Xiao
parent 23a7527e04
commit d2329e1c26
69 changed files with 249 additions and 6983 deletions

View File

@@ -7,27 +7,19 @@ package models
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/stretchr/testify/assert"
)
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"},
test := func (input, expectedHost, expectedPort string) {
host, port := parsePostgreSQLHostPort(input)
assert.Equal(t, expectedHost, host)
assert.Equal(t, expectedPort, port)
}
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)
}
})
test("127.0.0.1:1234", "127.0.0.1", "1234")
test("127.0.0.1", "127.0.0.1", "5432")
test("[::1]:1234", "[::1]", "1234")
test("[::1]", "[::1]", "5432")
test("/tmp/pg.sock:1234", "/tmp/pg.sock", "1234")
test("/tmp/pg.sock", "/tmp/pg.sock", "5432")
}