5c2fb602fdb1edb1bdee38e93b831a35c34bb6f0
[arvados.git] / sdk / R / tests / testthat / test-HttpRequest.R
1 context("Http Request")
2
3
4 test_that("execyte raises exception if http verb is not valid", {
5
6     http <- HttpRequest$new()
7     expect_that(http$exec("FAKE VERB", "url"),
8                throws_error("Http verb is not valid."))
9 }) 
10
11 test_that("createQuery generates and encodes query portion of http", {
12
13     http <- HttpRequest$new()
14     queryParams <- list()
15     queryParams$filters <- list(list("color", "=", "red"))
16     queryParams$limit <- 20
17     queryParams$offset <- 50
18     expect_that(http$createQuery(queryParams),
19                 equals(paste0("/?filters=%5B%5B%22color%22%2C%22%3D%22%2C%22red",
20                               "%22%5D%5D&limit=20&offset=50")))
21 }) 
22
23 test_that("createQuery generates and empty string when queryParams is an empty list", {
24
25     http <- HttpRequest$new()
26     expect_that(http$createQuery(list()), equals(""))
27 })