| 1 | // Code generated by gen_tests.py and process_polyglot.py. |
| 2 | // Do not edit this file directly. |
| 3 | // The template for this file is located at: |
| 4 | // ../template.go.tpl |
| 5 | package reql_tests |
| 6 | |
| 7 | import ( |
| 8 | "testing" |
| 9 | "time" |
| 10 | |
| 11 | "github.com/stretchr/testify/suite" |
| 12 | r "gopkg.in/rethinkdb/rethinkdb-go.v6" |
| 13 | "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" |
| 14 | ) |
| 15 | |
| 16 | // Test ReQL interface to geo indexes |
| 17 | func TestGeoIndexingSuite(t *testing.T) { |
| 18 | suite.Run(t, new(GeoIndexingSuite)) |
| 19 | } |
| 20 | |
| 21 | type GeoIndexingSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *GeoIndexingSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up GeoIndexingSuite") |
| 29 | // Use imports to prevent errors |
| 30 | _ = time.Time{} |
| 31 | _ = compare.AnythingIsFine |
| 32 | |
| 33 | session, err := r.Connect(r.ConnectOpts{ |
| 34 | Address: url, |
| 35 | }) |
| 36 | suite.Require().NoError(err, "Error returned when connecting to server") |
| 37 | suite.session = session |
| 38 | |
| 39 | r.DBDrop("db_geo_index").Exec(suite.session) |
| 40 | err = r.DBCreate("db_geo_index").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_geo_index").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | r.DB("db_geo_index").TableDrop("table_test_indexing").Exec(suite.session) |
| 46 | err = r.DB("db_geo_index").TableCreate("table_test_indexing").Exec(suite.session) |
| 47 | suite.Require().NoError(err) |
| 48 | err = r.DB("db_geo_index").Table("table_test_indexing").Wait().Exec(suite.session) |
| 49 | suite.Require().NoError(err) |
| 50 | } |
| 51 | |
| 52 | func (suite *GeoIndexingSuite) TearDownSuite() { |
| 53 | suite.T().Log("Tearing down GeoIndexingSuite") |
| 54 | |
| 55 | if suite.session != nil { |
| 56 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 57 | r.DB("db_geo_index").TableDrop("table_test_indexing").Exec(suite.session) |
| 58 | r.DBDrop("db_geo_index").Exec(suite.session) |
| 59 | |
| 60 | suite.session.Close() |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (suite *GeoIndexingSuite) TestCases() { |
| 65 | suite.T().Log("Running GeoIndexingSuite: Test ReQL interface to geo indexes") |
| 66 | |
| 67 | table_test_indexing := r.DB("db_geo_index").Table("table_test_indexing") |
| 68 | _ = table_test_indexing // Prevent any noused variable errors |
| 69 | |
| 70 | // geo/indexing.yaml line #4 |
| 71 | // rows = [{'id':0, 'g':r.point(10,10), 'm':[r.point(0,0),r.point(1,0),r.point(2,0)]},{'id':1, 'g':r.polygon([0,0], [0,1], [1,1], [1,0])},{'id':2, 'g':r.line([0.000002,-1], [-0.000001,1])}] |
| 72 | suite.T().Log("Possibly executing: var rows []interface{} = []interface{}{map[interface{}]interface{}{'id': 0, 'g': r.Point(10, 10), 'm': []interface{}{r.Point(0, 0), r.Point(1, 0), r.Point(2, 0)}, }, map[interface{}]interface{}{'id': 1, 'g': r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0}), }, map[interface{}]interface{}{'id': 2, 'g': r.Line([]interface{}{2e-06, -1}, []interface{}{-1e-06, 1}), }}") |
| 73 | |
| 74 | rows := []interface{}{map[interface{}]interface{}{"id": 0, "g": r.Point(10, 10), "m": []interface{}{r.Point(0, 0), r.Point(1, 0), r.Point(2, 0)}}, map[interface{}]interface{}{"id": 1, "g": r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0})}, map[interface{}]interface{}{"id": 2, "g": r.Line([]interface{}{2e-06, -1}, []interface{}{-1e-06, 1})}} |
| 75 | _ = rows // Prevent any noused variable errors |
| 76 | |
| 77 | { |
| 78 | // geo/indexing.yaml line #8 |
| 79 | /* ({'deleted':0,'inserted':3,'skipped':0,'errors':0,'replaced':0,'unchanged':0}) */ |
| 80 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "inserted": 3, "skipped": 0, "errors": 0, "replaced": 0, "unchanged": 0} |
| 81 | /* table_test_indexing.insert(rows) */ |
| 82 | |
| 83 | suite.T().Log("About to run line #8: table_test_indexing.Insert(rows)") |
| 84 | |
| 85 | runAndAssert(suite.Suite, expected_, table_test_indexing.Insert(rows), suite.session, r.RunOpts{ |
| 86 | GeometryFormat: "raw", |
| 87 | GroupFormat: "map", |
| 88 | }) |
| 89 | suite.T().Log("Finished running line #8") |
| 90 | } |
| 91 | |
| 92 | { |
| 93 | // geo/indexing.yaml line #12 |
| 94 | /* {'created':1} */ |
| 95 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 96 | /* table_test_indexing.index_create('g', geo=true) */ |
| 97 | |
| 98 | suite.T().Log("About to run line #12: table_test_indexing.IndexCreate('g').OptArgs(r.IndexCreateOpts{Geo: true, })") |
| 99 | |
| 100 | runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreate("g").OptArgs(r.IndexCreateOpts{Geo: true}), suite.session, r.RunOpts{ |
| 101 | GeometryFormat: "raw", |
| 102 | GroupFormat: "map", |
| 103 | }) |
| 104 | suite.T().Log("Finished running line #12") |
| 105 | } |
| 106 | |
| 107 | { |
| 108 | // geo/indexing.yaml line #16 |
| 109 | /* {'created':1} */ |
| 110 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 111 | /* table_test_indexing.index_create('m', geo=true, multi=true) */ |
| 112 | |
| 113 | suite.T().Log("About to run line #16: table_test_indexing.IndexCreate('m').OptArgs(r.IndexCreateOpts{Geo: true, Multi: true, })") |
| 114 | |
| 115 | runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreate("m").OptArgs(r.IndexCreateOpts{Geo: true, Multi: true}), suite.session, r.RunOpts{ |
| 116 | GeometryFormat: "raw", |
| 117 | GroupFormat: "map", |
| 118 | }) |
| 119 | suite.T().Log("Finished running line #16") |
| 120 | } |
| 121 | |
| 122 | { |
| 123 | // geo/indexing.yaml line #19 |
| 124 | /* {'created':1} */ |
| 125 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 126 | /* table_test_indexing.index_create('other') */ |
| 127 | |
| 128 | suite.T().Log("About to run line #19: table_test_indexing.IndexCreate('other')") |
| 129 | |
| 130 | runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreate("other"), suite.session, r.RunOpts{ |
| 131 | GeometryFormat: "raw", |
| 132 | GroupFormat: "map", |
| 133 | }) |
| 134 | suite.T().Log("Finished running line #19") |
| 135 | } |
| 136 | |
| 137 | { |
| 138 | // geo/indexing.yaml line #23 |
| 139 | /* {'created':1} */ |
| 140 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 141 | /* table_test_indexing.index_create('point_det', lambda x: r.point(x, x) ) */ |
| 142 | |
| 143 | suite.T().Log("About to run line #23: table_test_indexing.IndexCreateFunc('point_det', func(x r.Term) interface{} { return r.Point(x, x)})") |
| 144 | |
| 145 | runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreateFunc("point_det", func(x r.Term) interface{} { return r.Point(x, x) }), suite.session, r.RunOpts{ |
| 146 | GeometryFormat: "raw", |
| 147 | GroupFormat: "map", |
| 148 | }) |
| 149 | suite.T().Log("Finished running line #23") |
| 150 | } |
| 151 | |
| 152 | { |
| 153 | // geo/indexing.yaml line #27 |
| 154 | /* AnythingIsFine */ |
| 155 | var expected_ string = compare.AnythingIsFine |
| 156 | /* table_test_indexing.index_wait() */ |
| 157 | |
| 158 | suite.T().Log("About to run line #27: table_test_indexing.IndexWait()") |
| 159 | |
| 160 | runAndAssert(suite.Suite, expected_, table_test_indexing.IndexWait(), suite.session, r.RunOpts{ |
| 161 | GeometryFormat: "raw", |
| 162 | GroupFormat: "map", |
| 163 | }) |
| 164 | suite.T().Log("Finished running line #27") |
| 165 | } |
| 166 | |
| 167 | { |
| 168 | // geo/indexing.yaml line #32 |
| 169 | /* err('ReqlQueryLogicError', 'Could not prove function deterministic. Index functions must be deterministic.') */ |
| 170 | var expected_ Err = err("ReqlQueryLogicError", "Could not prove function deterministic. Index functions must be deterministic.") |
| 171 | /* table_test_indexing.index_create('point_det', lambda x: r.line(x, x) ) */ |
| 172 | |
| 173 | suite.T().Log("About to run line #32: table_test_indexing.IndexCreateFunc('point_det', func(x r.Term) interface{} { return r.Line(x, x)})") |
| 174 | |
| 175 | runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreateFunc("point_det", func(x r.Term) interface{} { return r.Line(x, x) }), suite.session, r.RunOpts{ |
| 176 | GeometryFormat: "raw", |
| 177 | GroupFormat: "map", |
| 178 | }) |
| 179 | suite.T().Log("Finished running line #32") |
| 180 | } |
| 181 | |
| 182 | { |
| 183 | // geo/indexing.yaml line #37 |
| 184 | /* err('ReqlQueryLogicError', 'Index `other` is not a geospatial index. get_intersecting can only be used with a geospatial index.', [0]) */ |
| 185 | var expected_ Err = err("ReqlQueryLogicError", "Index `other` is not a geospatial index. get_intersecting can only be used with a geospatial index.") |
| 186 | /* table_test_indexing.get_intersecting(r.point(0,0), index='other').count() */ |
| 187 | |
| 188 | suite.T().Log("About to run line #37: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'other', }).Count()") |
| 189 | |
| 190 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "other"}).Count(), suite.session, r.RunOpts{ |
| 191 | GeometryFormat: "raw", |
| 192 | GroupFormat: "map", |
| 193 | }) |
| 194 | suite.T().Log("Finished running line #37") |
| 195 | } |
| 196 | |
| 197 | { |
| 198 | // geo/indexing.yaml line #41 |
| 199 | /* err_regex('ReqlOpFailedError', 'Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]', [0]) */ |
| 200 | var expected_ Err = err_regex("ReqlOpFailedError", "Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") |
| 201 | /* table_test_indexing.get_intersecting(r.point(0,0), index='missing').count() */ |
| 202 | |
| 203 | suite.T().Log("About to run line #41: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'missing', }).Count()") |
| 204 | |
| 205 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "missing"}).Count(), suite.session, r.RunOpts{ |
| 206 | GeometryFormat: "raw", |
| 207 | GroupFormat: "map", |
| 208 | }) |
| 209 | suite.T().Log("Finished running line #41") |
| 210 | } |
| 211 | |
| 212 | { |
| 213 | // geo/indexing.yaml line #44 |
| 214 | /* err('ReqlQueryLogicError', 'get_intersecting requires an index argument.', [0]) */ |
| 215 | var expected_ Err = err("ReqlQueryLogicError", "get_intersecting requires an index argument.") |
| 216 | /* table_test_indexing.get_intersecting(r.point(0,0)).count() */ |
| 217 | |
| 218 | suite.T().Log("About to run line #44: table_test_indexing.GetIntersecting(r.Point(0, 0)).Count()") |
| 219 | |
| 220 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).Count(), suite.session, r.RunOpts{ |
| 221 | GeometryFormat: "raw", |
| 222 | GroupFormat: "map", |
| 223 | }) |
| 224 | suite.T().Log("Finished running line #44") |
| 225 | } |
| 226 | |
| 227 | { |
| 228 | // geo/indexing.yaml line #47 |
| 229 | /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ |
| 230 | var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") |
| 231 | /* table_test_indexing.get_all(0, index='g').count() */ |
| 232 | |
| 233 | suite.T().Log("About to run line #47: table_test_indexing.GetAll(0).OptArgs(r.GetAllOpts{Index: 'g', }).Count()") |
| 234 | |
| 235 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetAll(0).OptArgs(r.GetAllOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 236 | GeometryFormat: "raw", |
| 237 | GroupFormat: "map", |
| 238 | }) |
| 239 | suite.T().Log("Finished running line #47") |
| 240 | } |
| 241 | |
| 242 | { |
| 243 | // geo/indexing.yaml line #51 |
| 244 | /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ |
| 245 | var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") |
| 246 | /* table_test_indexing.between(0, 1, index='g').count() */ |
| 247 | |
| 248 | suite.T().Log("About to run line #51: table_test_indexing.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'g', }).Count()") |
| 249 | |
| 250 | runAndAssert(suite.Suite, expected_, table_test_indexing.Between(0, 1).OptArgs(r.BetweenOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 251 | GeometryFormat: "raw", |
| 252 | GroupFormat: "map", |
| 253 | }) |
| 254 | suite.T().Log("Finished running line #51") |
| 255 | } |
| 256 | |
| 257 | { |
| 258 | // geo/indexing.yaml line #55 |
| 259 | /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ |
| 260 | var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") |
| 261 | /* table_test_indexing.order_by(index='g').count() */ |
| 262 | |
| 263 | suite.T().Log("About to run line #55: table_test_indexing.OrderBy().OptArgs(r.OrderByOpts{Index: 'g', }).Count()") |
| 264 | |
| 265 | runAndAssert(suite.Suite, expected_, table_test_indexing.OrderBy().OptArgs(r.OrderByOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 266 | GeometryFormat: "raw", |
| 267 | GroupFormat: "map", |
| 268 | }) |
| 269 | suite.T().Log("Finished running line #55") |
| 270 | } |
| 271 | |
| 272 | { |
| 273 | // geo/indexing.yaml line #77 |
| 274 | /* err('ReqlQueryLogicError', 'get_intersecting cannot use the primary index.', [0]) */ |
| 275 | var expected_ Err = err("ReqlQueryLogicError", "get_intersecting cannot use the primary index.") |
| 276 | /* table_test_indexing.get_intersecting(r.point(0,0), index='id').count() */ |
| 277 | |
| 278 | suite.T().Log("About to run line #77: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'id', }).Count()") |
| 279 | |
| 280 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ |
| 281 | GeometryFormat: "raw", |
| 282 | GroupFormat: "map", |
| 283 | }) |
| 284 | suite.T().Log("Finished running line #77") |
| 285 | } |
| 286 | |
| 287 | { |
| 288 | // geo/indexing.yaml line #82 |
| 289 | /* 1 */ |
| 290 | var expected_ int = 1 |
| 291 | /* table_test_indexing.get_intersecting(r.point(0,0), index='g').count() */ |
| 292 | |
| 293 | suite.T().Log("About to run line #82: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") |
| 294 | |
| 295 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 296 | GeometryFormat: "raw", |
| 297 | GroupFormat: "map", |
| 298 | }) |
| 299 | suite.T().Log("Finished running line #82") |
| 300 | } |
| 301 | |
| 302 | { |
| 303 | // geo/indexing.yaml line #86 |
| 304 | /* 1 */ |
| 305 | var expected_ int = 1 |
| 306 | /* table_test_indexing.get_intersecting(r.point(10,10), index='g').count() */ |
| 307 | |
| 308 | suite.T().Log("About to run line #86: table_test_indexing.GetIntersecting(r.Point(10, 10)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") |
| 309 | |
| 310 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(10, 10)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 311 | GeometryFormat: "raw", |
| 312 | GroupFormat: "map", |
| 313 | }) |
| 314 | suite.T().Log("Finished running line #86") |
| 315 | } |
| 316 | |
| 317 | { |
| 318 | // geo/indexing.yaml line #90 |
| 319 | /* 1 */ |
| 320 | var expected_ int = 1 |
| 321 | /* table_test_indexing.get_intersecting(r.point(0.5,0.5), index='g').count() */ |
| 322 | |
| 323 | suite.T().Log("About to run line #90: table_test_indexing.GetIntersecting(r.Point(0.5, 0.5)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") |
| 324 | |
| 325 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0.5, 0.5)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 326 | GeometryFormat: "raw", |
| 327 | GroupFormat: "map", |
| 328 | }) |
| 329 | suite.T().Log("Finished running line #90") |
| 330 | } |
| 331 | |
| 332 | { |
| 333 | // geo/indexing.yaml line #94 |
| 334 | /* 0 */ |
| 335 | var expected_ int = 0 |
| 336 | /* table_test_indexing.get_intersecting(r.point(20,20), index='g').count() */ |
| 337 | |
| 338 | suite.T().Log("About to run line #94: table_test_indexing.GetIntersecting(r.Point(20, 20)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") |
| 339 | |
| 340 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(20, 20)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 341 | GeometryFormat: "raw", |
| 342 | GroupFormat: "map", |
| 343 | }) |
| 344 | suite.T().Log("Finished running line #94") |
| 345 | } |
| 346 | |
| 347 | { |
| 348 | // geo/indexing.yaml line #98 |
| 349 | /* 2 */ |
| 350 | var expected_ int = 2 |
| 351 | /* table_test_indexing.get_intersecting(r.polygon([0,0], [1,0], [1,1], [0,1]), index='g').count() */ |
| 352 | |
| 353 | suite.T().Log("About to run line #98: table_test_indexing.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1})).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") |
| 354 | |
| 355 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1})).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 356 | GeometryFormat: "raw", |
| 357 | GroupFormat: "map", |
| 358 | }) |
| 359 | suite.T().Log("Finished running line #98") |
| 360 | } |
| 361 | |
| 362 | { |
| 363 | // geo/indexing.yaml line #102 |
| 364 | /* 3 */ |
| 365 | var expected_ int = 3 |
| 366 | /* table_test_indexing.get_intersecting(r.line([0,0], [10,10]), index='g').count() */ |
| 367 | |
| 368 | suite.T().Log("About to run line #102: table_test_indexing.GetIntersecting(r.Line([]interface{}{0, 0}, []interface{}{10, 10})).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") |
| 369 | |
| 370 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Line([]interface{}{0, 0}, []interface{}{10, 10})).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ |
| 371 | GeometryFormat: "raw", |
| 372 | GroupFormat: "map", |
| 373 | }) |
| 374 | suite.T().Log("Finished running line #102") |
| 375 | } |
| 376 | |
| 377 | { |
| 378 | // geo/indexing.yaml line #106 |
| 379 | /* ("SELECTION<STREAM>") */ |
| 380 | var expected_ string = "SELECTION<STREAM>" |
| 381 | /* table_test_indexing.get_intersecting(r.point(0,0), index='g').type_of() */ |
| 382 | |
| 383 | suite.T().Log("About to run line #106: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).TypeOf()") |
| 384 | |
| 385 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).TypeOf(), suite.session, r.RunOpts{ |
| 386 | GeometryFormat: "raw", |
| 387 | GroupFormat: "map", |
| 388 | }) |
| 389 | suite.T().Log("Finished running line #106") |
| 390 | } |
| 391 | |
| 392 | { |
| 393 | // geo/indexing.yaml line #110 |
| 394 | /* ("SELECTION<STREAM>") */ |
| 395 | var expected_ string = "SELECTION<STREAM>" |
| 396 | /* table_test_indexing.get_intersecting(r.point(0,0), index='g').filter(true).type_of() */ |
| 397 | |
| 398 | suite.T().Log("About to run line #110: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Filter(true).TypeOf()") |
| 399 | |
| 400 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Filter(true).TypeOf(), suite.session, r.RunOpts{ |
| 401 | GeometryFormat: "raw", |
| 402 | GroupFormat: "map", |
| 403 | }) |
| 404 | suite.T().Log("Finished running line #110") |
| 405 | } |
| 406 | |
| 407 | { |
| 408 | // geo/indexing.yaml line #114 |
| 409 | /* ("STREAM") */ |
| 410 | var expected_ string = "STREAM" |
| 411 | /* table_test_indexing.get_intersecting(r.point(0,0), index='g').map(r.row).type_of() */ |
| 412 | |
| 413 | suite.T().Log("About to run line #114: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Map(r.Row).TypeOf()") |
| 414 | |
| 415 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Map(r.Row).TypeOf(), suite.session, r.RunOpts{ |
| 416 | GeometryFormat: "raw", |
| 417 | GroupFormat: "map", |
| 418 | }) |
| 419 | suite.T().Log("Finished running line #114") |
| 420 | } |
| 421 | |
| 422 | { |
| 423 | // geo/indexing.yaml line #119 |
| 424 | /* 1 */ |
| 425 | var expected_ int = 1 |
| 426 | /* table_test_indexing.get_intersecting(r.point(0,0), index='m').count() */ |
| 427 | |
| 428 | suite.T().Log("About to run line #119: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") |
| 429 | |
| 430 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ |
| 431 | GeometryFormat: "raw", |
| 432 | GroupFormat: "map", |
| 433 | }) |
| 434 | suite.T().Log("Finished running line #119") |
| 435 | } |
| 436 | |
| 437 | { |
| 438 | // geo/indexing.yaml line #123 |
| 439 | /* 1 */ |
| 440 | var expected_ int = 1 |
| 441 | /* table_test_indexing.get_intersecting(r.point(1,0), index='m').count() */ |
| 442 | |
| 443 | suite.T().Log("About to run line #123: table_test_indexing.GetIntersecting(r.Point(1, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") |
| 444 | |
| 445 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(1, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ |
| 446 | GeometryFormat: "raw", |
| 447 | GroupFormat: "map", |
| 448 | }) |
| 449 | suite.T().Log("Finished running line #123") |
| 450 | } |
| 451 | |
| 452 | { |
| 453 | // geo/indexing.yaml line #127 |
| 454 | /* 1 */ |
| 455 | var expected_ int = 1 |
| 456 | /* table_test_indexing.get_intersecting(r.point(2,0), index='m').count() */ |
| 457 | |
| 458 | suite.T().Log("About to run line #127: table_test_indexing.GetIntersecting(r.Point(2, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") |
| 459 | |
| 460 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(2, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ |
| 461 | GeometryFormat: "raw", |
| 462 | GroupFormat: "map", |
| 463 | }) |
| 464 | suite.T().Log("Finished running line #127") |
| 465 | } |
| 466 | |
| 467 | { |
| 468 | // geo/indexing.yaml line #131 |
| 469 | /* 0 */ |
| 470 | var expected_ int = 0 |
| 471 | /* table_test_indexing.get_intersecting(r.point(3,0), index='m').count() */ |
| 472 | |
| 473 | suite.T().Log("About to run line #131: table_test_indexing.GetIntersecting(r.Point(3, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") |
| 474 | |
| 475 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(3, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ |
| 476 | GeometryFormat: "raw", |
| 477 | GroupFormat: "map", |
| 478 | }) |
| 479 | suite.T().Log("Finished running line #131") |
| 480 | } |
| 481 | |
| 482 | { |
| 483 | // geo/indexing.yaml line #136 |
| 484 | /* 2 */ |
| 485 | var expected_ int = 2 |
| 486 | /* table_test_indexing.get_intersecting(r.polygon([0,0], [0,1], [1,1], [1,0]), index='m').count() */ |
| 487 | |
| 488 | suite.T().Log("About to run line #136: table_test_indexing.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0})).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") |
| 489 | |
| 490 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 1}, []interface{}{1, 0})).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ |
| 491 | GeometryFormat: "raw", |
| 492 | GroupFormat: "map", |
| 493 | }) |
| 494 | suite.T().Log("Finished running line #136") |
| 495 | } |
| 496 | |
| 497 | { |
| 498 | // geo/indexing.yaml line #142 |
| 499 | /* err('ReqlQueryLogicError', 'Index `other` is not a geospatial index. get_nearest can only be used with a geospatial index.', [0]) */ |
| 500 | var expected_ Err = err("ReqlQueryLogicError", "Index `other` is not a geospatial index. get_nearest can only be used with a geospatial index.") |
| 501 | /* table_test_indexing.get_nearest(r.point(0,0), index='other') */ |
| 502 | |
| 503 | suite.T().Log("About to run line #142: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'other', })") |
| 504 | |
| 505 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "other"}), suite.session, r.RunOpts{ |
| 506 | GeometryFormat: "raw", |
| 507 | GroupFormat: "map", |
| 508 | }) |
| 509 | suite.T().Log("Finished running line #142") |
| 510 | } |
| 511 | |
| 512 | { |
| 513 | // geo/indexing.yaml line #146 |
| 514 | /* err_regex('ReqlOpFailedError', 'Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]', [0]) */ |
| 515 | var expected_ Err = err_regex("ReqlOpFailedError", "Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") |
| 516 | /* table_test_indexing.get_nearest(r.point(0,0), index='missing') */ |
| 517 | |
| 518 | suite.T().Log("About to run line #146: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'missing', })") |
| 519 | |
| 520 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "missing"}), suite.session, r.RunOpts{ |
| 521 | GeometryFormat: "raw", |
| 522 | GroupFormat: "map", |
| 523 | }) |
| 524 | suite.T().Log("Finished running line #146") |
| 525 | } |
| 526 | |
| 527 | { |
| 528 | // geo/indexing.yaml line #149 |
| 529 | /* err('ReqlQueryLogicError', 'get_nearest requires an index argument.', [0]) */ |
| 530 | var expected_ Err = err("ReqlQueryLogicError", "get_nearest requires an index argument.") |
| 531 | /* table_test_indexing.get_nearest(r.point(0,0)) */ |
| 532 | |
| 533 | suite.T().Log("About to run line #149: table_test_indexing.GetNearest(r.Point(0, 0))") |
| 534 | |
| 535 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)), suite.session, r.RunOpts{ |
| 536 | GeometryFormat: "raw", |
| 537 | GroupFormat: "map", |
| 538 | }) |
| 539 | suite.T().Log("Finished running line #149") |
| 540 | } |
| 541 | |
| 542 | { |
| 543 | // geo/indexing.yaml line #170 |
| 544 | /* err('ReqlQueryLogicError', 'get_nearest cannot use the primary index.', [0]) */ |
| 545 | var expected_ Err = err("ReqlQueryLogicError", "get_nearest cannot use the primary index.") |
| 546 | /* table_test_indexing.get_nearest(r.point(0,0), index='id').count() */ |
| 547 | |
| 548 | suite.T().Log("About to run line #170: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'id', }).Count()") |
| 549 | |
| 550 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ |
| 551 | GeometryFormat: "raw", |
| 552 | GroupFormat: "map", |
| 553 | }) |
| 554 | suite.T().Log("Finished running line #170") |
| 555 | } |
| 556 | |
| 557 | { |
| 558 | // geo/indexing.yaml line #175 |
| 559 | /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}}]) */ |
| 560 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 0.055659745396754216, "doc": map[interface{}]interface{}{"id": 2}}} |
| 561 | /* table_test_indexing.get_nearest(r.point(0,0), index='g').pluck('dist', {'doc':'id'}) */ |
| 562 | |
| 563 | suite.T().Log("About to run line #175: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 564 | |
| 565 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 566 | GeometryFormat: "raw", |
| 567 | GroupFormat: "map", |
| 568 | }) |
| 569 | suite.T().Log("Finished running line #175") |
| 570 | } |
| 571 | |
| 572 | { |
| 573 | // geo/indexing.yaml line #179 |
| 574 | /* ([{'dist':0,'doc':{'id':2}},{'dist':0.11130264976984369,'doc':{'id':1}}]) */ |
| 575 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 0.11130264976984369, "doc": map[interface{}]interface{}{"id": 1}}} |
| 576 | /* table_test_indexing.get_nearest(r.point(-0.000001,1), index='g').pluck('dist', {'doc':'id'}) */ |
| 577 | |
| 578 | suite.T().Log("About to run line #179: table_test_indexing.GetNearest(r.Point(-1e-06, 1)).OptArgs(r.GetNearestOpts{Index: 'g', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 579 | |
| 580 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(-1e-06, 1)).OptArgs(r.GetNearestOpts{Index: "g"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 581 | GeometryFormat: "raw", |
| 582 | GroupFormat: "map", |
| 583 | }) |
| 584 | suite.T().Log("Finished running line #179") |
| 585 | } |
| 586 | |
| 587 | { |
| 588 | // geo/indexing.yaml line #183 |
| 589 | /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}},{'dist':1565109.0992178896,'doc':{'id':0}}]) */ |
| 590 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 0.055659745396754216, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 1565109.0992178896, "doc": map[interface{}]interface{}{"id": 0}}} |
| 591 | /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1565110).pluck('dist', {'doc':'id'}) */ |
| 592 | |
| 593 | suite.T().Log("About to run line #183: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1565110, }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 594 | |
| 595 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1565110}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 596 | GeometryFormat: "raw", |
| 597 | GroupFormat: "map", |
| 598 | }) |
| 599 | suite.T().Log("Finished running line #183") |
| 600 | } |
| 601 | |
| 602 | { |
| 603 | // geo/indexing.yaml line #187 |
| 604 | /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}}]) */ |
| 605 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 0.055659745396754216, "doc": map[interface{}]interface{}{"id": 2}}} |
| 606 | /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1565110, max_results=2).pluck('dist', {'doc':'id'}) */ |
| 607 | |
| 608 | suite.T().Log("About to run line #187: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1565110, MaxResults: 2, }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 609 | |
| 610 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1565110, MaxResults: 2}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 611 | GeometryFormat: "raw", |
| 612 | GroupFormat: "map", |
| 613 | }) |
| 614 | suite.T().Log("Finished running line #187") |
| 615 | } |
| 616 | |
| 617 | { |
| 618 | // geo/indexing.yaml line #191 |
| 619 | /* err('ReqlQueryLogicError', 'The distance has become too large for continuing the indexed nearest traversal. Consider specifying a smaller `max_dist` parameter. (Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 10968937.995244588703m, but must be smaller than 9985163.1855612862855m.)', [0]) */ |
| 620 | var expected_ Err = err("ReqlQueryLogicError", "The distance has become too large for continuing the indexed nearest traversal. Consider specifying a smaller `max_dist` parameter. (Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 10968937.995244588703m, but must be smaller than 9985163.1855612862855m.)") |
| 621 | /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=10000000).pluck('dist', {'doc':'id'}) */ |
| 622 | |
| 623 | suite.T().Log("About to run line #191: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 10000000, }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 624 | |
| 625 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 10000000}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 626 | GeometryFormat: "raw", |
| 627 | GroupFormat: "map", |
| 628 | }) |
| 629 | suite.T().Log("Finished running line #191") |
| 630 | } |
| 631 | |
| 632 | { |
| 633 | // geo/indexing.yaml line #195 |
| 634 | /* ([{'dist':0,'doc':{'id':1}},{'dist':0.00005565974539675422,'doc':{'id':2}},{'dist':1565.1090992178897,'doc':{'id':0}}]) */ |
| 635 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 5.565974539675422e-05, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 1565.1090992178897, "doc": map[interface{}]interface{}{"id": 0}}} |
| 636 | /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1566, unit='km').pluck('dist', {'doc':'id'}) */ |
| 637 | |
| 638 | suite.T().Log("About to run line #195: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1566, Unit: 'km', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 639 | |
| 640 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1566, Unit: "km"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 641 | GeometryFormat: "raw", |
| 642 | GroupFormat: "map", |
| 643 | }) |
| 644 | suite.T().Log("Finished running line #195") |
| 645 | } |
| 646 | |
| 647 | { |
| 648 | // geo/indexing.yaml line #198 |
| 649 | /* ([{'dist':0, 'doc':{'id':1}}, {'dist':8.726646259990191e-09, 'doc':{'id':2}}, {'dist':0.24619691677893205, 'doc':{'id':0}}]) */ |
| 650 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"dist": 0, "doc": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"dist": 8.726646259990191e-09, "doc": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"dist": 0.24619691677893205, "doc": map[interface{}]interface{}{"id": 0}}} |
| 651 | /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1, geo_system='unit_sphere').pluck('dist', {'doc':'id'}) */ |
| 652 | |
| 653 | suite.T().Log("About to run line #198: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', MaxDist: 1, GeoSystem: 'unit_sphere', }).Pluck('dist', map[interface{}]interface{}{'doc': 'id', })") |
| 654 | |
| 655 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g", MaxDist: 1, GeoSystem: "unit_sphere"}).Pluck("dist", map[interface{}]interface{}{"doc": "id"}), suite.session, r.RunOpts{ |
| 656 | GeometryFormat: "raw", |
| 657 | GroupFormat: "map", |
| 658 | }) |
| 659 | suite.T().Log("Finished running line #198") |
| 660 | } |
| 661 | |
| 662 | { |
| 663 | // geo/indexing.yaml line #202 |
| 664 | /* ("ARRAY") */ |
| 665 | var expected_ string = "ARRAY" |
| 666 | /* table_test_indexing.get_nearest(r.point(0,0), index='g').type_of() */ |
| 667 | |
| 668 | suite.T().Log("About to run line #202: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).TypeOf()") |
| 669 | |
| 670 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).TypeOf(), suite.session, r.RunOpts{ |
| 671 | GeometryFormat: "raw", |
| 672 | GroupFormat: "map", |
| 673 | }) |
| 674 | suite.T().Log("Finished running line #202") |
| 675 | } |
| 676 | |
| 677 | { |
| 678 | // geo/indexing.yaml line #206 |
| 679 | /* ("ARRAY") */ |
| 680 | var expected_ string = "ARRAY" |
| 681 | /* table_test_indexing.get_nearest(r.point(0,0), index='g').map(r.row).type_of() */ |
| 682 | |
| 683 | suite.T().Log("About to run line #206: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).Map(r.Row).TypeOf()") |
| 684 | |
| 685 | runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).Map(r.Row).TypeOf(), suite.session, r.RunOpts{ |
| 686 | GeometryFormat: "raw", |
| 687 | GroupFormat: "map", |
| 688 | }) |
| 689 | suite.T().Log("Finished running line #206") |
| 690 | } |
| 691 | } |