sqlboiler/templates_test/select.tpl
Aaron L 1caa8afa73 Change seed to start at a random value.
- Insert at least some randomness.
2016-08-14 20:44:59 -07:00

29 lines
930 B
Smarty

{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
{{- $tableNamePlural := .Table.Name | plural | titleCase -}}
{{- $varNamePlural := .Table.Name | plural | camelCase -}}
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
func Test{{$tableNamePlural}}Select(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, err := {{$tableNamePlural}}(tx).All()
if err != nil {
t.Error(err)
}
if len(slice) != 1 {
t.Error("want one record, got:", len(slice))
}
}