Make all tests create random seed and use MustTx
- Mark Upsert/Find for parallelism
This commit is contained in:
parent
490cdef5bc
commit
6f963d518c
12 changed files with 89 additions and 118 deletions
|
@ -5,17 +5,15 @@
|
|||
func Test{{$tableNamePlural}}Delete(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -37,17 +35,15 @@ func Test{{$tableNamePlural}}Delete(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}QueryDeleteAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -69,17 +65,15 @@ func Test{{$tableNamePlural}}QueryDeleteAll(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}SliceDeleteAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
func Test{{$tableNamePlural}}Exists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
{{- $varNamePlural := .Table.Name | plural | camelCase -}}
|
||||
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
||||
func Test{{$tableNamePlural}}Find(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
func Test{{$tableNamePlural}}Bind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -28,17 +26,15 @@ func Test{{$tableNamePlural}}Bind(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}One(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -53,21 +49,19 @@ func Test{{$tableNamePlural}}One(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}All(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}}One := &{{$tableNameSingular}}{}
|
||||
{{$varNameSingular}}Two := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}One, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}One, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}Two, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}Two, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}One.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -88,21 +82,19 @@ func Test{{$tableNamePlural}}All(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}Count(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var err error
|
||||
seed := new(boil.Seed)
|
||||
{{$varNameSingular}}One := &{{$tableNameSingular}}{}
|
||||
{{$varNameSingular}}Two := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}One, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}One, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}Two, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}Two, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}One.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ func Test{{$tableNamePlural}}InPrimaryKeyArgs(t *testing.T) {
|
|||
var o {{$tableNameSingular}}
|
||||
o = {{$tableNameSingular}}{}
|
||||
|
||||
if err = boil.RandomizeStruct(&o, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
seed := new(boil.Seed)
|
||||
if err = seed.RandomizeStruct(&o, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Could not randomize struct: %s", err)
|
||||
}
|
||||
|
||||
|
@ -34,9 +35,10 @@ func Test{{$tableNamePlural}}SliceInPrimaryKeyArgs(t *testing.T) {
|
|||
var err error
|
||||
o := make({{$tableNameSingular}}Slice, 3)
|
||||
|
||||
seed := new(boil.Seed)
|
||||
for i := range o {
|
||||
o[i] = &{{$tableNameSingular}}{}
|
||||
if err = boil.RandomizeStruct(o[i], {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct(o[i], {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Could not randomize struct: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ func Test{{$tableNamePlural}}Hooks(t *testing.T) {
|
|||
empty := &{{$tableNameSingular}}{}
|
||||
o := &{{$tableNameSingular}}{}
|
||||
|
||||
if err = boil.RandomizeStruct(o, {{$varNameSingular}}DBTypes, false); err != nil {
|
||||
seed := new(boil.Seed)
|
||||
if err = seed.RandomizeStruct(o, {{$varNameSingular}}DBTypes, false); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} object: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
func Test{{$tableNamePlural}}Insert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -34,17 +32,15 @@ func Test{{$tableNamePlural}}Insert(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}InsertWhitelist(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx, {{$varNameSingular}}Columns...); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -21,8 +21,9 @@ func Test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
boil.RandomizeStruct(&b, {{$rel.ForeignTable.NameSingular | camelCase}}DBTypes, false, "{{.ForeignColumn}}")
|
||||
boil.RandomizeStruct(&c, {{$rel.ForeignTable.NameSingular | camelCase}}DBTypes, false, "{{.ForeignColumn}}")
|
||||
seed := new(boil.Seed)
|
||||
seed.RandomizeStruct(&b, {{$rel.ForeignTable.NameSingular | camelCase}}DBTypes, false, "{{.ForeignColumn}}")
|
||||
seed.RandomizeStruct(&c, {{$rel.ForeignTable.NameSingular | camelCase}}DBTypes, false, "{{.ForeignColumn}}")
|
||||
{{if .Nullable -}}
|
||||
a.{{.Column | titleCase}}.Valid = true
|
||||
{{- end}}
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
func Test{{$tableNamePlural}}Reload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -28,17 +26,15 @@ func Test{{$tableNamePlural}}Reload(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}ReloadAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
func Test{{$tableNamePlural}}Select(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
func Test{{$tableNamePlural}}Update(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -29,7 +27,7 @@ func Test{{$tableNamePlural}}Update(t *testing.T) {
|
|||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
if err = boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
|
@ -41,17 +39,15 @@ func Test{{$tableNamePlural}}Update(t *testing.T) {
|
|||
func Test{{$tableNamePlural}}SliceUpdateAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -65,7 +61,7 @@ func Test{{$tableNamePlural}}SliceUpdateAll(t *testing.T) {
|
|||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
if err = boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
|
||||
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,21 +3,18 @@
|
|||
{{- $varNamePlural := .Table.Name | plural | camelCase -}}
|
||||
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
||||
func Test{{$tableNamePlural}}Upsert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := new(boil.Seed)
|
||||
var err error
|
||||
|
||||
{{$varNameSingular}} := {{$tableNameSingular}}{}
|
||||
|
||||
// Attempt the INSERT side of an UPSERT
|
||||
if err = boil.RandomizeStruct(&{{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
{{$varNameSingular}} := {{$tableNameSingular}}{}
|
||||
if err = seed.RandomizeStruct(&{{$varNameSingular}}, {{$varNameSingular}}DBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
tx, err := boil.Begin()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tx := MustTx(boil.Begin())
|
||||
defer tx.Rollback()
|
||||
|
||||
if err = {{$varNameSingular}}.Upsert(tx, false, nil, nil); err != nil {
|
||||
t.Errorf("Unable to upsert {{$tableNameSingular}}: %s", err)
|
||||
}
|
||||
|
@ -31,7 +28,7 @@ func Test{{$tableNamePlural}}Upsert(t *testing.T) {
|
|||
}
|
||||
|
||||
// Attempt the UPDATE side of an UPSERT
|
||||
if err = boil.RandomizeStruct(&{{$varNameSingular}}, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
|
||||
if err = seed.RandomizeStruct(&{{$varNameSingular}}, {{$varNameSingular}}DBTypes, false, {{$varNameSingular}}PrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue