title: Issue with go-sqlmock testing in the expected query part
body: <p>I am using <code>go-sqlmock</code> for the first time and I am trying to write a test for post operation. I am using <code>gorm</code> and <code>gin</code>.</p>
  <ol>
  <li>The test is giving me an error where <code>s.mock.ExpectQuery(regexp.QuoteMeta(....</code> I am not what is the issue here. I have posted both the test and the output.</li>
  <li>Also, (this has nothing to do with 1) in this test I really do not know what the <code>code</code> will be as it is randomly generated in the api controller. Is there a way to assign a generic number in the <code>code</code> field.</li>
  </ol>
  <p>The test file</p>
  <pre class="lang-golang prettyprint-override"><code>     package unit
      
       import (
          &quot;net/http&quot;
          &quot;net/http/httptest&quot;
          &quot;regexp&quot;
          &quot;testing&quot;
      
          &quot;github.com/DATA-DOG/go-sqlmock&quot;
          &quot;github.com/SamiAlsubhi/go/controllers&quot;
          &quot;github.com/SamiAlsubhi/go/routes&quot;
          &quot;github.com/gin-gonic/gin&quot;
          &quot;github.com/stretchr/testify/assert&quot;
          &quot;github.com/stretchr/testify/require&quot;
          &quot;github.com/stretchr/testify/suite&quot;
          &quot;gorm.io/driver/postgres&quot;
          &quot;gorm.io/gorm&quot;
       )
      
      type Suite struct {
          suite.Suite
          DB     *gorm.DB
          mock   sqlmock.Sqlmock
          router *gin.Engine
      }
      
      func (s *Suite) SetupSuite(t *testing.T) {
          conn, mock, err := sqlmock.New()
          if err != nil || conn == nil {
              t.Errorf(&quot;Failed to open mock sql db, got error: %v&quot;, err)
          }
          s.mock = mock
      
          dialector := postgres.New(postgres.Config{
              DSN:                  &quot;sqlmock_db_0&quot;,
              DriverName:           &quot;postgres&quot;,
              Conn:                 conn,
              PreferSimpleProtocol: true,
          })
      
          if db, err := gorm.Open(dialector, &amp;gorm.Config{}); err != nil || db == nil {
              t.Errorf(&quot;Failed to open gorm v2 db, got error: %v&quot;, err)
          } else {
              s.DB = db
          }
          api := &amp;controllers.API{Db: s.DB}
      
          s.router = routes.SetupRouter(api)
      
      }
      
      func TestSetup(t *testing.T) {
          suite.Run(t, new(Suite))
      
      }
      
      func (s *Suite) AfterTest(_, _ string) {
          require.NoError(s.T(), s.mock.ExpectationsWereMet())
      }
      
      func (s *Suite) Test_GetOTP() {
          var (
              phone = &quot;99999999&quot;
              code  = &quot;123456&quot;
          )
      
          s.mock.ExpectQuery(regexp.QuoteMeta(
              `INSERT INTO &quot;otps&quot; (&quot;phone&quot;,&quot;code&quot;) VALUES ($1,$2) RETURNING &quot;otps&quot;.&quot;id&quot;`)).
              WithArgs(phone, code).
              WillReturnRows(sqlmock.NewRows([]string{&quot;id&quot;}).
                  AddRow(1))
      
          s.mock.ExpectCommit()
      
          w := httptest.NewRecorder()
          req, err := http.NewRequest(&quot;GET&quot;, &quot;/api/auth/get-otp/&quot;+phone, nil)
          require.NoError(s.T(), err)
      
          s.router.ServeHTTP(w, req)
          assert.Equal(s.T(), 200, w.Code)
      
          //require.Nil(s.T(), deep.Equal(&amp;model.Person{ID: id, Name: name}, w.Body))
      }
  </code></pre>
  <p>the output.</p>
  <pre class="lang-golang prettyprint-override"><code>    --- FAIL: TestSetup (0.00s)
          --- FAIL: TestSetup/Test_GetOTP (0.00s)
              /Users/sami/Desktop/SamiAlsubhi/go/test/unit/suite.go:63: test panicked: runtime error: invalid memory address or nil pointer dereference
                  goroutine 26 [running]:
                  runtime/debug.Stack()
                      /usr/local/go/src/runtime/debug/stack.go:24 +0x65
                  github.com/stretchr/testify/suite.failOnPanic(0xc000001a00)
                      /Users/sami/Desktop/golang/pkg/mod/github.com/stretchr/testify@v1.7.0/suite/suite.go:63 +0x3e
                  panic({0x49e96a0, 0x5193810})
                      /usr/local/go/src/runtime/panic.go:1038 +0x215
                  github.com/SamiAlsubhi/go/test/unit.(*Suite).AfterTest(0x4abe61b, {0x4becfd0, 0xc000468940}, {0x0, 0x0})
                      /Users/sami/Desktop/SamiAlsubhi/go/test/unit/setup_test.go:60 +0x1c
                  github.com/stretchr/testify/suite.Run.func1.1()
                      /Users/sami/Desktop/golang/pkg/mod/github.com/stretchr/testify@v1.7.0/suite/suite.go:137 +0x1b7
                  panic({0x49e96a0, 0x5193810})
                      /usr/local/go/src/runtime/panic.go:1038 +0x215
                  github.com/SamiAlsubhi/go/test/unit.(*Suite).Test_GetOTP(0xc000468940)
                      /Users/sami/Desktop/SamiAlsubhi/go/test/unit/setup_test.go:69 +0x4f
                  reflect.Value.call({0xc000049140, 0xc000010308, 0x13}, {0x4abf50c, 0x4}, {0xc000080e70, 0x1, 0x1})
                      /usr/local/go/src/reflect/value.go:543 +0x814
                  reflect.Value.Call({0xc000049140, 0xc000010308, 0xc000468940}, {0xc0003c9e70, 0x1, 0x1})
                      /usr/local/go/src/reflect/value.go:339 +0xc5
                  github.com/stretchr/testify/suite.Run.func1(0xc000001a00)
                      /Users/sami/Desktop/golang/pkg/mod/github.com/stretchr/testify@v1.7.0/suite/suite.go:158 +0x4b6
                  testing.tRunner(0xc000001a00, 0xc000162000)
                      /usr/local/go/src/testing/testing.go:1259 +0x102
                  created by testing.(*T).Run
                      /usr/local/go/src/testing/testing.go:1306 +0x35a
      FAIL
      coverage: [no statements]
      FAIL    github.com/SamiAlsubhi/go/test/unit 0.912s
      FAIL
  </code></pre>