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