Fix delete template test bug
* Begin Find template tests
This commit is contained in:
parent
62fe6a775c
commit
fb34fa6dab
3 changed files with 22 additions and 10 deletions
|
@ -11,7 +11,7 @@ func Test{{$tableNamePlural}}All(t *testing.T) {
|
||||||
|
|
||||||
o := make({{$varNameSingular}}Slice, 2)
|
o := make({{$varNameSingular}}Slice, 2)
|
||||||
if err = boil.RandomizeSlice(&o); err != nil {
|
if err = boil.RandomizeSlice(&o); err != nil {
|
||||||
t.Errorf("%d: Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert two random columns to test DeleteAll
|
// insert two random columns to test DeleteAll
|
||||||
|
@ -38,7 +38,7 @@ func Test{{$tableNamePlural}}All(t *testing.T) {
|
||||||
|
|
||||||
o = make({{$varNameSingular}}Slice, 3)
|
o = make({{$varNameSingular}}Slice, 3)
|
||||||
if err = boil.RandomizeSlice(&o); err != nil {
|
if err = boil.RandomizeSlice(&o); err != nil {
|
||||||
t.Errorf("%d: Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(o); i++ {
|
for i := 0; i < len(o); i++ {
|
||||||
|
|
|
@ -27,7 +27,7 @@ func Test{{$tableNamePlural}}QueryDeleteAll(t *testing.T) {
|
||||||
|
|
||||||
o := make({{$varNameSingular}}Slice, 3)
|
o := make({{$varNameSingular}}Slice, 3)
|
||||||
if err = boil.RandomizeSlice(&o); err != nil {
|
if err = boil.RandomizeSlice(&o); err != nil {
|
||||||
t.Errorf("%d: Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert random columns to test DeleteAll
|
// insert random columns to test DeleteAll
|
||||||
|
@ -59,7 +59,7 @@ func Test{{$tableNamePlural}}SliceDeleteAll(t *testing.T) {
|
||||||
// insert random columns to test DeleteAll
|
// insert random columns to test DeleteAll
|
||||||
o := make({{$varNameSingular}}Slice, 3)
|
o := make({{$varNameSingular}}Slice, 3)
|
||||||
if err = boil.RandomizeSlice(&o); err != nil {
|
if err = boil.RandomizeSlice(&o); err != nil {
|
||||||
t.Errorf("%d: Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(o); i++ {
|
for i := 0; i < len(o); i++ {
|
||||||
|
@ -89,15 +89,10 @@ func Test{{$tableNamePlural}}Delete(t *testing.T) {
|
||||||
// insert random columns to test Delete
|
// insert random columns to test Delete
|
||||||
o := make({{$varNameSingular}}Slice, 3)
|
o := make({{$varNameSingular}}Slice, 3)
|
||||||
if err = boil.RandomizeSlice(&o); err != nil {
|
if err = boil.RandomizeSlice(&o); err != nil {
|
||||||
t.Errorf("%d: Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(o); i++ {
|
for i := 0; i < len(o); i++ {
|
||||||
err = boil.RandomizeStruct(o[i])
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%d: Unable to randomize {{$tableNameSingular}} struct: %s", i, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = o[i].Insert()
|
err = o[i].Insert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{{- $tableNameSingular := titleCaseSingular .Table.Name -}}
|
||||||
|
{{- $dbName := singular .Table.Name -}}
|
||||||
|
{{- $tableNamePlural := titleCasePlural .Table.Name -}}
|
||||||
|
{{- $varNamePlural := camelCasePlural .Table.Name -}}
|
||||||
|
{{- $varNameSingular := camelCaseSingular .Table.Name -}}
|
||||||
|
|
||||||
|
func Test{{$tableNamePlural}}Find(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
{{$varNamePlural}}DeleteAllRows(t)
|
||||||
|
|
||||||
|
o := make({{$varNameSingular}}Slice, 3)
|
||||||
|
if err = boil.RandomizeSlice(&o); err != nil {
|
||||||
|
t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue