Run gofmt -s to remove needless repetition
This commit is contained in:
parent
0b7e6fc507
commit
81d3e15aa9
7 changed files with 65 additions and 65 deletions
|
@ -9,9 +9,9 @@ func TestColumnNames(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
cols := []Column{
|
cols := []Column{
|
||||||
Column{Name: "one"},
|
{Name: "one"},
|
||||||
Column{Name: "two"},
|
{Name: "two"},
|
||||||
Column{Name: "three"},
|
{Name: "three"},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := strings.Join(ColumnNames(cols), " ")
|
out := strings.Join(ColumnNames(cols), " ")
|
||||||
|
@ -22,8 +22,8 @@ func TestColumnNames(t *testing.T) {
|
||||||
|
|
||||||
func TestColumnDBTypes(t *testing.T) {
|
func TestColumnDBTypes(t *testing.T) {
|
||||||
cols := []Column{
|
cols := []Column{
|
||||||
Column{Name: "test_one", DBType: "integer"},
|
{Name: "test_one", DBType: "integer"},
|
||||||
Column{Name: "test_two", DBType: "interval"},
|
{Name: "test_two", DBType: "interval"},
|
||||||
}
|
}
|
||||||
|
|
||||||
res := ColumnDBTypes(cols)
|
res := ColumnDBTypes(cols)
|
||||||
|
|
|
@ -12,8 +12,8 @@ func (t testInterface) TableNames() ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var testCols = []Column{
|
var testCols = []Column{
|
||||||
Column{Name: "col1", Type: "character varying"},
|
{Name: "col1", Type: "character varying"},
|
||||||
Column{Name: "col2", Type: "character varying", Nullable: true},
|
{Name: "col2", Type: "character varying", Nullable: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t testInterface) Columns(tableName string) ([]Column, error) {
|
func (t testInterface) Columns(tableName string) ([]Column, error) {
|
||||||
|
@ -129,18 +129,18 @@ func TestSetForeignKeyConstraints(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []Table{
|
tables := []Table{
|
||||||
Table{
|
{
|
||||||
Name: "one",
|
Name: "one",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
Column{Name: "id1", Type: "string", Nullable: false, Unique: false},
|
{Name: "id1", Type: "string", Nullable: false, Unique: false},
|
||||||
Column{Name: "id2", Type: "string", Nullable: true, Unique: true},
|
{Name: "id2", Type: "string", Nullable: true, Unique: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Table{
|
{
|
||||||
Name: "other",
|
Name: "other",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
Column{Name: "one_id_1", Type: "string", Nullable: false, Unique: false},
|
{Name: "one_id_1", Type: "string", Nullable: false, Unique: false},
|
||||||
Column{Name: "one_id_2", Type: "string", Nullable: true, Unique: true},
|
{Name: "one_id_2", Type: "string", Nullable: true, Unique: true},
|
||||||
},
|
},
|
||||||
FKeys: []ForeignKey{
|
FKeys: []ForeignKey{
|
||||||
{Column: "one_id_1", ForeignTable: "one", ForeignColumn: "id1"},
|
{Column: "one_id_1", ForeignTable: "one", ForeignColumn: "id1"},
|
||||||
|
@ -184,16 +184,16 @@ func TestSetRelationships(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []Table{
|
tables := []Table{
|
||||||
Table{
|
{
|
||||||
Name: "one",
|
Name: "one",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
Column{Name: "id", Type: "string"},
|
{Name: "id", Type: "string"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Table{
|
{
|
||||||
Name: "other",
|
Name: "other",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
Column{Name: "other_id", Type: "string"},
|
{Name: "other_id", Type: "string"},
|
||||||
},
|
},
|
||||||
FKeys: []ForeignKey{{Column: "other_id", ForeignTable: "one", ForeignColumn: "id", Nullable: true}},
|
FKeys: []ForeignKey{{Column: "other_id", ForeignTable: "one", ForeignColumn: "id", Nullable: true}},
|
||||||
},
|
},
|
||||||
|
|
|
@ -69,27 +69,27 @@ func TestAutoIncPrimaryKey(t *testing.T) {
|
||||||
Ok: true,
|
Ok: true,
|
||||||
Expect: Column{Name: "one", Type: "int32", Nullable: false, Default: `nextval('abc'::regclass)`},
|
Expect: Column{Name: "one", Type: "int32", Nullable: false, Default: `nextval('abc'::regclass)`},
|
||||||
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
||||||
Columns: []Column{Column{Name: "one", Type: "int32", Nullable: false, Default: `nextval('abc'::regclass)`}},
|
Columns: []Column{{Name: "one", Type: "int32", Nullable: false, Default: `nextval('abc'::regclass)`}},
|
||||||
},
|
},
|
||||||
"missingcase": {
|
"missingcase": {
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"two"}},
|
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"two"}},
|
||||||
Columns: []Column{Column{Name: "one", Type: "int32", Nullable: false, Default: `nextval('abc'::regclass)`}},
|
Columns: []Column{{Name: "one", Type: "int32", Nullable: false, Default: `nextval('abc'::regclass)`}},
|
||||||
},
|
},
|
||||||
"wrongtype": {
|
"wrongtype": {
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
||||||
Columns: []Column{Column{Name: "one", Type: "string", Nullable: false, Default: `nextval('abc'::regclass)`}},
|
Columns: []Column{{Name: "one", Type: "string", Nullable: false, Default: `nextval('abc'::regclass)`}},
|
||||||
},
|
},
|
||||||
"nodefault": {
|
"nodefault": {
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
||||||
Columns: []Column{Column{Name: "one", Type: "string", Nullable: false, Default: ``}},
|
Columns: []Column{{Name: "one", Type: "string", Nullable: false, Default: ``}},
|
||||||
},
|
},
|
||||||
"nullable": {
|
"nullable": {
|
||||||
Ok: false,
|
Ok: false,
|
||||||
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
Pkey: &PrimaryKey{Name: "pkey", Columns: []string{"one"}},
|
||||||
Columns: []Column{Column{Name: "one", Type: "string", Nullable: true, Default: `nextval('abc'::regclass)`}},
|
Columns: []Column{{Name: "one", Type: "string", Nullable: true, Default: `nextval('abc'::regclass)`}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []Table{
|
tables := []Table{
|
||||||
Table{Name: "users", Columns: []Column{{Name: "id"}}},
|
{Name: "users", Columns: []Column{{Name: "id"}}},
|
||||||
Table{Name: "contests", Columns: []Column{{Name: "id"}}},
|
{Name: "contests", Columns: []Column{{Name: "id"}}},
|
||||||
Table{
|
{
|
||||||
Name: "videos",
|
Name: "videos",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
{Name: "id"},
|
{Name: "id"},
|
||||||
|
@ -23,7 +23,7 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
{Name: "videos_contest_id_fk", Column: "contest_id", ForeignTable: "contests", ForeignColumn: "id"},
|
{Name: "videos_contest_id_fk", Column: "contest_id", ForeignTable: "contests", ForeignColumn: "id"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Table{
|
{
|
||||||
Name: "notifications",
|
Name: "notifications",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
{Name: "user_id"},
|
{Name: "user_id"},
|
||||||
|
@ -34,7 +34,7 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
{Name: "notifications_source_id_fk", Column: "source_id", ForeignTable: "users", ForeignColumn: "id"},
|
{Name: "notifications_source_id_fk", Column: "source_id", ForeignTable: "users", ForeignColumn: "id"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Table{
|
{
|
||||||
Name: "users_video_tags",
|
Name: "users_video_tags",
|
||||||
IsJoinTable: true,
|
IsJoinTable: true,
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
|
@ -51,7 +51,7 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
relationships := ToManyRelationships("users", tables)
|
relationships := ToManyRelationships("users", tables)
|
||||||
|
|
||||||
expected := []ToManyRelationship{
|
expected := []ToManyRelationship{
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: false,
|
Nullable: false,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
|
@ -63,7 +63,7 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
|
|
||||||
ToJoinTable: false,
|
ToJoinTable: false,
|
||||||
},
|
},
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: false,
|
Nullable: false,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
|
@ -75,7 +75,7 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
|
|
||||||
ToJoinTable: false,
|
ToJoinTable: false,
|
||||||
},
|
},
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: false,
|
Nullable: false,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
|
@ -87,7 +87,7 @@ func TestToManyRelationships(t *testing.T) {
|
||||||
|
|
||||||
ToJoinTable: false,
|
ToJoinTable: false,
|
||||||
},
|
},
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: false,
|
Nullable: false,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
|
@ -125,9 +125,9 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tables := []Table{
|
tables := []Table{
|
||||||
Table{Name: "users", Columns: []Column{{Name: "id", Nullable: true, Unique: true}}},
|
{Name: "users", Columns: []Column{{Name: "id", Nullable: true, Unique: true}}},
|
||||||
Table{Name: "contests", Columns: []Column{{Name: "id", Nullable: true, Unique: true}}},
|
{Name: "contests", Columns: []Column{{Name: "id", Nullable: true, Unique: true}}},
|
||||||
Table{
|
{
|
||||||
Name: "videos",
|
Name: "videos",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
{Name: "id", Nullable: true, Unique: true},
|
{Name: "id", Nullable: true, Unique: true},
|
||||||
|
@ -139,7 +139,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
{Name: "videos_contest_id_fk", Column: "contest_id", ForeignTable: "contests", ForeignColumn: "id", Nullable: true, Unique: true},
|
{Name: "videos_contest_id_fk", Column: "contest_id", ForeignTable: "contests", ForeignColumn: "id", Nullable: true, Unique: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Table{
|
{
|
||||||
Name: "notifications",
|
Name: "notifications",
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
{Name: "user_id", Nullable: true, Unique: true},
|
{Name: "user_id", Nullable: true, Unique: true},
|
||||||
|
@ -150,7 +150,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
{Name: "notifications_source_id_fk", Column: "source_id", ForeignTable: "users", ForeignColumn: "id", Nullable: true, Unique: true},
|
{Name: "notifications_source_id_fk", Column: "source_id", ForeignTable: "users", ForeignColumn: "id", Nullable: true, Unique: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Table{
|
{
|
||||||
Name: "users_video_tags",
|
Name: "users_video_tags",
|
||||||
IsJoinTable: true,
|
IsJoinTable: true,
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
|
@ -170,7 +170,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := []ToManyRelationship{
|
expected := []ToManyRelationship{
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: true,
|
Nullable: true,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
|
@ -182,7 +182,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
|
|
||||||
ToJoinTable: false,
|
ToJoinTable: false,
|
||||||
},
|
},
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: true,
|
Nullable: true,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
|
@ -194,7 +194,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
|
|
||||||
ToJoinTable: false,
|
ToJoinTable: false,
|
||||||
},
|
},
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: true,
|
Nullable: true,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
|
@ -206,7 +206,7 @@ func TestToManyRelationshipsNull(t *testing.T) {
|
||||||
|
|
||||||
ToJoinTable: false,
|
ToJoinTable: false,
|
||||||
},
|
},
|
||||||
ToManyRelationship{
|
{
|
||||||
Column: "id",
|
Column: "id",
|
||||||
Nullable: true,
|
Nullable: true,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestGetColumn(t *testing.T) {
|
||||||
|
|
||||||
table := Table{
|
table := Table{
|
||||||
Columns: []Column{
|
Columns: []Column{
|
||||||
Column{Name: "one"},
|
{Name: "one"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
imports.go
40
imports.go
|
@ -155,7 +155,7 @@ var defaultTemplateImports = imports{
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultSingletonTemplateImports = map[string]imports{
|
var defaultSingletonTemplateImports = map[string]imports{
|
||||||
"boil_helpers": imports{
|
"boil_helpers": {
|
||||||
standard: importList{},
|
standard: importList{},
|
||||||
thirdParty: importList{
|
thirdParty: importList{
|
||||||
`"github.com/nullbio/sqlboiler/boil"`,
|
`"github.com/nullbio/sqlboiler/boil"`,
|
||||||
|
@ -179,7 +179,7 @@ var defaultTestTemplateImports = imports{
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultSingletonTestTemplateImports = map[string]imports{
|
var defaultSingletonTestTemplateImports = map[string]imports{
|
||||||
"boil_main_helpers": imports{
|
"boil_main_helpers": {
|
||||||
standard: importList{
|
standard: importList{
|
||||||
`"database/sql"`,
|
`"database/sql"`,
|
||||||
`"os"`,
|
`"os"`,
|
||||||
|
@ -189,7 +189,7 @@ var defaultSingletonTestTemplateImports = map[string]imports{
|
||||||
`"github.com/spf13/viper"`,
|
`"github.com/spf13/viper"`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"boil_helpers": imports{
|
"boil_helpers": {
|
||||||
standard: importList{
|
standard: importList{
|
||||||
`"crypto/md5"`,
|
`"crypto/md5"`,
|
||||||
`"fmt"`,
|
`"fmt"`,
|
||||||
|
@ -205,7 +205,7 @@ var defaultSingletonTestTemplateImports = map[string]imports{
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultTestMainImports = map[string]imports{
|
var defaultTestMainImports = map[string]imports{
|
||||||
"postgres": imports{
|
"postgres": {
|
||||||
standard: importList{
|
standard: importList{
|
||||||
`"testing"`,
|
`"testing"`,
|
||||||
`"os"`,
|
`"os"`,
|
||||||
|
@ -233,52 +233,52 @@ var defaultTestMainImports = map[string]imports{
|
||||||
// database requires one of the following special types. Check
|
// database requires one of the following special types. Check
|
||||||
// TranslateColumnType to see the type assignments.
|
// TranslateColumnType to see the type assignments.
|
||||||
var importsBasedOnType = map[string]imports{
|
var importsBasedOnType = map[string]imports{
|
||||||
"null.Float32": imports{
|
"null.Float32": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Float64": imports{
|
"null.Float64": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Int": imports{
|
"null.Int": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Int8": imports{
|
"null.Int8": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Int16": imports{
|
"null.Int16": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Int32": imports{
|
"null.Int32": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Int64": imports{
|
"null.Int64": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Uint": imports{
|
"null.Uint": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Uint8": imports{
|
"null.Uint8": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Uint16": imports{
|
"null.Uint16": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Uint32": imports{
|
"null.Uint32": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Uint64": imports{
|
"null.Uint64": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.String": imports{
|
"null.String": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Bool": imports{
|
"null.Bool": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"null.Time": imports{
|
"null.Time": {
|
||||||
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
|
||||||
},
|
},
|
||||||
"time.Time": imports{
|
"time.Time": {
|
||||||
standard: importList{`"time"`},
|
standard: importList{`"time"`},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,16 +78,16 @@ func TestCombineTypeImports(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cols := []bdb.Column{
|
cols := []bdb.Column{
|
||||||
bdb.Column{
|
{
|
||||||
Type: "null.Time",
|
Type: "null.Time",
|
||||||
},
|
},
|
||||||
bdb.Column{
|
{
|
||||||
Type: "null.Time",
|
Type: "null.Time",
|
||||||
},
|
},
|
||||||
bdb.Column{
|
{
|
||||||
Type: "time.Time",
|
Type: "time.Time",
|
||||||
},
|
},
|
||||||
bdb.Column{
|
{
|
||||||
Type: "null.Float",
|
Type: "null.Float",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue