[R] add for more tests for URL validation (#13572)

* add url validation in r client

* update samples

* add more tests for url validation
This commit is contained in:
William Cheng 2022-10-03 13:34:27 +08:00 committed by GitHub
parent c939894711
commit 3ec6cc5bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -599,4 +599,14 @@ test_that("Tests URL validation", {
invalid_json <- '{"className":"date","percent_description":"abc","url_property":"invalid_url"}'
expect_error(Date$public_methods$validateJSON(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception
# test fromJSONString with valid data
d <- Date$new()
d$fromJSONString(valid_json)
expect_equal(d$className, "date")
expect_equal(d$percent_description, "abc")
expect_equal(d$url_property, "https://abc.com/a/1/b/2")
# test fromJSONString with invalid data
d <- Date$new()
expect_error(d$fromJSONString(invalid_json), 'Error! Invalid URL: invalid_url') # should throw exception
})