context('Test that fill query works properly')
test_that('fill_query fills dates correctly', {
query = 'select * from dummytable where date between %start and %end;'
past13 <- strftime(
lubridate::floor_date(c(Sys.time() - months(13), Sys.time()), 'month'),
format = '%Y-%m-%d'
)
# auto fill to past 13 months
filled_query = fill_query(query = query, range = NA)
expect_equal(filled_query,
paste0('select * from dummytable where date between \'',
past13[1], '\' and \'', past13[2], '\';'))
# custom range
filled_query <- fill_query(query = query, range = onedayrange)
expect_equal(filled_query,
paste0('select * from dummytable where date between \'',
onedayrange[1], '\' and \'', onedayrange[2], '\';'))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.