context("Start() metadata_dims check") test_that("1. One data set", { repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" data <- Start(dat = list(list(name = 'system5_m1', path = repos)), var = 'tas', sdate = '20170101', ensemble = indices(1), time = indices(1), lat = indices(1:10), lon = indices(1:10), synonims = list(lat = c('lat', 'latitude'), lon = c('lon', 'longitude')), return_vars = list(time = 'sdate', longitude = 'dat', latitude = 'dat'), metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat' retrieve = T ) expect_equal( length(attr(data, 'Variables')), 2 ) expect_equal( names(attr(data, 'Variables')), c("common", "system5_m1") ) expect_equal( names(attr(data, 'Variables')$common), c('time', 'tas') ) expect_equal( names(attr(data, 'Variables')$system5_m1), c("longitude", "latitude") ) expect_equal( length(attr(data, 'Variables')$common$tas), 12 ) } test_that("2. Two data sets", { repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" data <- Start(dat = list(list(name = 'system4_m1', path = repos2), list(name = 'system5_m1', path = repos)), var = 'tas', sdate = '20170101', ensemble = indices(1), time = indices(1), lat = indices(1:10), lon = indices(1:10), synonims = list(lat = c('lat', 'latitude'), lon = c('lon', 'longitude')), return_vars = list(time = 'sdate', longitude = 'dat', latitude = 'dat'), metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat' retrieve = T ) expect_equal( length(attr(data, 'Variables')), 3 ) expect_equal( names(attr(data, 'Variables')), c("common", "system4_m1", "system5_m1") ) expect_equal( names(attr(data, 'Variables')$common), 'time' ) expect_equal( names(attr(data, 'Variables')$system4_m1), c("longitude", "latitude", "tas") ) expect_equal( names(attr(data, 'Variables')$system5_m1), c("longitude", "latitude", "tas") ) expect_equal( length(attr(data, 'Variables')$system5_m1$tas), 12 ) expect_equal( length(attr(data, 'Variables')$system4_m1$tas), 11 ) } test_that("3. Specify metadata_dims with another file dimension", { }