|
| 1 | +test_that("can read NEWS.md in root directory", { |
| 2 | + skip_on_cran() |
| 3 | + |
| 4 | + pkg <- local_package_create() |
| 5 | + suppressMessages(usethis::with_project(pkg, use_news_md())) |
| 6 | + |
| 7 | + expect_no_error(show_news(pkg)) |
| 8 | +}) |
| 9 | + |
| 10 | +test_that("can read NEWS.Rd in inst directory", { |
| 11 | + skip_on_cran() |
| 12 | + |
| 13 | + pkg <- local_package_create() |
| 14 | + |
| 15 | + dir_create(pkg, "inst") |
| 16 | + write(r"[\name{NEWS} |
| 17 | +\title{News for Package 'test'} |
| 18 | +
|
| 19 | +\section{CHANGES IN test VERSION 0.0.1}{ |
| 20 | + \itemize{ |
| 21 | + \item First version |
| 22 | + } |
| 23 | +}]", path(pkg, "inst", "NEWS.Rd")) |
| 24 | + |
| 25 | + expect_no_error(show_news(pkg)) |
| 26 | +}) |
| 27 | + |
| 28 | +test_that("can read NEWS in inst directory", { |
| 29 | + skip_on_cran() |
| 30 | + |
| 31 | + pkg <- local_package_create() |
| 32 | + |
| 33 | + dir_create(pkg, "inst") |
| 34 | + write("v0.1-1 (2024-01-09)\n\n o first release", path(pkg, "inst", "NEWS")) |
| 35 | + |
| 36 | + expect_no_error(show_news(pkg)) |
| 37 | +}) |
| 38 | + |
| 39 | +test_that("fails when NEWS is missing", { |
| 40 | + skip_on_cran() |
| 41 | + |
| 42 | + pkg <- local_package_create() |
| 43 | + |
| 44 | + expect_error(show_news(pkg)) |
| 45 | +}) |
| 46 | + |
| 47 | +test_that("fails when NEWS is improperly formatted", { |
| 48 | + skip_on_cran() |
| 49 | + |
| 50 | + pkg <- local_package_create() |
| 51 | + suppressMessages(usethis::with_project(pkg, use_news_md())) |
| 52 | + |
| 53 | + dir_create(pkg, "inst") |
| 54 | + file_create(pkg, "inst", "NEWS.Rd") |
| 55 | + |
| 56 | + expect_error(show_news(pkg)) |
| 57 | +}) |
0 commit comments