Skip to content

Commit

Permalink
Merge pull request #49 from katilingban/dev
Browse files Browse the repository at this point in the history
add tests for add_issue_template; fix #40
  • Loading branch information
ernestguevarra authored Dec 31, 2024
2 parents e99187c + 3286b48 commit 8eb1fca
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 9 deletions.
2 changes: 1 addition & 1 deletion R/add_issue_templates.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ add_issue_template <- function(issue = NULL,
)
)

dir.create("path")
dir.create(path, recursive = TRUE)

cli::cli_alert_success(
"{.file {path}} directory successfully created."
Expand Down
8 changes: 5 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ knitr::opts_chunk$set(
[![DOI](https://zenodo.org/badge/790010725.svg)](https://zenodo.org/badge/latestdoi/790010725)
<!-- badges: end -->

Tools and utilities for package development currently not available from usual development tools. These are mostly linked to personal preferences during the development process. They assist in making routine and repetitive tasks easily implementable.
Tools and utilities for package development currently not available from usual development tools. These are mostly linked to the author's personal preferences during the package development process. They assist in making routine and repetitive tasks easily implementable.

## What does pakete do?

Expand All @@ -41,7 +41,7 @@ Currently, `{pakete}` includes functions for:

5. adding [Zenodo](https://zenodo.org/) DOI badge; and,

6. adding GitHub Actions.
6. adding specific GitHub Actions.

## Installation

Expand All @@ -50,7 +50,9 @@ You can install `{pakete}` via the [Katilingban R Universe](https://katilingban.
```{r install-r-universe, eval = FALSE}
install.packages(
"pakete",
repos = c('https://katilingban.r-universe.dev', 'https://cloud.r-project.org')
repos = c(
'https://katilingban.r-universe.dev', 'https://cloud.r-project.org'
)
)
```

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ coverage](https://codecov.io/gh/katilingban/pakete/branch/main/graph/badge.svg)]
<!-- badges: end -->

Tools and utilities for package development currently not available from
usual development tools. These are mostly linked to personal preferences
during the development process. They assist in making routine and
repetitive tasks easily implementable.
usual development tools. These are mostly linked to the author’s
personal preferences during the package development process. They assist
in making routine and repetitive tasks easily implementable.

## What does pakete do?

Expand All @@ -38,7 +38,7 @@ Currently, `{pakete}` includes functions for:

5. adding [Zenodo](https://zenodo.org/) DOI badge; and,

6. adding GitHub Actions.
6. adding specific GitHub Actions.

## Installation

Expand All @@ -48,7 +48,9 @@ Universe](https://katilingban.r-universe.dev) as follows:
``` r
install.packages(
"pakete",
repos = c('https://katilingban.r-universe.dev', 'https://cloud.r-project.org')
repos = c(
'https://katilingban.r-universe.dev', 'https://cloud.r-project.org'
)
)
```

Expand Down
74 changes: 74 additions & 0 deletions tests/testthat/test-add_issue_templates.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Tests for add_issue_template functions ---------------------------------------

test_that("add_issue_template works as expected", {
dir.create(".github/ISSUE_TEMPLATE", recursive = TRUE)

expect_error(add_issue_template())

add_issue_template(issue = "initial-cran-release")

expect_snapshot_file(
path = ".github/ISSUE_TEMPLATE/initial-cran-release.md",
name = "initial-cran-release.md"
)

file.remove(".github/ISSUE_TEMPLATE/initial-cran-release.md")
unlink(".github", recursive = TRUE)
})


test_that("add_issue_template no directory works as expected", {
add_issue_template(issue = "initial-cran-release")

expect_snapshot_file(
path = ".github/ISSUE_TEMPLATE/initial-cran-release.md",
name = "initial-cran-release.md"
)

file.remove(".github/ISSUE_TEMPLATE/initial-cran-release.md")
unlink(".github", recursive = TRUE)
})


test_that("add_issue_template overwrite = TRUE works as expected", {
dir.create(".github/ISSUE_TEMPLATE", recursive = TRUE)

file.copy(
from = system.file(
"templates", "initial-cran-release.md", package = "pakete"
),
to = ".github/ISSUE_TEMPLATE"
)

add_issue_template(issue = "initial-cran-release", overwrite = TRUE)

expect_snapshot_file(
path = ".github/ISSUE_TEMPLATE/initial-cran-release.md",
name = "initial-cran-release.md"
)

file.remove(".github/ISSUE_TEMPLATE/initial-cran-release.md")
unlink(".github", recursive = TRUE)
})


test_that("add_issue_template overwrite = FALSE works as expected", {
dir.create(".github/ISSUE_TEMPLATE", recursive = TRUE)

file.copy(
from = system.file(
"templates", "initial-cran-release.md", package = "pakete"
),
to = ".github/ISSUE_TEMPLATE"
)

add_issue_template(issue = "initial-cran-release", overwrite = FALSE)

expect_snapshot_file(
path = ".github/ISSUE_TEMPLATE/initial-cran-release.md",
name = "initial-cran-release.md"
)

file.remove(".github/ISSUE_TEMPLATE/initial-cran-release.md")
unlink(".github", recursive = TRUE)
})

0 comments on commit 8eb1fca

Please sign in to comment.