From 98697bc2d39202dec374acec165d7921113e33dd Mon Sep 17 00:00:00 2001 From: David Kretch Date: Mon, 13 May 2019 11:05:47 -0400 Subject: [PATCH] Fix tests which stopped working in AppVeyor (#155) --- make.paws/tests/testthat/test_operations.R | 2 -- make.paws/tests/testthat/test_tests.R | 30 +++++++--------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/make.paws/tests/testthat/test_operations.R b/make.paws/tests/testthat/test_operations.R index 1d4816d610..4b89d25309 100644 --- a/make.paws/tests/testthat/test_operations.R +++ b/make.paws/tests/testthat/test_operations.R @@ -1,7 +1,5 @@ context("Make operations") -code <- function(x) paste(deparse(substitute(x)), collapse = "\n") - test_that("make_operation", { operation <- list( name = "Operation", diff --git a/make.paws/tests/testthat/test_tests.R b/make.paws/tests/testthat/test_tests.R index 6202ce4ae3..269d3687f4 100644 --- a/make.paws/tests/testthat/test_tests.R +++ b/make.paws/tests/testthat/test_tests.R @@ -1,15 +1,5 @@ context("Make tests") -# Allow us to capture code to compare it against a function's output. -code <- function(x) { - text <- deparse(substitute(x)) - if (text[1] == "{") { - text <- text[-1] - text <- text[-length(text)] - } - result <- paste(text, collapse = "\n") -} - # Format code so differences in style don't affect comparisons. format_test_code <- function(code) { formatted <- formatR::tidy_source(text = code, output = FALSE) @@ -27,11 +17,11 @@ test_that("make_test no arguments", { name = "foo" ) a <- make_test(operation, api, NULL, NA) - e <- code({ - test_that("foo", { + e <- + 'test_that("foo", { expect_error(svc$foo(), NA) }) - }) + ' actual <- format_test_code(a) expected <- format_test_code(e) expect_equal(actual, expected) @@ -47,11 +37,11 @@ test_that("make_test with arguments", { name = "foo" ) a <- make_test(operation, api, list('"bar"', 123), NA) - e <- code({ - test_that("foo", { + e <- + 'test_that("foo", { expect_error(svc$foo("bar", 123), NA) }) - }) + ' actual <- format_test_code(a) expected <- format_test_code(e) expect_equal(actual, expected) @@ -102,8 +92,8 @@ test_that("make_tests", { ) ) a <- make_tests(api) - e <- code({ - context("api") + e <- + 'context("api") svc <- paws::api() @@ -118,10 +108,8 @@ test_that("make_tests", { test_that("list_bar", { expect_error(svc$list_bar(), NA) }) - }) + ' actual <- format_test_code(a) expected <- format_test_code(e) - expected <- sapply(expected, function(x) c(x, "")) # re-insert blank lines. - expected <- expected[-length(expected)] # no trailing blank line. expect_equal(actual, expected) })