Fixed outstanding failed tests

This commit is contained in:
Patrick O'brien 2016-09-10 01:06:07 +10:00
parent ac02f7d2e0
commit 817189fbfd
3 changed files with 14 additions and 14 deletions

View file

@ -6,14 +6,14 @@ import (
"github.com/vattle/sqlboiler/strmangle"
)
type mockDriver struct{}
type testMockDriver struct{}
func (m mockDriver) TranslateColumnType(c Column) Column { return c }
func (m mockDriver) UseLastInsertID() bool { return false }
func (m mockDriver) Open() error { return nil }
func (m mockDriver) Close() {}
func (m testMockDriver) TranslateColumnType(c Column) Column { return c }
func (m testMockDriver) UseLastInsertID() bool { return false }
func (m testMockDriver) Open() error { return nil }
func (m testMockDriver) Close() {}
func (m mockDriver) TableNames(whitelist, blacklist []string) ([]string, error) {
func (m testMockDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error) {
if len(whitelist) > 0 {
return whitelist, nil
}
@ -22,7 +22,7 @@ func (m mockDriver) TableNames(whitelist, blacklist []string) ([]string, error)
}
// Columns returns a list of mock columns
func (m mockDriver) Columns(tableName string) ([]Column, error) {
func (m testMockDriver) Columns(schema, tableName string) ([]Column, error) {
return map[string][]Column{
"pilots": {
{Name: "id", Type: "int", DBType: "integer"},
@ -64,7 +64,7 @@ func (m mockDriver) Columns(tableName string) ([]Column, error) {
}
// ForeignKeyInfo returns a list of mock foreignkeys
func (m mockDriver) ForeignKeyInfo(tableName string) ([]ForeignKey, error) {
func (m testMockDriver) ForeignKeyInfo(schema, tableName string) ([]ForeignKey, error) {
return map[string][]ForeignKey{
"jets": {
{Table: "jets", Name: "jets_pilot_id_fk", Column: "pilot_id", ForeignTable: "pilots", ForeignColumn: "id", ForeignColumnUnique: true},
@ -84,7 +84,7 @@ func (m mockDriver) ForeignKeyInfo(tableName string) ([]ForeignKey, error) {
}
// PrimaryKeyInfo returns mock primary key info for the passed in table name
func (m mockDriver) PrimaryKeyInfo(tableName string) (*PrimaryKey, error) {
func (m testMockDriver) PrimaryKeyInfo(schema, tableName string) (*PrimaryKey, error) {
return map[string]*PrimaryKey{
"pilots": {Name: "pilot_id_pkey", Columns: []string{"id"}},
"airports": {Name: "airport_id_pkey", Columns: []string{"id"}},
@ -99,7 +99,7 @@ func (m mockDriver) PrimaryKeyInfo(tableName string) (*PrimaryKey, error) {
func TestTables(t *testing.T) {
t.Parallel()
tables, err := Tables(mockDriver{}, nil, nil)
tables, err := Tables(testMockDriver{}, "public", nil, nil)
if err != nil {
t.Error(err)
}

View file

@ -39,7 +39,7 @@ func init() {
// for Postgres: "schema_name"."table_name", versus
// simply "table_name" for MySQL (because it does not support real schemas)
func SchemaTable(driver string, schema string, table string) string {
if driver == "postgres" {
if driver == "postgres" && schema != "public" {
return fmt.Sprintf(`"%s"."%s"`, schema, table)
}

View file

@ -12,7 +12,7 @@ import (
func TestTextsFromForeignKey(t *testing.T) {
t.Parallel()
tables, err := bdb.Tables(&drivers.MockDriver{}, nil, nil)
tables, err := bdb.Tables(&drivers.MockDriver{}, "public", nil, nil)
if err != nil {
t.Fatal(err)
}
@ -81,7 +81,7 @@ func TestTextsFromForeignKey(t *testing.T) {
func TestTextsFromOneToOneRelationship(t *testing.T) {
t.Parallel()
tables, err := bdb.Tables(&drivers.MockDriver{}, nil, nil)
tables, err := bdb.Tables(&drivers.MockDriver{}, "public", nil, nil)
if err != nil {
t.Fatal(err)
}
@ -130,7 +130,7 @@ func TestTextsFromOneToOneRelationship(t *testing.T) {
func TestTextsFromRelationship(t *testing.T) {
t.Parallel()
tables, err := bdb.Tables(&drivers.MockDriver{}, nil, nil)
tables, err := bdb.Tables(&drivers.MockDriver{}, "public", nil, nil)
if err != nil {
t.Fatal(err)
}