`vicspatial:::vicmap_cql_string(structure(list, class = "vicmap_promise"))` threw an error with unexpected message.
Expected match: "you need to use collect"
Actual message: "cannot set an attribute on a 'builtin'"

# Modifications Copyright 2020 Justin Cally
# Copyright 2019 Province of British Columbia
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
# Tests here have been implemented from bcdata: https://github.com/bcgov/bcdata/blob/master/tests/testthat/test-cql-string.R
geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))
test_that("vicmap_cql_string fails when an invalid arguments are given",{
test_that("vicmap_cql_string fails when used on an uncollected (promise) object", {
expect_is(CQL("SELECT * FROM foo;"), c("CQL", "SQL"))
test_that("All cql geom predicate functions work", {
CQL(paste0(f, "({geom_name}, POINT (1 1))"))
DWITHIN(the_geom, 1), #default units meters
CQL("DWITHIN({geom_name}, POINT (1 1), 1, meters)")
CQL("BEYOND({geom_name}, POINT (1 1), 1, feet)")
test_that("CQL functions fail correctly", {
expect_error(EQUALS(quakes), "x is not a valid sf object")
expect_error(BEYOND(the_geom, "five"), "'distance' must be numeric")
expect_error(DWITHIN(the_geom, 5, "fathoms"), "'arg' should be one of")
expect_error(DWITHIN(the_geom, "10", "meters"), "must be numeric")
expect_error(RELATE(the_geom, "********"), "pattern") # 8 characters
expect_error(RELATE(the_geom, "********5"), "pattern") # invalid character
expect_error(RELATE(the_geom, rep("TTTTTTTTT", 2)), "pattern") # > length 1
skip_if(geoserver_down, message = "vicspatial geoserver not currently available")
expect_equal(as.character(vmne$query$CQL_FILTER), "(NOT \"state\" = 'VIC')")