Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Oct 5, 2023
1 parent 2d7aab2 commit 44b2fd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/testthat/_snaps/treat-argument.md
Original file line number Diff line number Diff line change
@@ -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.
}

15 changes: 15 additions & 0 deletions tests/testthat/test-treat-argument.R
Original file line number Diff line number Diff line change
@@ -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)
)
})

0 comments on commit 44b2fd4

Please sign in to comment.