@@ -110,3 +110,52 @@ cli::test_that_cli("children are validated along with parents", {
110110 expect_equal(lnk $ enforce_https , c(FALSE , FALSE , TRUE , TRUE ))
111111})
112112
113+ cli :: test_that_cli(" missing children will not be read" , {
114+ # setup -------------------------------------------------------------------
115+ tmp <- withr :: local_tempdir()
116+ test_dir <- fs :: path(tmp , " sandpaper-fragment" )
117+ fs :: dir_copy(lesson_fragment(" sandpaper-fragment" ), test_dir )
118+ fs :: dir_copy(
119+ test_path(" examples" , " child-example" , " files" ),
120+ fs :: path(test_dir , " episodes" )
121+ )
122+ # create two files in the lesson with the same children -------------------
123+ parent_file <- fs :: path(test_dir , " episodes" , " intro.Rmd" )
124+ second_parent_file <- fs :: path(test_dir , " episodes" , " next.Rmd" )
125+ fs :: file_copy(
126+ test_path(" examples" , " child-example" , " parent.Rmd" ),
127+ parent_file ,
128+ overwrite = TRUE
129+ )
130+ fs :: file_copy(
131+ test_path(" examples" , " child-example" , " parent.Rmd" ),
132+ second_parent_file ,
133+ overwrite = TRUE
134+ )
135+ cat(" ```{r child=file.path(snippets, \" test.Rmd\" )}\n ```\n " ,
136+ file = parent_file ,
137+ append = TRUE
138+ )
139+ # set the order in the config --------------------------------------------
140+ cfg <- readLines(fs :: path(test_dir , " config.yaml" ))
141+ eplist <- which(endsWith(cfg , " intro.Rmd" ))
142+ cfg [eplist ] <- paste0(cfg [eplist ], " \n - next.Rmd" )
143+ writeLines(cfg , fs :: path(test_dir , " config.yaml" ))
144+ children_names <- fs :: path(
145+ test_dir , " episodes" , " files" ,
146+ c(" child.md" , " child-2.Rmd" , " child-3.md" )
147+ )
148+
149+ expect_message(lsn <- Lesson $ new(test_dir , jekyll = FALSE ),
150+ " could not process child document file.path(snippets, \" test.Rmd\" )" ,
151+ fixed = TRUE
152+ )
153+
154+ expect_snapshot(lnk <- lsn $ validate_links())
155+ expect_s3_class(lnk , " data.frame" )
156+ expect_paths <- c(" learners/setup.md" , " learners/setup.md" , " episodes/files/child.md" , " episodes/files/child-3.md" )
157+ expect_equal(lnk $ filepath , fs :: path(expect_paths ))
158+ expect_equal(lnk $ internal_file , c(TRUE , TRUE , FALSE , TRUE ))
159+ expect_equal(lnk $ enforce_https , c(FALSE , FALSE , TRUE , TRUE ))
160+ })
161+
0 commit comments