Skip to content

Commit

Permalink
Added some more tests for not installed packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
oscpe436 committed Dec 30, 2015
1 parent 9f2ca62 commit ae52bfc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions inst/extdata/example_assignment08_bad_pkgs.yml
@@ -0,0 +1,15 @@
name : Test assignment 01
description : An example of how an assignment requiring packages can be constructed.
reporter : student
tasks:
task1:
url:
- https://raw.githubusercontent.com/MansMeg/markmyassignment/master/inst/extdata/example_task1.R
task2:
url:
- https://raw.githubusercontent.com/MansMeg/markmyassignment/master/inst/extdata/example_task2_a.R
- https://raw.githubusercontent.com/MansMeg/markmyassignment/master/inst/extdata/example_task2_b.R
mandatory:
url:
- https://raw.githubusercontent.com/MansMeg/markmyassignment/master/inst/extdata/example_mandatory.R
packages: ['nonsense_pkg_q5pHq9N18oQoSXARECby']
3 changes: 3 additions & 0 deletions tests/testthat/test-set_assignment.R
Expand Up @@ -39,9 +39,12 @@ test_that(desc="show_tasks()",{
})

test_that(desc="check_installed_packages()",{
assgn_path <- paste0(system.file(package = "markmyassignment"), "/extdata/example_assignment08_bad_pkgs.yml")
expect_warning(set_assignment(path = assgn_path), regexp = "The following packages need to be installed and then loaded")
assgn_path <- paste0(system.file(package = "markmyassignment"), "/extdata/example_assignment07_pkgs.yml")
expect_warning(set_assignment(path = assgn_path))
if( all(c("ggplot2", "stringr") %in% installed.packages()) ){
expect_warning(set_assignment(path = assgn_path), regexp = "The following packages need to be loaded")
library(ggplot2) ; library(stringr)
expect_is(suppressMessages(set_assignment(assgn_path)), "character")
}
Expand Down

0 comments on commit ae52bfc

Please sign in to comment.