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 
			
		
		
		
	add a test for slice argument matching
This commit is contained in:
		| @@ -35,3 +35,24 @@ func TestAnyTimeArgument(t *testing.T) { | ||||
| 		t.Errorf("there were unfulfilled expections: %s", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestByteSliceArgument(t *testing.T) { | ||||
| 	t.Parallel() | ||||
| 	db, mock, err := New() | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an error '%s' was not expected when opening a stub database connection", err) | ||||
| 	} | ||||
| 	defer db.Close() | ||||
|  | ||||
| 	username := []byte("user") | ||||
| 	mock.ExpectExec("INSERT INTO users").WithArgs(username).WillReturnResult(NewResult(1, 1)) | ||||
|  | ||||
| 	_, err = db.Exec("INSERT INTO users(username) VALUES (?)", username) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("error '%s' was not expected, while inserting a row", err) | ||||
| 	} | ||||
|  | ||||
| 	if err := mock.ExpectationsWereMet(); err != nil { | ||||
| 		t.Errorf("there were unfulfilled expections: %s", err) | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user