76d4b84019
* This fixes postgres deadlocks
47 lines
1.5 KiB
Smarty
47 lines
1.5 KiB
Smarty
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
|
|
{{- $tableNamePlural := .Table.Name | plural | titleCase -}}
|
|
{{- $varNamePlural := .Table.Name | plural | camelCase -}}
|
|
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
|
func test{{$tableNamePlural}}Reload(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
seed := boil.NewSeed()
|
|
var err error
|
|
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
|
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); 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)
|
|
}
|
|
|
|
if err = {{$varNameSingular}}.Reload(tx); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
func test{{$tableNamePlural}}ReloadAll(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
seed := boil.NewSeed()
|
|
var err error
|
|
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
|
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); 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)
|
|
}
|
|
|
|
slice := {{$tableNameSingular}}Slice{{"{"}}{{$varNameSingular}}{{"}"}}
|
|
|
|
if err = slice.ReloadAll(tx); err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|