2016-08-02 11:56:55 +02:00
|
|
|
{{- $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) {
|
2016-08-14 10:58:36 +02:00
|
|
|
t.Parallel()
|
2016-08-02 11:56:55 +02:00
|
|
|
|
2016-08-15 05:14:39 +02:00
|
|
|
seed := new(boil.Seed)
|
|
|
|
var err error
|
2016-08-14 10:58:36 +02:00
|
|
|
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
2016-08-15 05:14:39 +02:00
|
|
|
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
2016-08-14 11:11:32 +02:00
|
|
|
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
2016-08-02 11:56:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-15 05:14:39 +02:00
|
|
|
tx := MustTx(boil.Begin())
|
2016-08-14 10:58:36 +02:00
|
|
|
defer tx.Rollback()
|
|
|
|
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
|
|
|
t.Error(err)
|
2016-08-02 11:56:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-14 10:58:36 +02:00
|
|
|
if err = {{$varNameSingular}}.Reload(tx); err != nil {
|
2016-08-11 14:26:49 +02:00
|
|
|
t.Error(err)
|
|
|
|
}
|
2016-08-02 11:56:55 +02:00
|
|
|
}
|
2016-08-08 15:30:29 +02:00
|
|
|
|
|
|
|
func Test{{$tableNamePlural}}ReloadAll(t *testing.T) {
|
2016-08-14 10:58:36 +02:00
|
|
|
t.Parallel()
|
2016-08-08 15:30:29 +02:00
|
|
|
|
2016-08-15 05:14:39 +02:00
|
|
|
seed := new(boil.Seed)
|
|
|
|
var err error
|
2016-08-14 10:58:36 +02:00
|
|
|
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
2016-08-15 05:14:39 +02:00
|
|
|
if err = seed.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
|
2016-08-14 11:11:32 +02:00
|
|
|
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
2016-08-08 15:30:29 +02:00
|
|
|
}
|
|
|
|
|
2016-08-15 05:14:39 +02:00
|
|
|
tx := MustTx(boil.Begin())
|
2016-08-14 10:58:36 +02:00
|
|
|
defer tx.Rollback()
|
|
|
|
if err = {{$varNameSingular}}.Insert(tx); err != nil {
|
|
|
|
t.Error(err)
|
2016-08-08 15:30:29 +02:00
|
|
|
}
|
|
|
|
|
2016-08-14 10:58:36 +02:00
|
|
|
slice := {{$tableNameSingular}}Slice{{"{"}}{{$varNameSingular}}{{"}"}}
|
2016-08-08 15:30:29 +02:00
|
|
|
|
2016-08-14 10:58:36 +02:00
|
|
|
if err = slice.ReloadAll(tx); err != nil {
|
|
|
|
t.Error(err)
|
2016-08-08 15:30:29 +02:00
|
|
|
}
|
|
|
|
}
|