diff --git a/tests/testthat/_snaps/treat-argument.md b/tests/testthat/_snaps/treat-argument.md new file mode 100644 index 0000000..1099a6d --- /dev/null +++ b/tests/testthat/_snaps/treat-argument.md @@ -0,0 +1,26 @@ +# spq_treat_argument() errors for no equivalent + + Code + spq_treat_argument("something(bla)") + Condition + Error in `spq_translate_dsl()`: + ! x Can't find SPARQL equivalent for something(). + i If you think there should be one, open an issue in https://github.com/lvaudor/glitter. + +# COUNT() + + Code + spq_init() %>% spq_add("?film wdt:P31 wd:Q11424") %>% spq_mutate( + narrative_location = wdt::P840(film)) %>% spq_mutate(count = n()) %>% + spq_select(-film, -narrative_location) + Output + + SELECT (COUNT(*) AS ?count) + WHERE { + + ?film wdt:P31 wd:Q11424. + ?film wdt:P840 ?narrative_location. + + } + + diff --git a/tests/testthat/test-treat-argument.R b/tests/testthat/test-treat-argument.R new file mode 100644 index 0000000..7e3349b --- /dev/null +++ b/tests/testthat/test-treat-argument.R @@ -0,0 +1,15 @@ +test_that("spq_treat_argument() errors for no equivalent", { + expect_snapshot(error = TRUE, { + spq_treat_argument("something(bla)") + }) +}) + +test_that("COUNT()", { + expect_snapshot( + spq_init() %>% + spq_add("?film wdt:P31 wd:Q11424") %>% + spq_mutate(narrative_location = wdt::P840(film)) %>% + spq_mutate(count = n()) %>% + spq_select(- film, - narrative_location) + ) +})