forked from r-lib/usethis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-use-license.R
80 lines (72 loc) 路 2.55 KB
/
test-use-license.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
context("use_license")
test_that("find_name() errors when no name seems to be intentionally set", {
withr::with_options(
list(usethis.full_name = NULL, devtools.name = NULL),
expect_usethis_error(find_name(), ".*name.* argument is missing")
)
withr::with_options(
list(usethis.full_name = NULL, devtools.name = "Your name goes here"),
expect_usethis_error(find_name(), ".*name.* argument is missing")
)
})
test_that("find_name() picks up usethis.full_name, then devtools.name", {
withr::with_options(
list(
usethis.full_name = "usethis.full_name",
devtools.name = "devtools.name"
),
expect_identical(find_name(), "usethis.full_name")
)
withr::with_options(
list(
usethis.full_name = NULL,
devtools.name = "devtools.name"
),
expect_identical(find_name(), "devtools.name")
)
})
test_that("use_mit_license() works", {
pkg <- create_local_package()
use_mit_license(name = "MIT License")
expect_match(desc::desc_get("License", file = pkg), "MIT [+] file LICENSE")
expect_proj_file("LICENSE.md")
expect_proj_file("LICENSE")
expect_true(is_build_ignored("^LICENSE\\.md$"))
expect_true(is_build_ignored("^LICENSE$", invert = TRUE))
})
test_that("use_gpl3_license() works", {
pkg <- create_local_package()
use_gpl3_license(name = "GPL3 License")
expect_match(desc::desc_get("License", file = pkg), "GPL-3")
expect_proj_file("LICENSE.md")
expect_true(is_build_ignored("^LICENSE\\.md$"))
expect_true(is_build_ignored("^LICENSE$", invert = TRUE))
})
test_that("use_apl2_license() works", {
pkg <- create_local_package()
use_apl2_license(name = "Apache License")
expect_match(desc::desc_get("License", file = pkg), "Apache")
expect_proj_file("LICENSE.md")
expect_true(is_build_ignored("^LICENSE\\.md$"))
})
test_that("use_cc0_license() works", {
pkg <- create_local_package()
use_cc0_license(name = "CC0 License")
expect_match(desc::desc_get("License", file = pkg), "CC0")
expect_proj_file("LICENSE.md")
expect_true(is_build_ignored("^LICENSE\\.md$"))
})
test_that("use_ccby_license() works", {
pkg <- create_local_package()
use_ccby_license(name = "CCBY-4.0 License")
expect_match(desc::desc_get("License", file = pkg), "CC BY 4.0")
expect_proj_file("LICENSE.md")
expect_true(is_build_ignored("^LICENSE\\.md$"))
})
test_that("use_lgpl_license() works", {
pkg <- create_local_package()
use_lgpl_license(name = "LGPL (>= 2.1)")
expect_match(desc::desc_get("License", file = pkg), "LGPL")
expect_proj_file("LICENSE.md")
expect_true(is_build_ignored("^LICENSE\\.md$"))
})