Fix port test
This commit is contained in:
parent
dc4fe50fb8
commit
e7ae42060e
@ -6,7 +6,6 @@
|
||||
package base
|
||||
|
||||
import (
|
||||
gosql "database/sql"
|
||||
"testing"
|
||||
|
||||
"github.com/github/gh-ost/go/mysql"
|
||||
@ -42,8 +41,8 @@ func TestValidateConnection(t *testing.T) {
|
||||
{
|
||||
migrationContext := &MigrationContext{Log: NewDefaultLogger()}
|
||||
serverInfo := &mysql.ServerInfo{
|
||||
Port: gosql.NullInt64{Int64: mysql.DefaultInstancePort, Valid: true},
|
||||
ExtraPort: gosql.NullInt64{Int64: mysql.DefaultInstancePort + 1, Valid: true},
|
||||
Port: mysql.NewPort(mysql.DefaultInstancePort),
|
||||
ExtraPort: mysql.NewPort(mysql.DefaultInstancePort + 1),
|
||||
}
|
||||
test.S(t).ExpectNil(ValidateConnection(serverInfo, connectionConfig, migrationContext, "test"))
|
||||
}
|
||||
@ -78,7 +77,7 @@ func TestValidateConnection(t *testing.T) {
|
||||
{
|
||||
migrationContext := &MigrationContext{Log: NewDefaultLogger()}
|
||||
serverInfo := &mysql.ServerInfo{
|
||||
ExtraPort: gosql.NullInt64{Int64: mysql.DefaultInstancePort, Valid: true},
|
||||
ExtraPort: mysql.NewPort(mysql.DefaultInstancePort),
|
||||
}
|
||||
test.S(t).ExpectNil(ValidateConnection(serverInfo, connectionConfig, migrationContext, "test"))
|
||||
}
|
||||
@ -86,8 +85,8 @@ func TestValidateConnection(t *testing.T) {
|
||||
{
|
||||
migrationContext := &MigrationContext{Log: NewDefaultLogger()}
|
||||
serverInfo := &mysql.ServerInfo{
|
||||
Port: gosql.NullInt64{Int64: 12345, Valid: true},
|
||||
ExtraPort: gosql.NullInt64{Int64: mysql.DefaultInstancePort, Valid: true},
|
||||
Port: mysql.NewPort(12345),
|
||||
ExtraPort: mysql.NewPort(mysql.DefaultInstancePort),
|
||||
}
|
||||
test.S(t).ExpectNil(ValidateConnection(serverInfo, connectionConfig, migrationContext, "test"))
|
||||
}
|
||||
@ -95,7 +94,7 @@ func TestValidateConnection(t *testing.T) {
|
||||
{
|
||||
migrationContext := &MigrationContext{Log: NewDefaultLogger()}
|
||||
serverInfo := &mysql.ServerInfo{
|
||||
Port: gosql.NullInt64{Int64: 9999, Valid: true},
|
||||
Port: mysql.NewPort(9999),
|
||||
}
|
||||
test.S(t).ExpectNotNil(ValidateConnection(serverInfo, connectionConfig, migrationContext, "test"))
|
||||
}
|
||||
|
@ -11,11 +11,8 @@ import gosql "database/sql"
|
||||
type Port gosql.NullInt64
|
||||
|
||||
// NewPort creates a new Port.
|
||||
func NewPort(port int64) gosql.NullInt64 {
|
||||
return gosql.NullInt64{
|
||||
Int64: port,
|
||||
Valid: port > 0,
|
||||
}
|
||||
func NewPort(port int64) Port {
|
||||
return Port{Int64: port, Valid: port > 0}
|
||||
}
|
||||
|
||||
// ServerInfo represents the online config of a MySQL server.
|
||||
|
Loading…
Reference in New Issue
Block a user