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