You've already forked go-sqlmock
							
							
				mirror of
				https://github.com/DATA-DOG/go-sqlmock.git
				synced 2025-10-30 23:47:46 +02:00 
			
		
		
		
	added tests
This commit is contained in:
		| @@ -642,6 +642,12 @@ func TestPingExpectationsContextTimeout(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type failArgument struct{} | ||||
|  | ||||
| func (f failArgument) Match(_ driver.Value) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func Test_sqlmock_Exec(t *testing.T) { | ||||
| 	db, mock, err := New() | ||||
| 	if err != nil { | ||||
| @@ -652,7 +658,12 @@ func Test_sqlmock_Exec(t *testing.T) { | ||||
|  | ||||
| 	expected := NewResult(1, 1) | ||||
| 	mock.ExpectExec("SELECT (.+) FROM users WHERE (.+)"). | ||||
| 		WillReturnResult(expected) | ||||
| 		WillReturnResult(expected). | ||||
| 		WithArgs("test") | ||||
|  | ||||
| 	mock.ExpectExec("SELECT (.+) FROM animals WHERE (.+)"). | ||||
| 		WillReturnError(errors.New("matcher %T could not match %d argument %T - %+v")). | ||||
| 		WithArgs(failArgument{}) | ||||
|  | ||||
| 	result, err := mock.(*sqlmock).Exec(query, []driver.Value{"test"}) | ||||
| 	if err != nil { | ||||
| @@ -663,6 +674,12 @@ func Test_sqlmock_Exec(t *testing.T) { | ||||
| 		t.Errorf("Results are not equal. Expected: %v, Actual: %v", expected, result) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	_, err = mock.(*sqlmock).Exec(query, []driver.Value{failArgument{}}) | ||||
| 	if err == nil { | ||||
| 		t.Errorf("error expected") | ||||
| 		return | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_sqlmock_Query(t *testing.T) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user