<commit_before>{{- $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) {
  // Only run this test if there are ample cols to test on
  if len({{$varNameSingular}}AutoIncrementColumns) == 0 {
    return
  }

  var err error

  x := &struct{
  {{- $colNames := .Table.Columns | filterColumnsByAutoIncrement true | columnNames }}
  {{ $colTypes := .Table.Columns | filterColumnsByAutoIncrement true | columnTypes }}
  {{range $index, $element := $colNames}}
    {{$element | titleCase}} {{index $colTypes $index}}
  {{end}}
  }{}

  item := {{$tableNameSingular}}{}

  blacklistCols := strmangle.SetMerge({{$varNameSingular}}AutoIncrementColumns, {{$varNameSingular}}PrimaryKeyColumns)
  if err = boil.RandomizeStruct(&item, {{$varNameSingular}}DBTypes, false, blacklistCols...); err != nil {
    t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
  }

  if err = item.InsertG(); err != nil {
    t.Errorf("Unable to insert item {{$tableNameSingular}}:\n%#v\nErr: %s", item, err)
  }

  err = {{$tableNamePlural}}G(qm.Select({{$varNameSingular}}AutoIncrementColumns...), qm.Where(`{{whereClause 1 .Table.PKey.Columns}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})).Bind(x)
  if err != nil {
    t.Errorf("Unable to select insert results with bind: %s", err)
  }

  {{range $index, $element := $colNames }}
  {{$e := titleCase $element}}
  if item.{{$e}} != x.{{$e}} || x.{{$e}} == {{index $colTypes $index}}(0) {
    t.Errorf("Expected item.{{$e}} to match x.{{$e}}, but got: %v, %v", item.{{$e}}, x.{{$e}})
  }
  {{end}}

  {{$varNamePlural}}DeleteAllRows(t)
}<commit_msg>Refactor select test<commit_after>{{- $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) {
  {{$varNameSingular}} := &{{$tableNameSingular}}{}
  if err := boil.RandomizeStruct({{$varNameSingular}}, {{$varNameSingular}}DBTypes, true, {{$varNameSingular}}ColumnsWithDefault...); err != nil {
    t.Errorf("Unable to randomize {{$tableNameSingular}} slice: %s", err)
  }

  tx, err := boil.Begin()
  if err != nil {
    t.Fatal(err)
  }
  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))
  }
}
{'fraction_non_alphanumeric': 0.20522783468738962, 'fraction_numerical': 0.001412928293889085, 'mean_word_length': 4.2347504621072085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2101606', 'n_tokens_mistral': 1005, 'n_tokens_neox': 980, 'n_words': 214}