title: SQL Mock testing Insert in go
body: <p>I am trying to set up unit test for my CreatePolicy method in my API. it takes three fields: Id, Name and Kind. Kind should be either Allow or Deny. I am getting this error after setting up the following tests.</p>
  <pre><code>    expected: &quot;[{\&quot;ID\&quot;:\&quot;cea0b319-9027-4542-9769- 
      de056efdf8b1\&quot;,\&quot;Name\&quot;:\&quot;test\&quot;,\&quot;Kind\&quot;:\&quot;ALLOW\&quot;}]&quot;
  
      actual  : &quot;{\&quot;errors\&quot;: 
      [{\&quot;field\&quot;:\&quot;Kind\&quot;,\&quot;error\&quot;:\&quot;oneof\&quot;,\&quot;expected_value\&quot;:\&quot;ALLOW DENY\&quot;}]}&quot;
                              
  
  func (ts *TestSuite) TestCreatePolicy() {
  
      val := uuid.NewString()
      prep := ts.mock.ExpectPrepare(&quot;INSERT INTO policies&quot;)
  
      prep.ExpectExec().WithArgs(val, &quot;test&quot;, &quot;ALLOW&quot;).WillReturnResult(sqlmock.NewResult(1, 1))
  
      ts.app.PolicyCreate(ts.testContext)
  
      // Assert all the queries were executed in the server.
      err := ts.mock.ExpectationsWereMet()
      assert.Nil(ts.T(), err)
  
      // The response should be 200 OK
      assert.Equal(ts.T(), 200, ts.recorder.Code)
  
      // The response should be JSON
      assert.Equal(ts.T(), &quot;application/json; charset=utf-8&quot;, ts.recorder.Header().Get(&quot;Content-Type&quot;))
  
      ts.mock.ExpectClose()
  
      expectedPolicy := []repo.Policy{
          {
              ID:   val,
              Name: &quot;test&quot;,
              Kind: &quot;ALLOW&quot;,
          },
      }
  
      expectedPolicyStr, _ := json.Marshal(expectedPolicy)
  
      // The response should be a valid JSON
      assert.Equal(ts.T(), string(expectedPolicyStr), ts.recorder.Body.String())
  
  }
  </code></pre>