Skip to content

Commit 48e2542

Browse files
committed
Added unit tests for "tagging" utilities
- fairly bare bones - closes #5
1 parent 237a6e0 commit 48e2542

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎tests/testthat/test-git-tag.R‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
# Setup ----
3+
skip_if_not(is_git())
4+
withr::local_options(list(gitr_echo_cmd = FALSE))
5+
tagname <- "gitr-unit-tag"
6+
withr::defer(git("tag", "--delete", tagname))
7+
8+
9+
# Testing ----
10+
test_that("`gitr_recent_tag()` gets the most recent tag", {
11+
# create a new tag
12+
git("tag", "-a", tagname, "-m",
13+
encodeString("Unit test tag v0.0.9000", quote = "'"))
14+
expect_equal(git_recent_tag(), tagname)
15+
})
16+
17+
test_that("`gitr_tag_info()` unit tests (minimal)", {
18+
tag_df <- git_tag_info()
19+
expect_s3_class(tag_df, "data.frame")
20+
expect_named(tag_df, c("tag", "tag_sha", "target_sha", "message",
21+
"author", "email", "user", "tagdate",
22+
"size", "path"))
23+
expect_true(nrow(tag_df) >= 2L)
24+
recent_tag <- tag_df[tagname, ]
25+
expect_equal(recent_tag$tag, tagname)
26+
expect_equal(recent_tag$message, "Unit test tag v0.0.9000")
27+
})

0 commit comments

Comments
 (0)