-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest-fledgling.R
115 lines (106 loc) · 2.67 KB
/
test-fledgling.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
test_that("read_news() works with usual format", {
news_lines <- c(
news_preamble(), "",
"# fledge v2.0.0", "",
"* blop", "",
"* lala", "",
"# fledge v1.0.0", "",
"* blip", "",
"* lili", ""
)
expect_snapshot_tibble(read_news(news_lines))
})
test_that("read_news() works with other formats", {
news_lines <- c(
"<!-- Hands off, please -->",
"",
"# Changes in v2.0.0", "",
"* blop", "",
"* lala", "",
"",
"# Changes in v1.0.0", "",
"* blip", "",
"* lili", ""
)
expect_snapshot_tibble(read_news(news_lines))
})
test_that("read_news() works with nicknames", {
news_lines <- c(
news_preamble(), "",
'# Changes in v2.0.0 "Vigorous Calisthenics"', "",
"* blop", "",
"* lala", "",
'# Changes in v1.0.0 "Pumpkin Helmet"', "",
"* blip", "",
"* lili", ""
)
expect_snapshot_tibble(read_news(news_lines))
})
test_that("read_news() works with h2", {
news_lines <- c(
news_preamble(), "",
'## Changes in v2.0.0 "Vigorous Calisthenics"', "",
"* blop", "",
"* lala", "",
'## Changes in v1.0.0 "Pumpkin Helmet"', "",
"* blip", "",
"* lili", ""
)
expect_snapshot_tibble(read_news(news_lines))
})
test_that("correct handling of no preamble", {
news_lines <- c(
"# fledge v2.0.0", "",
"* blop", ""
)
expect_equal(read_news(news_lines)[["preamble"]], news_preamble())
})
test_that("correct handling of old preamble", {
news_lines <- c(
"<!-- NEWS.md is maintained by https://cynkra.github.io/fledge, do not edit -->", "",
"# fledge v2.0.0", "",
"* blop", ""
)
expect_equal(read_news(news_lines)[["preamble"]], news_preamble())
})
test_that("correct handling of current preamble", {
news_lines <- c(
news_preamble(), "",
"# fledge v2.0.0", "",
"* blop", ""
)
expect_equal(read_news(news_lines)[["preamble"]], news_preamble())
})
test_that("correct handling of custom preamble", {
fancy <- "<!-- NEWS.md is maintained by a fancy package, do not edit -->"
news_lines <- c(
fancy, "",
"# fledge v2.0.0", "",
"* blop", ""
)
expect_equal(read_news(news_lines)[["preamble"]], fancy)
})
test_that("read_news() works with two-lines headers", {
news_lines <- c(
"fledge v2.0.0",
"=============", "",
"* blop", "",
"* lala", "",
"# fledge v1.0.0", "",
"* blip", "",
"* lili", ""
)
expect_snapshot_tibble(read_news(news_lines))
})
test_that("read_news() reports duplicated version names", {
news_lines <- c(
"fledge v2.0.0",
"=============", "",
"* blop", "",
"* lala", "",
"# fledge v2.0.0", "",
"* blip", "",
"* lili", ""
)
expect_snapshot(read_news(news_lines), error = TRUE)
})