2411: add copyright headers to our R files.
[arvados.git] / sdk / R / tests / testthat / test-HttpRequest.R
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 context("Http Request")
6
7
8 test_that("execyte raises exception if http verb is not valid", {
9
10     http <- HttpRequest$new()
11     expect_that(http$exec("FAKE VERB", "url"),
12                throws_error("Http verb is not valid."))
13 }) 
14
15 test_that("createQuery generates and encodes query portion of http", {
16
17     http <- HttpRequest$new()
18     queryParams <- list()
19     queryParams$filters <- list(list("color", "=", "red"))
20     queryParams$limit <- 20
21     queryParams$offset <- 50
22     expect_that(http$createQuery(queryParams),
23                 equals(paste0("/?filters=%5B%5B%22color%22%2C%22%3D%22%2C%22red",
24                               "%22%5D%5D&limit=20&offset=50")))
25 }) 
26
27 test_that("createQuery generates and empty string when queryParams is an empty list", {
28
29     http <- HttpRequest$new()
30     expect_that(http$createQuery(list()), equals(""))
31 })