Skip to content

Commit

Permalink
add a test for slice argument matching
Browse files Browse the repository at this point in the history
  • Loading branch information
l3pp4rd committed Feb 25, 2016
1 parent f071545 commit 3769fed
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions argument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 3769fed

Please sign in to comment.