Skip to content

Commit a6a4627

Browse files
committed
Updated git() unit tests (#5)
- more meaningful - previously didn't return anything to snapshot - now actually tests
1 parent 95a2a38 commit a6a4627

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

‎tests/testthat/_snaps/git.md‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
# silencing the git echo is possible via the `gitr.echo_cmd` global option
22

33
Code
4-
git("--version")
5-
Output
6-
Running git --version
7-
8-
---
9-
10-
Code
11-
git("--version")
12-
13-
---
14-
15-
Code
16-
git("--version", echo_cmd = FALSE)
4+
ver <- git("--version", echo_cmd = FALSE)$stdout
175
Output
186
Running git --version
197

‎tests/testthat/test-git.R‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ test_that("the basic functionality of `git()` works as expected", {
1010
test_that("silencing the git echo is possible via the `gitr.echo_cmd` global option", {
1111
# use `git("--version")` for testing b/c doesn't require a git repository
1212
# default; TRUE
13-
expect_snapshot(git("--version"))
13+
true <- system2("git", "--version", stdout = TRUE)
14+
expect_equal(git("--version", echo_cmd = FALSE)$stdout, true)
1415

1516
# over-ride default; FALSE
1617
withr::with_options(
1718
list(gitr.echo_cmd = FALSE),
18-
expect_snapshot(git("--version"))
19+
ver <- git("--version")$stdout
1920
)
21+
expect_equal(ver, true)
2022

2123
# over-ride passed param; TRUE
2224
withr::with_options(
2325
list(gitr.echo_cmd = TRUE),
24-
expect_snapshot(git("--version", echo_cmd = FALSE))
26+
expect_snapshot(ver <- git("--version", echo_cmd = FALSE)$stdout)
2527
)
28+
expect_equal(ver, true)
2629
})

0 commit comments

Comments
 (0)