Skip to content

Commit 8a6c882

Browse files
committed
skip lockfile validation tests on CRAN
1 parent 99339c7 commit 8a6c882

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/testthat/test-lockfile-validate.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
test_that("a known-good lockfile passes validation", {
3-
3+
4+
skip_on_cran()
45
skip_if_not_installed("jsonvalidate")
6+
57
lockfile <- '
68
{
79
"R": {
@@ -53,11 +55,13 @@ test_that("a known-good lockfile passes validation", {
5355
'
5456
expect_no_error(lockfile_validate(lockfile = lockfile))
5557
expect_true(lockfile_validate(lockfile = lockfile))
58+
5659
})
5760

5861

5962
test_that("a known-good lockfile with extra fields passes validation", {
6063

64+
skip_on_cran()
6165
skip_if_not_installed("jsonvalidate")
6266

6367
# Lockfile adds a R$Nickname field not present in the schema
@@ -113,10 +117,12 @@ test_that("a known-good lockfile with extra fields passes validation", {
113117
'
114118
expect_no_error(lockfile_validate(lockfile = lockfile))
115119
expect_true(lockfile_validate(lockfile = lockfile))
120+
116121
})
117122

118123
test_that("a custom schema file can be used for successful validation", {
119124

125+
skip_on_cran()
120126
skip_if_not_installed("jsonvalidate")
121127

122128
# Custom schema adds a required R$Nickname field present in the lockfile
@@ -166,10 +172,12 @@ test_that("a custom schema file can be used for successful validation", {
166172
'
167173
expect_no_error(lockfile_validate(lockfile = lockfile, schema = schema))
168174
expect_true(lockfile_validate(lockfile = lockfile, schema = schema))
175+
169176
})
170177

171178
test_that("a custom schema file can be used for failed validation", {
172179

180+
skip_on_cran()
173181
skip_if_not_installed("jsonvalidate")
174182

175183
# Custom schema adds a required R$Nickname field not present in the lockfile
@@ -218,10 +226,12 @@ test_that("a custom schema file can be used for failed validation", {
218226
'
219227

220228
expect_false(lockfile_validate(lockfile = lockfile, schema = schema))
229+
221230
})
222231

223232
test_that("an incorrect Packages$Hash field fails validation", {
224233

234+
skip_on_cran()
225235
skip_if_not_installed("jsonvalidate")
226236

227237
lockfile <- '
@@ -248,10 +258,12 @@ test_that("an incorrect Packages$Hash field fails validation", {
248258
'
249259

250260
expect_false(lockfile_validate(lockfile = lockfile))
261+
251262
})
252263

253264
test_that("invalid JSON fails validation", {
254265

266+
skip_on_cran()
255267
skip_if_not_installed("jsonvalidate")
256268

257269
# Packages uses [] which is not valid JSON
@@ -278,10 +290,12 @@ test_that("invalid JSON fails validation", {
278290
}
279291
'
280292
expect_error(lockfile_validate(lockfile = lockfile, error = TRUE))
293+
281294
})
282295

283296
test_that("strict mode catches unknown keyword in provided schema", {
284297

298+
skip_on_cran()
285299
skip_if_not_installed("jsonvalidate")
286300

287301
# Custom schema provides "Version" with "type": "UNKNOWN"
@@ -324,5 +338,7 @@ test_that("strict mode catches unknown keyword in provided schema", {
324338
}
325339
}
326340
'
341+
327342
expect_error(lockfile_validate(lockfile = lockfile, strict = TRUE))
343+
328344
})

0 commit comments

Comments
 (0)