Skip to content

Commit

Permalink
Test that 'git2r_arg_check_branch' raise error
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Widgren <stefan.widgren@gmail.com>
  • Loading branch information
stewid committed Mar 25, 2016
1 parent 50ec176 commit 95b43ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/branch.R
Expand Up @@ -67,6 +67,31 @@ b <- branch_create(commit.2, name = "test", force = TRUE)
stopifnot(identical(branch_target(branches(repo)[[1]]),
branch_target(branches(repo)[[2]])))

## Test arguments
res <- tools::assertError(.Call(git2r:::git2r_branch_delete, NULL))
stopifnot(length(grep("'branch' must be a S4 class git_branch",
res[[1]]$message)) > 0)
res <- tools::assertError(.Call(git2r:::git2r_branch_delete, 3))
stopifnot(length(grep("'branch' must be a S4 class git_branch",
res[[1]]$message)) > 0)
res <- tools::assertError(.Call(git2r:::git2r_branch_delete, repo))
stopifnot(length(grep("'branch' must be a S4 class git_branch",
res[[1]]$message)) > 0)
b_tmp <- b
b_tmp@name <- NA_character_
res <- tools::assertError(.Call(git2r:::git2r_branch_delete, b_tmp))
stopifnot(length(grep("'branch' must be a S4 class git_branch",
res[[1]]$message)) > 0)
b_tmp <- b
b_tmp@type <- NA_integer_
res <- tools::assertError(.Call(git2r:::git2r_branch_delete, b_tmp))
stopifnot(length(grep("'branch' must be a S4 class git_branch",
res[[1]]$message)) > 0)
b_tmp@type <- 3L
res <- tools::assertError(.Call(git2r:::git2r_branch_delete, b_tmp))
stopifnot(length(grep("'branch' must be a S4 class git_branch",
res[[1]]$message)) > 0)

## Delete branch
branch_delete(b)
stopifnot(identical(length(branches(repo)), 1L))
Expand Down

0 comments on commit 95b43ef

Please sign in to comment.