-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-confirm_files.R
86 lines (47 loc) · 2.46 KB
/
test-confirm_files.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
t# ============================================
# Authors: MJ
# Maintainers: MJ
# Copyright: 2022, HRDAG, GPL v2 or later
# ============================================
right_dir <- system.file("extdata", "right", package = "verdata", "verdata-reclutamiento-R1.parquet")
wrong_dir <- system.file("extdata", "wrong", package = "verdata", "verdata-reclutamiento-R1.parquet")
csv_right <- system.file("extdata", "right", package = "verdata", "verdata-reclutamiento-R1.csv.zip")
testthat::test_that("Hashing file", {
testthat::expect_true(confirm_file(right_dir)$confirmed)
})
testthat::test_that("Hashing wrong file", {
testthat::expect_false(confirm_file(wrong_dir)$confirmed)
})
testthat::test_that("Hashing right csv file", {
testthat::expect_true(confirm_file(csv_right)$confirmed)
})
right_dir <- system.file("extdata", "right", package = "verdata")
wrong_dir <- system.file("extdata", "wrong", package = "verdata")
testthat::test_that("Hashing files", {
testthat::expect_true(all(confirm_files(right_dir, "reclutamiento", c(1, 2))$confirmed))
})
testthat::test_that("Hashing wrong files", {
testthat::expect_false(all(confirm_files(wrong_dir, "reclutamiento", c(1, 2))$confirmed))
})
testthat::test_that("Function should return an error if the violation type is incorrect", {
testthat::expect_error(confirm_files(right_dir, "RECLUTAMIENTO", c(1, 2)))
})
testthat::test_that("Expect message when number of replicates exceed available replicates", {
testthat::expect_error(confirm_files(right_dir, "reclutamiento", 90:110))
})
testthat::test_that("Expect message when first replicate is less than 1", {
testthat::expect_error(confirm_files(right_dir, "reclutamiento", 0:2))
})
testthat::test_that("Expect message when first replicate is less than 1 and last is more than 100", {
testthat::expect_error(confirm_files(right_dir, "reclutamiento", 0:101))
})
testthat::test_that("Function should return an error if replicate numbers are misspecified", {
testthat::expect_error(confirm_files(right_dir, "reclutamiento", c("1", 2)))
})
testthat::test_that("Function should return an error if replicate numbers are misspecified", {
testthat::expect_error(confirm_files(right_dir, "RECLUTAMIENTO", c(1, "dos")))
})
testthat::test_that("Function should return an error if one or more of the replicates is not in the directory, but within the plausible bounds", {
testthat::expect_error(confirm_files(right_dir, "reclutamiento", 1:10))
})
# --- Done