-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
application/octet-stream
serializer (#864)
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
test_that("octet serializes raw objects properly", { | ||
|
||
content <- charToRaw("Beware of bugs in the above code; I have only proved it correct, not tried it.") | ||
|
||
val <- serializer_octet()(content, list(), PlumberResponse$new(), stop) | ||
expect_equal(val$status, 200L) | ||
expect_equal(val$headers$`Content-Type`, "application/octet-stream") | ||
expect_equal(val$body, content) | ||
expect_equal(rawToChar(val$body), rawToChar(content)) | ||
}) | ||
|
||
test_that("octet throws on non-raw objects", { | ||
|
||
content <- "Beware of bugs in the above code; I have only proved it correct, not tried it." | ||
|
||
expect_error( | ||
serializer_octet()( | ||
content, | ||
list(), | ||
PlumberResponse$new(), | ||
function(req, res, err) stop(err) | ||
), | ||
"received non-raw data", | ||
) | ||
}) |