|
| 1 | + |
| 2 | +#------------------------------------------------------------------------------- |
| 3 | +# Copyright (c) 2019-2022 University of Newcastle upon Tyne. All rights reserved. |
| 4 | +# |
| 5 | +# This program and the accompanying materials |
| 6 | +# are made available under the terms of the GNU Public License v3.0. |
| 7 | +# |
| 8 | +# You should have received a copy of the GNU General Public License |
| 9 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 10 | +#------------------------------------------------------------------------------- |
| 11 | + |
| 12 | +# |
| 13 | +# Set up |
| 14 | +# |
| 15 | + |
| 16 | +context("utils::smk::setup") |
| 17 | +test_that(".loadServersideObject() returns existing object", { |
| 18 | + test_df <- data.frame(a = 1:3) |
| 19 | + result <- .loadServersideObject("test_df") |
| 20 | + expect_identical(result, test_df) |
| 21 | +}) |
| 22 | + |
| 23 | +test_that(".loadServersideObject() throws error for missing object", { |
| 24 | + expect_error( |
| 25 | + .loadServersideObject("nonexistent_obj"), |
| 26 | + regexp = "does not exist" |
| 27 | + ) |
| 28 | +}) |
| 29 | + |
| 30 | +test_that(".checkClass() passes for correct class", { |
| 31 | + df <- data.frame(a = 1) |
| 32 | + expect_invisible( |
| 33 | + .checkClass(df, "df", c("data.frame", "matrix")) |
| 34 | + ) |
| 35 | +}) |
| 36 | + |
| 37 | +test_that(".checkClass() throws informative error for wrong class", { |
| 38 | + x <- list(a = 1) |
| 39 | + expect_error( |
| 40 | + .checkClass(x, "x", c("data.frame", "matrix")), |
| 41 | + regexp = "must be of type data.frame or matrix" |
| 42 | + ) |
| 43 | +}) |
| 44 | + |
| 45 | +context("utils::smk::shutdown") |
| 46 | +context("utils::smk::done") |
0 commit comments