eddelbuettel/rpushbullet — pull request #17 by mikebirdgeneau (2014-12-29 16:32:35+00:00)
Title: Add additional file tests & fix argument issues.

Hi @eddelbuettel,
I started by looking at the file testing before moving onto channels. I'm submitting this pull request so that we can discuss a summary of what I did:

1. Started by looking at what happened in the fallback case when a default device was missing. Noticed that `match` returned NA when the fallback case of `0` was returned from `.getDefaultDevice()`. Fixed by adding if statement to avoid passing NA to `dest` (ebb7614).

2. Reviewed existing tests in `tests/simpleTests.R`. Found that I was getting an error in the fromJSON function. Added `[[1]]` to access the first list element returned from each call to `pbPost`. This allowed me to run the tests without issue. (d0c2518)

3. Added additional tests to handle files with different arguments passed for `recipients`, `email`, in addition to the existing case where these arguments were blank (b71c19a). Based on some of this testing, I'm wondering about the best approach to determine if the test has 'passed' given that no error is returned.

4. In order to make tests more generic, replaced hard-coded email and device names with values obtained from the configuration file, as well as the active user's email from the results of an earlier test (22fbb7a).

5. All tests were running without returning errors, but the file_url argument was not being passed correctly to curl. This appears to be an issue with the arguments passed to sprintf. I updated the arguments for consistency with the rest of the code in `R/pushes.R` (which also happens to align with the order used in the pushbullet API documentation). In doing this, I noticed that there were only 7 `%s` placeholders when 8 arguments were being passed. I added an extra `%s` which results in all tests passing for me (6352e16).

Hopefully at least some of this work helps.
Mike