pax_global_header00006660000000000000000000000064136346442250014523gustar00rootroot0000000000000052 comment=fcfe1f12e1c9fb834ac0e68e7771dbfc0e773e4f rethinkdb-go-6.2.1/000077500000000000000000000000001363464422500141065ustar00rootroot00000000000000rethinkdb-go-6.2.1/.gitignore000066400000000000000000000004521363464422500160770ustar00rootroot00000000000000# Compiled Object files, Static and Dynamic libs (Shared Objects) *.o *.a *.so #vim *.swp *.swo # Folders _obj _test # Architecture specific extensions/prefixes *.[568vq] [568vq].out *.cgo1.go *.cgo2.c _cgo_defun.c _cgo_gotypes.go _cgo_export.* _testmain.go *.exe .wercker cover.html .idea/ rethinkdb-go-6.2.1/.travis.yml000066400000000000000000000015531363464422500162230ustar00rootroot00000000000000language: go go: - 1.12.x - 1.13.x - 1.14.x go_import_path: gopkg.in/rethinkdb/rethinkdb-go.v6 install: go get -t ./... before_script: - source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list - wget -qO- http://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add - - sudo apt-get update - sudo apt-get install rethinkdb - rethinkdb > /dev/null 2>&1 & - rethinkdb --port-offset 1 --directory rethinkdb_data1 > /dev/null 2>&1 & - rethinkdb --port-offset 2 --directory rethinkdb_data2 --join localhost:29016 > /dev/null 2>&1 & - rethinkdb --port-offset 3 --directory rethinkdb_data3 --join localhost:29016 > /dev/null 2>&1 & script: - go test -race . - go test -tags='cluster' -short -race -v ./... - GOMODULE111=off go test . rethinkdb-go-6.2.1/CHANGELOG.md000066400000000000000000000674761363464422500157430ustar00rootroot00000000000000# Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## v6.2.1 - 2020-03-19 - Revert backoff v4 for gopath compatibility ## v6.2.0 - 2020-03-18 - Backoff v4 - Reworked cluster discovery - Fix rare connection goroutine leak ## v6.1.0 - 2020-03-09 - Reworked and tested new connection pools with multiple queries per connection - Socket Read- and WriteTimeout replaced with context timeout - Mock assert fix - Connection pool fixed initial size - Changes added offsets ## v6.0.0 - 2019-12-22 - 2.4 RethinkDB support - Added JSON tags to ConnectOpts to make it serializable - Blocking mocks for responses - Fix Connect documentation - Added Type to ChangeResponse - Added bitwise operations support - Added write hooks support ## v5.0.1 - 2018-10-18 - Fix noreply queries memory leak due unnecessary for responses ## v5.0.0 - 2018-09-12 - Moved to rethinkdb organization - Renamed to rethinkdb-go repo - Renamed to rethinkdb package ## v4.1.0 - 2018-08-29 ### Fixed - Rare `Connection` leaks if socket errors occurred - Updated `ql2.proto` file from rethinkdb repo ### Added - Support for independent custom type marshalers ## v4.0.0 - 2017-12-14 ### Fixed - `Connection` work with sockets, now only a single goroutine reads from socket. - Optimized threadsafe operations in `Connection` with channels and atomics instead of mutex. - All tests with real db moved to integration folder ### Added - Added support for tracing with `opentracing-go` - Added a brand-new unit tests for `Connection` ## v3.0.5 - 2017-09-28 - Fixed typo at http opts ## v3.0.4 - 2017-09-04 - Fixed default context timeout if one of config's timeout os omitted ## v3.0.3 - 2017-09-03 - Added support to cancellation queries and timeouts with `context.Context` passed through `RunOpts` - Fixed import path for `sirupsen/logrus` due to repo was renamed ## v3.0.2 - 2017-04-16 ### Changed - Updated Go versions used by CI ### Fixed - Fixed performance issue caused by lock contention in `IsConnected` (thanks to @ekle) ## v3.0.1 - 2016-01-30 ### Fixed - Fixed import paths - Updated Go version used by Travis ## v3.0.0 - 2016-12-06 Unfortunately this will likely be the last release I plan to work on. This is due to the following reasons: - Over the last few years while I have spent a lot of time maintaining this driver I have not used it very much for my own personal projects. - My job has been keeping me very busy lately and I don't have as much time to work on this project as I used to. - The company behind RethinkDB has shut down and while I am sure the community will keep the database going it seems like a good time for me to step away from the project. - The driver itself is in a relatively good condition and many companies are using the existing version in production. I hope you understand my decision to step back from the project, if you have any questions or would be interested in take over some of the maintenance of the project please let me know. To make this process easier I have also decided to move the repository to the RethinkDB-go organisation. All existing imports _should_ still work. Thanks to everybody who got involved with this project over the last ~4 years and helped out, I have truly enjoyed the time I have spent building this library and I hope both RethinkDB and this driver manage to keep going. ### Changed - Moved project to `gorethink` organisation - Fixed behaviour when unmarshaling nil slices ### Fixed - Fix possible deadlock when calling `Session.Reconnect` - Fixed another bug with panic/infinite loop when closing cursor during reads - Fixed goroutine leak when calling `Session.Close` ## v2.2.2 - 2016-09-25 ### Changed - The `gorethink` struct tag is now always checked even after calling `SetTags` ### Fixed - Fixed infinite loop in cursor when closed during read ## v2.2.1 - 2016-09-18 ### Added - Added `State` and `Error` to `ChangeResponse` ### Fixed - Fixed panic caused by cursor trying to read outstanding responses while closed - Fixed panic when using mock session ## v2.2.0 - 2016-08-16 ### Added - Added support for optional arguments to `r.JS()` - Added `NonVotingReplicaTags` optional argument to `TableCreateOpts` - Added root term `TypeOf`, previously only the method term was supported - Added root version of `Group` terms (`Group`, `GroupByIndex`, `MultiGroup`, `MultiGroupByIndex`) - Added root version of `Distinct` - Added root version of `Contains` - Added root version of `Count` - Added root version of `Sum` - Added root version of `Avg` - Added root version of `Min` - Added root version of `MinIndex` - Added root version of `Max` - Added root version of `MaxIndex` - Added `ReadMode` to `RunOpts` - Added the `Interface` function to the `Cursor` which returns a queries result set as an `interface{}` - Added `GroupOpts` type - Added `GetAllOpts` type - Added `MinOpts`/`MaxOpts` types - Added `OptArgs` method to `Term` which allows optional arguments to be specified in an alternative way, for example: ```go r.DB("examples").Table("heroes").GetAll("man_of_steel").OptArgs(r.GetAllOpts{ Index: "code_name", }) ``` - Added ability to create compound keys from structs, for example: ``` type User struct { Company string `rethinkdb:"id[0]"` Name string `rethinkdb:"id[1]"` Age int `rethinkdb:"age"` } // Creates {"id": [COMPANY, NAME], "age": AGE} ``` - Added `Merge` function to `encoding` package that decodes data into a value without zeroing it first. - Added `MockAnything` functions to allow mocking of only part of a query (Thanks to @pzduniak) ### Changed - Renamed `PrimaryTag` to `PrimaryReplicaTag` in `ReconfigureOpts` - Renamed `NotAtomic` to `NonAtomic` in `ReplaceOpts` and `UpdateOpts` - Changed behaviour of function callbacks to allow arguments to be either of type `r.Term` or `interface {}` instead of only `r.Term` - Changed logging to be disabled by default, to enable logs change the output writer of the logger. For example: `r.Log.Out = os.Stderr` ### Fixed - Fixed `All` not working correctly when the cursor is created by `Mock` - Fixed `Mock` not matching queries containing functions - Fixed byte arrays not being correctly converted to the BINARY pseudo-type ## v2.1.3 - 2016-08-01 ### Changed - Changed behaviour of function callbacks to allow arguments to be either of type `r.Term` or `interface {}` instead of only `r.Term` ### Fixed - Fixed incorrectly named `Replicas` field in `TableCreateOpts` - Fixed broken optional argument `FinalEmit` in `FoldOpts` - Fixed bug causing some queries using `r.Row` to fail with the error `Cannot use r.row in nested queries.` - Fixed typos in `ConnectOpt` field (and related functions) `InitialCap`. ## v2.1.2 - 2016-07-22 ### Added - Added the `InitialCap` field to `ConnectOpts` to replace `MaxIdle` as the name no longer made sense. ### Changed - Improved documentation of ConnectOpts - Default value for `KeepAlivePeriod` changed from `0` to `30s` ### Deprecated - Deprecated the field `MaxIdle` in `ConnectOpts`, it has now been replaced by `InitialCap` which has the same behaviour as before. Setting both fields will still work until the field is removed in a future version. ### Fixed - Fixed issue causing changefeeds to hang if no data was received ## v2.1.1 - 2016-07-12 - Added `session.Database()` which returns the current default database ### Changed - Added more documentation ### Fixed - Fixed `Random()` not being implemented correctly and added tests (Thanks to @bakape for the PR) ## v2.1.0 - 2016-06-26 ### Added - Added ability to mock queries based on the library github.com/stretchr/testify + Added the `QueryExecutor` interface and changed query runner methods (`Run`/`Exec`) to accept this type instead of `*Session`, `Session` will still be accepted as it implements the `QueryExecutor` interface. + Added the `NewMock` function to create a mock query executor + Queries can be mocked using `On` and `Return`, `Mock` also contains functions for asserting that the required mocked queries were executed. + For more information about how to mock queries see the readme and tests in `mock_test.go`. ## Changed - Exported the `Build()` function on `Query` and `Term`. - Updated import of `github.com/cenkalti/backoff` to `github.com/cenk/backoff` ## v2.0.4 - 2016-05-22 ### Changed - Changed `Connect` to return the reason for connections failing (instead of just "no connections were made when creating the session") - Changed how queries are retried internally, previously when a query failed due to an issue with the connection a new connection was picked from the connection pool and the query was retried, now the driver will attempt to retry the query with a new host (and connection). This should make applications connecting to a multi-node cluster more reliable. ### Fixed - Fixed queries not being retried when using `Query()`, queries are now retried if the request failed due to a bad connection. - Fixed `Cursor` methods panicking if using a nil cursor, please note that you should still always check if your queries return an error. ## v2.0.3 - 2016-05-12 ### Added - Added constants for system database and table names. ### Changed - Re-enabled keep alive by default. ## v2.0.2 - 2016-04-18 ### Fixed - Fixed issue which prevented anonymous `time.Time` values from being encoded when used in a struct. - Fixed panic when attempting to run a query with a nil session ## v2.0.1 - 2016-04-14 ### Added - Added `UnionWithOpts` term which allows `Union` to be called with optional arguments (such as `Interleave`) - Added `IncludeOffsets` and `IncludeTypes` optional arguments to `ChangesOpts` - Added `Conflict` optional argument to `InsertOpts` ### Fixed - Fixed error when connecting to database as non-admin user, please note that `DiscoverHosts` will not work with user authentication at this time due to the fact that RethinkDB restricts access to the required system tables. ## v2.0.0 - 2016-04-13 ### Changed - RethinkDB-go now uses the v1.0 RethinkDB protocol which supports RethinkDB v2.3 and above. If you are using RethinkDB 2.2 or older please set `HandshakeVersion` when creating a session. For example: ```go r.Connect( ... HandshakeVersion: r.HandshakeV0_4, ... ) ``` ### Added - Added support for username/password authentication. To login pass your username and password when creating a session using the `Username` and `Password` fields in the `ConnectOpts`. - Added the `Grant` term - Added the `Ordered` optional argument to `EqJoin` - Added the `Fold` term and examples - Added the `ReadOne` and `ReadAll` helper functions for quickly executing a query and scanning the result into a variable. For examples see the godocs. - Added the `Peek` and `Skip` functions to the `Cursor`. - Added support for referential arrays in structs - Added the `Durability` argument to `RunOpts`/`ExecOpts` ### Deprecated - Deprecated the root `Wait` term, `r.Table(...).Wait()` should now be used instead. - Deprecated session authentication using `AuthKey` ### Fixed - Fixed issue with `ReconfigureOpts` field `PrimaryTag` ## v1.4.1 - 2016-04-02 ### Fixed - Fixed panic when closing a connection at the same time as using a changefeed. - Update imports to correctly use gopkg.in - Fixed race condition when using anonymous functions - Fixed IsConflictErr and IsTypeErr panicking when passed nil errors - RunWrite no longer misformats errors with formatting directives in them ## v1.4.0 - 2016-03-15 ### Added - Added the ability to reference subdocuments when inserting new documents, for more information see the documentation in the readme. - Added the `SetTags` function which allows RethinkDB-go to override which tags are used when working with structs. For example to support the `json` add the following call `SetTags("gorethink", "json")`. - Added helper functions for checking the error type of a write query, this is useful when calling `RunWrite`. + Added `IsConflictErr` which returns true when RethinkDB returns a duplicate key error. + Added `IsTypeErr` which returns true when RethinkDB returns an unexpected type error. - Added the `RawQuery` term which can be used to execute a raw JSON query, for more information about this query see the godoc. - Added the `NextResponse` function to `Cursor` which will return the next raw JSON response in the result set. - Added ability to set the keep alive period by setting the `KeepAlivePeriod` field in `ConnectOpts`. ### Fixed - Fixed an issue that could prevent bad connections from being removed from the connection pool. - Fixed certain connection errors not being returned as `RqlConnectionError` when calling `Run`, `Exec` or `RunWrite`. - Fixed potential dead lock in connection code caused when building the query. ## v1.3.2 - 2015-02-01 ### Fixed - Fixed race condition in cursor which caused issues when closing a cursor that is in the process of fetching data. ## v1.3.1 - 2015-01-22 ### Added - Added more documentation and examples for `GetAll`. ### Fixed - Fixed `RunWrite` not defering its call to `Cursor.Close()`. This could cause issues if an error occurred when decoding the result. - Fixed panic when calling `Error()` on a RethinkDB-go `rqlError`. ## v1.3.0 - 2016-01-11 ### Added - Added new error types, the following error types can now be returned: `RQLClientError`, `RQLCompileError`, `RQLDriverCompileError`, `RQLServerCompileError`, `RQLAuthError`, `RQLRuntimeError`, `RQLQueryLogicError`, `RQLNonExistenceError`, `RQLResourceLimitError`, `RQLUserError`, `RQLInternalError`, `RQLTimeoutError`, `RQLAvailabilityError`, `RQLOpFailedError`, `RQLOpIndeterminateError`, `RQLDriverError`, `RQLConnectionError`. Please note that some other errors can be returned. - Added `IsConnected` function to `Session`. ### Fixed - Fixed panic when scanning through results caused by incorrect queue implementation. ## v1.2.0 - 2015-11-19 ### Added - Added `UUID` term - Added `Values` term - Added `IncludeInitial` and `ChangefeedQueueSize` to `ChangesOpts` - Added `UseJSONNumber` to `ConnectOpts` which changes the way the JSON unmarshal works when deserializing JSON with interface{}, it's preferred to use json.Number instead float64 as it preserves the original precision. - Added `HostDecayDuration` to `ConnectOpts` to configure how hosts are selected. For more information see the godoc. ### Changed - Timezones from `time.Time` are now stored in the database, before all times were stored as UTC. To convert a go `time.Time` back to UTC you can call `t.In(time.UTC)`. - Improved host selection to use `hailocab/go-hostpool` to select nodes based on recent responses and timings. - Changed connection pool to use `fatih/pool` instead of a custom connection pool, this has caused some internal API changes and the behaviour of `MaxIdle` and `MaxOpen` has slightly changed. This change was made mostly to make driver maintenance easier. + `MaxIdle` now configures the initial size of the pool, the name of this field will likely change in the future. + Not setting `MaxOpen` no longer creates an unbounded connection pool per host but instead creates a pool with a maximum capacity of 2 per host. ### Deprecated - Deprecated the option `NodeRefreshInterval` in `ConnectOpts` - Deprecated `SetMaxIdleConns` and `SetMaxOpenConns`, these options should now only be set when creating the session. ### Fixed - Fixed some type aliases not being correctly encoded when using `Expr`. ## v1.1.4 - 2015-10-02 ### Added - Added root table terms (`r.TableCreate`, `r.TableList` and `r.TableDrop`) ### Removed - Removed `ReadMode` option from `RunOpts` and `ExecOpts` (incorrectly added in v1.1.0) ### Fixed - Fixed `Decode` no longer setting pointer to nil on document not found - Fixed panic when `fetchMore` returns an error - Fixed deadlock when closing changefeed - Fixed stop query incorrectly waiting for response - Fixed pointers not to be properly decoded ## v1.1.3 - 2015-09-06 ### Fixed - Fixed pointers not to be properly decoded - Fixed queries always timing out when Timeout ConnectOpt is set. ## v1.1.2 - 2015-08-28 ### Fixed - Fixed issue when encoding some maps ## v1.1.1 - 2015-08-21 ### Fixed - Corrected protobuf import - Fixed documentation - Fixed issues with time pseudotype conversion that caused issues with milliseconds ## v1.1.0 - 2015-08-19 ### Added - Replaced `UseOutdated` with `ReadMode` - Added `EmergencyRepair` and `NonVotingReplicaTags` to `ReconfigureOpts` - Added `Union` as a root term - Added `Branch` as a root term - Added `ReadTimeout` and `WriteTimeout` to `RunOpts` and `ExecOpts` - Exported `github.com/Sirupsen/logrus.Logger` as `Log` - Added support for encoding maps with non-string keys - Added 'Round', 'Ceil' and 'Floor' terms - Added race detector to CI ### Changed - Changed `Timeout` connect argument to only configure the connection timeout. - Replaced `Db` with `DB` in `RunOpts` and `ExecOpts` (`Db` still works for now) - Made `Cursor` and `Session` safe for concurrent use - Replaced `ErrClusterClosed` with `ErrConnectionClosed` ## Deprecated - Deprecated `UseOutdated` optional argument - Deprecated `Db` in `RunOpt` ### Fixed - Fixed race condition in node pool - Fixed node refresh issue with RethinkDB 2.1 due to an API change - Fixed encoding errors not being returned when running queries ## v1.0.0 - 2015-06-27 1.0.0 is finally here, This is the first stable production ready release of RethinkDB-go! ![RethinkDB-go Logo](https://raw.github.com/wiki/gorethink/gorethink/gopher-and-thinker.png "Golang Gopher and RethinkDB Thinker") In an attempt to make this library more "idiomatic" some functions have been renamed, for the full list of changes and bug fixes see below. ### Added - Added more documentation. - Added `Shards`, `Replicas` and `PrimaryReplicaTag` optional arguments in `TableCreateOpts`. - Added `MultiGroup` and `MultiGroupByIndex` which are equivalent to the running `group` with the `multi` optional argument set to true. ### Changed - Renamed `Db` to `DB`. - Renamed `DbCreate` to `DBCreate`. - Renamed `DbDrop` to `DBDrop`. - Renamed `RqlConnectionError` to `RQLConnectionError`. - Renamed `RqlDriverError` to `RQLDriverError`. - Renamed `RqlClientError` to `RQLClientError`. - Renamed `RqlRuntimeError` to `RQLRuntimeError`. - Renamed `RqlCompileError` to `RQLCompileError`. - Renamed `Js` to `JS`. - Renamed `Json` to `JSON`. - Renamed `Http` to `HTTP`. - Renamed `GeoJson` to `GeoJSON`. - Renamed `ToGeoJson` to `ToGeoJSON`. - Renamed `WriteChanges` to `ChangeResponse`, this is now a general type and can be used when dealing with changefeeds. - Removed depth limit when encoding values using `Expr` ### Fixed - Fixed issue causing errors when closing a changefeed cursor (#191) - Fixed issue causing nodes to remain unhealthy when host discovery is disabled (#195) - Fixed issue causing driver to fail when connecting to DB which did not have its canonical address set correctly (#200). - Fixed ongoing queries not being properly stopped when closing the cursor. ### Removed - Removed `CacheSize` and `DataCenter` optional arguments in `TableCreateOpts`. - Removed `CacheSize` optional argument from `InsertOpts` ## v0.7.2 - 2015-05-05 ### Added - Added support for connecting to a server using TLS (#179) ### Fixed - Fixed issue causing driver to fail to connect to servers with the HTTP admin interface disabled (#181) - Fixed errors in documentation (#182, #184) - Fixed RunWrite not closing the cursor (#185) ## v0.7.1 - 2015-04-19 ### Changed - Improved logging of connection errors. ### Fixed - Fixed bug causing empty times to be inserted into the DB even when the omitempty tag was set. - Fixed node status refresh loop leaking goroutines. ## v0.7.0 - 2015-03-30 This release includes support for RethinkDB 2.0 and connecting to clusters. To connect to a cluster you should use the new `Addresses` field in `ConnectOpts`, for example: ```go session, err := r.Connect(r.ConnectOpts{ Addresses: []string{"localhost:28015", "localhost:28016"}, }) if err != nil { log.Fatalln(err.Error()) } ``` Also added was the ability to read from a cursor using a channel, this is especially useful when using changefeeds. For more information see this [gist](https://gist.github.com/gorethink/2865686d163ed78bbc3c) ```go cursor, err := r.Table("items").Changes() ch := make(chan map[string]interface{}) cursor.Listen(ch) ``` For more details checkout the [README](https://github.com/gorethink/gorethink/blob/master/README.md) and [godoc](https://godoc.org/github.com/gorethink/gorethink). As always if you have any further questions send me a message on [Gitter](https://gitter.im/gorethink/gorethink). - Added the ability to connect to multiple nodes, queries are then distributed between these nodes. If a node stops responding then queries stop being sent to this node. - Added the `DiscoverHosts` optional argument to `ConnectOpts`, when this value is `true` the driver will listen for new nodes added to the cluster. - Added the `Addresses` optional argument to `ConnectOpts`, this allows the driver to connect to multiple nodes in a cluster. - Added the `IncludeStates` optional argument to `Changes`. - Added `MinVal` and `MaxVal` which represent the smallest and largest possible values. - Added the `Listen` cursor helper function which publishes database results to a channel. - Added support for optional arguments for the `Wait` function. - Added the `Type` function to the `Cursor`, by default this value will be "Cursor" unless using a changefeed. - Changed the `IndexesOf` function to `OffsetsOf` . - Changed driver to use the v0.4 protocol (used to use v0.3). - Fixed geometry tests not properly checking the expected results. - Fixed bug causing nil pointer panics when using an `Unmarshaler` - Fixed dropped millisecond precision if given value is too old ## v0.6.3 - 2015-03-04 ### Added - Add `IdentifierFormat` optarg to `TableOpts` (#158) ### Fixed - Fix struct alignment for ARM and x86-32 builds (#153) - Fix sprintf format for geometry error message (#157) - Fix duplicate if block (#159) - Fix incorrect assertion in decoder tests ## v0.6.2 - 2015-02-15 - Fixed `writeQuery` being too small when sending large queries ## v0.6.1 - 2015-02-13 - Reduce GC by using buffers when reading and writing - Fixed encoding `time.Time` ignoring millseconds - Fixed pointers in structs that implement the `Marshaler`/`Unmarshaler` interfaces being ignored ## v0.6.0 - 2015-01-01 There are some major changes to the driver with this release that are not related to the RethinkDB v1.16 release. Please have a read through them: - Improvements to result decoding by caching reflection calls. - Finished implementing the `Marshaler`/`Unmarshaler` interfaces - Connection pool overhauled. There were a couple of issues with connections in the previous releases so this release replaces the `fatih/pool` package with a connection pool based on the `database/sql` connection pool. - Another change is the removal of the prefetching mechanism as the connection+cursor logic was becoming quite complex and causing bugs, hopefully this will be added back in the near future but for now I am focusing my efforts on ensuring the driver is as stable as possible #130 #137 - Due to the above change the API for connecting has changed slightly (The API is now closer to the `database/sql` API. `ConnectOpts` changes: - `MaxActive` renamed to `MaxOpen` - `IdleTimeout` renamed to `Timeout` - `Cursor`s are now only closed automatically when calling either `All` or `One` - `Exec` now takes `ExecOpts` instead of `RunOpts`. The only difference is that `Exec` has the `NoReply` field With that out the way here are the v1.16 changes: - Added `Range` which generates all numbers from a given range - Added an optional squash argument to the changes command, which lets the server combine multiple changes to the same document (defaults to true) - Added new admin functions (`Config`, `Rebalance`, `Reconfigure`, `Status`, `Wait`) - Added support for `SUCCESS_ATOM_FEED` - Added `MinIndex` + `MaxInde`x functions - Added `ToJSON` function - Updated `WriteResponse` type Since this release has a lot of changes and although I have tested these changes sometimes things fall through the gaps. If you discover any bugs please let me know and I will try to fix them as soon as possible. ## v.0.5.1 - 2014-12-14 - Fixed empty slices being returned as `[]T(nil)` not `[]T{}` #138 ## v0.5.0 - 2014-10-06 - Added geospatial terms (`Circle`, `Distance`, `Fill`, `Geojson`, `ToGeojson`, `GetIntersecting`, `GetNearest`, `Includes`, `Intersects`, `Line`, `Point`, `Polygon`, `PolygonSub`) - Added `UUID` term for generating unique IDs - Added `AtIndex` term, combines `Nth` and `GetField` - Added the `Geometry` type, see the types package - Updated the `BatchConf` field in `RunOpts`, now uses the `BatchOpts` type - Removed support for the `FieldMapper` interface Internal Changes - Fixed encoding performance issues, greatly improves writes/second - Updated `Next` to zero the destination value every time it is called. ## v0.4.2 - 2014-09-06 - Fixed issue causing `Close` to start an infinite loop - Tidied up connection closing logic ## v0.4.1 - 2014-09-05 - Fixed bug causing Pseudotypes to not be decoded properly (#117) - Updated github.com/fatih/pool to v2 (#118) ## v0.4.0 - 2014-08-13 - Updated the driver to support RethinkDB v1.14 (#116) - Added the Binary data type - Added the Binary command which takes a `[]byte` or `bytes.Buffer{}` as an argument. - Added the `BinaryFormat` optional argument to `RunOpts` - Added the `GroupFormat` optional argument to `RunOpts` - Added the `ArrayLimit` optional argument to `RunOpts` - Renamed the `ReturnVals` optional argument to `ReturnChanges` - Renamed the `Upsert` optional argument to `Conflict` - Added the `IndexRename` command - Updated `Distinct` to now take the `Index` optional argument (using `DistinctOpts`) Internal Changes - Updated to use the new JSON protocol - Switched the connection pool code to use github.com/fatih/pool - Added some benchmarks ## v0.3.2 - 2014-08-17 - Fixed issue causing connections not to be closed correctly (#109) - Fixed issue causing terms in optional arguments to be encoded incorrectly (#114) ## v0.3.1 - 2014-06-14 - Fixed "Token ## not in stream cache" error (#103) - Changed Exec to no longer use NoReply. It now waits for the server to respond. ## v0.3.0 - 2014-06-26 - Replaced `ResultRows`/`ResultRow` with `Cursor`, `Cursor` has the `Next`, `All` and `One` methods which stores the relevant value in the value pointed at by result. For more information check the examples. - Changed the time constants (Days and Months) to package globals instead of functions - Added the `Args` term and changed the arguments for many terms to `args ...interface{}` to allow argument splicing - Added the `Changes` term and support for the feed response type - Added the `Random` term - Added the `Http` term - The second argument for `Slice` is now optional - `EqJoin` now accepts a function as its first argument - `Nth` now returns a selection ## v0.2.0 - 2014-04-13 * Changed `Connect` to use `ConnectOpts` instead of `map[string]interface{}` * Migrated to new `Group`/`Ungroup` functions, these replace `GroupedMapReduce` and `GroupBy` * Added new aggregators * Removed base parameter for `Reduce` * Added `Object` function * Added `Upcase`, `Downcase` and `Split` string functions * Added `GROUPED_DATA` pseudotype * Fixed query printing ## v0.1.0 - 2013-11-27 * Added noreply writes * Added the new terms `index_status`, `index_wait` and `sync` * Added the profile flag to the run functions * Optional arguments are now structs instead of key, pair strings. Almost all of the struct fields are of type interface{} as they can have terms inside them. For example: `r.TableCreateOpts{ PrimaryKey: r.Expr("index") }` * Returned arrays are now properly loaded into ResultRows. In the past when running `r.Expr([]interface{}{1,2,3})` would require you to use `RunRow` followed by `Scan`. You can now use `Run` followed by `ScanAll` rethinkdb-go-6.2.1/LICENSE000066400000000000000000000240411363464422500151140ustar00rootroot00000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} 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 http://www.apache.org/licenses/LICENSE-2.0 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. rethinkdb-go-6.2.1/Makefile000066400000000000000000000006721363464422500155530ustar00rootroot00000000000000test: go test -coverprofile=cover.out -race gopkg.in/rethinkdb/rethinkdb-go.v6 gopkg.in/rethinkdb/rethinkdb-go.v6/encoding gopkg.in/rethinkdb/rethinkdb-go.v6/types go tool cover -html=cover.out -o cover.html rm -f cover.out integration: go test -race gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/... benchpool: go test -v -cpu 1,2,4,8,16,24,32,64,128,256 -bench=BenchmarkConnectionPool -run ^$ ./internal/integration/tests/ rethinkdb-go-6.2.1/README.md000066400000000000000000000552601363464422500153750ustar00rootroot00000000000000# RethinkDB-go - RethinkDB Driver for Go [![GitHub tag](https://img.shields.io/github/tag/rethinkdb/rethinkdb-go.svg?style=flat)](https://github.com/rethinkdb/rethinkdb-go/releases) [![GoDoc](https://godoc.org/github.com/rethinkdb/rethinkdb-go?status.svg)](https://godoc.org/github.com/rethinkdb/rethinkdb-go) [![Build status](https://travis-ci.org/rethinkdb/rethinkdb-go.svg?branch=master)](https://travis-ci.org/rethinkdb/rethinkdb-go) [Go](http://golang.org/) driver for [RethinkDB](http://www.rethinkdb.com/) ![RethinkDB-go Logo](https://raw.github.com/wiki/rethinkdb/rethinkdb-go/gopher-and-thinker-s.png "Golang Gopher and RethinkDB Thinker") Current version: v6.2.1 (RethinkDB v2.4) Please note that this version of the driver only supports versions of RethinkDB using the v0.4 protocol (any versions of the driver older than RethinkDB 2.0 will not work). If you need any help you can find me on the [RethinkDB slack](https://rethinkdb.slack.com/) in the #gorethink channel. ## Installation ``` go get gopkg.in/rethinkdb/rethinkdb-go.v6 ``` Replace `v6` with `v5` or `v4` to use previous versions. ## Example [embedmd]:# (example_test.go go) ```go package rethinkdb_test import ( "fmt" "log" r "gopkg.in/rethinkdb/rethinkdb-go.v6" ) func Example() { session, err := r.Connect(r.ConnectOpts{ Address: url, // endpoint without http }) if err != nil { log.Fatalln(err) } res, err := r.Expr("Hello World").Run(session) if err != nil { log.Fatalln(err) } var response string err = res.One(&response) if err != nil { log.Fatalln(err) } fmt.Println(response) // Output: // Hello World } ``` ## Connection ### Basic Connection Setting up a basic connection with RethinkDB is simple: [embedmd]:# (example_connect_test.go go /func ExampleConnect\(\) {/ /^}/) ```go func ExampleConnect() { var err error session, err = r.Connect(r.ConnectOpts{ Address: url, }) if err != nil { log.Fatalln(err.Error()) } } ``` See the [documentation](http://godoc.org/github.com/rethinkdb/rethinkdb-go#Connect) for a list of supported arguments to Connect(). ### Connection Pool The driver uses a connection pool at all times, by default it creates and frees connections automatically. It's safe for concurrent use by multiple goroutines. To configure the connection pool `InitialCap`, `MaxOpen` and `Timeout` can be specified during connection. If you wish to change the value of `InitialCap` or `MaxOpen` during runtime then the functions `SetInitialPoolCap` and `SetMaxOpenConns` can be used. [embedmd]:# (example_connect_test.go go /func ExampleConnect_connectionPool\(\) {/ /^}/) ```go func ExampleConnect_connectionPool() { var err error session, err = r.Connect(r.ConnectOpts{ Address: url, InitialCap: 10, MaxOpen: 10, }) if err != nil { log.Fatalln(err.Error()) } } ``` ### Connect to a cluster To connect to a RethinkDB cluster which has multiple nodes you can use the following syntax. When connecting to a cluster with multiple nodes queries will be distributed between these nodes. [embedmd]:# (example_connect_test.go go /func ExampleConnect_cluster\(\) {/ /^}/) ```go func ExampleConnect_cluster() { var err error session, err = r.Connect(r.ConnectOpts{ Addresses: []string{url}, // Addresses: []string{url1, url2, url3, ...}, }) if err != nil { log.Fatalln(err.Error()) } } ``` When `DiscoverHosts` is true any nodes are added to the cluster after the initial connection then the new node will be added to the pool of available nodes used by RethinkDB-go. Unfortunately the canonical address of each server in the cluster **MUST** be set as otherwise clients will try to connect to the database nodes locally. For more information about how to set a RethinkDB servers canonical address set this page http://www.rethinkdb.com/docs/config-file/. ## User Authentication To login with a username and password you should first create a user, this can be done by writing to the `users` system table and then grant that user access to any tables or databases they need access to. This queries can also be executed in the RethinkDB admin console. ```go err := r.DB("rethinkdb").Table("users").Insert(map[string]string{ "id": "john", "password": "p455w0rd", }).Exec(session) ... err = r.DB("blog").Table("posts").Grant("john", map[string]bool{ "read": true, "write": true, }).Exec(session) ... ``` Finally the username and password should be passed to `Connect` when creating your session, for example: ```go session, err := r.Connect(r.ConnectOpts{ Address: "localhost:28015", Database: "blog", Username: "john", Password: "p455w0rd", }) ``` Please note that `DiscoverHosts` will not work with user authentication at this time due to the fact that RethinkDB restricts access to the required system tables. ## Query Functions This library is based on the official drivers so the code on the [API](http://www.rethinkdb.com/api/) page should require very few changes to work. To view full documentation for the query functions check the [API reference](https://github.com/rethinkdb/rethinkdb-go/wiki/Go-ReQL-command-reference) or [GoDoc](http://godoc.org/github.com/rethinkdb/rethinkdb-go#Term) Slice Expr Example ```go r.Expr([]interface{}{1, 2, 3, 4, 5}).Run(session) ``` Map Expr Example ```go r.Expr(map[string]interface{}{"a": 1, "b": 2, "c": 3}).Run(session) ``` Get Example ```go r.DB("database").Table("table").Get("GUID").Run(session) ``` Map Example (Func) ```go r.Expr([]interface{}{1, 2, 3, 4, 5}).Map(func (row Term) interface{} { return row.Add(1) }).Run(session) ``` Map Example (Implicit) ```go r.Expr([]interface{}{1, 2, 3, 4, 5}).Map(r.Row.Add(1)).Run(session) ``` Between (Optional Args) Example ```go r.DB("database").Table("table").Between(1, 10, r.BetweenOpts{ Index: "num", RightBound: "closed", }).Run(session) ``` For any queries which use callbacks the function signature is important as your function needs to be a valid RethinkDB-go callback, you can see an example of this in the map example above. The simplified explanation is that all arguments must be of type `r.Term`, this is because of how the query is sent to the database (your callback is not actually executed in your Go application but encoded as JSON and executed by RethinkDB). The return argument can be anything you want it to be (as long as it is a valid return value for the current query) so it usually makes sense to return `interface{}`. Here is an example of a callback for the conflict callback of an insert operation: ```go r.Table("test").Insert(doc, r.InsertOpts{ Conflict: func(id, oldDoc, newDoc r.Term) interface{} { return newDoc.Merge(map[string]interface{}{ "count": oldDoc.Add(newDoc.Field("count")), }) }, }) ``` ### Optional Arguments As shown above in the Between example optional arguments are passed to the function as a struct. Each function that has optional arguments as a related struct. This structs are named in the format FunctionNameOpts, for example BetweenOpts is the related struct for Between. #### Cancelling queries For query cancellation use `Context` argument at `RunOpts`. If `Context` is `nil` and `ReadTimeout` or `WriteTimeout` is not 0 from `ConnectionOpts`, `Context` will be formed by summation of these timeouts. For unlimited timeouts for `Changes()` pass `context.Background()`. ## Results Different result types are returned depending on what function is used to execute the query. - `Run` returns a cursor which can be used to view all rows returned. - `RunWrite` returns a WriteResponse and should be used for queries such as Insert, Update, etc... - `Exec` sends a query to the server and closes the connection immediately after reading the response from the database. If you do not wish to wait for the response then you can set the `NoReply` flag. Example: ```go res, err := r.DB("database").Table("tablename").Get(key).Run(session) if err != nil { // error } defer res.Close() // Always ensure you close the cursor to ensure connections are not leaked ``` Cursors have a number of methods available for accessing the query results - `Next` retrieves the next document from the result set, blocking if necessary. - `All` retrieves all documents from the result set into the provided slice. - `One` retrieves the first document from the result set. Examples: ```go var row interface{} for res.Next(&row) { // Do something with row } if res.Err() != nil { // error } ``` ```go var rows []interface{} err := res.All(&rows) if err != nil { // error } ``` ```go var row interface{} err := res.One(&row) if err == r.ErrEmptyResult { // row not found } if err != nil { // error } ``` ## Encoding/Decoding When passing structs to Expr(And functions that use Expr such as Insert, Update) the structs are encoded into a map before being sent to the server. Each exported field is added to the map unless - the field's tag is "-", or - the field is empty and its tag specifies the "omitempty" option. Each fields default name in the map is the field name but can be specified in the struct field's tag value. The "rethinkdb" key in the struct field's tag value is the key name, followed by an optional comma and options. Examples: ```go // Field is ignored by this package. Field int `rethinkdb:"-"` // Field appears as key "myName". Field int `rethinkdb:"myName"` // Field appears as key "myName" and // the field is omitted from the object if its value is empty, // as defined above. Field int `rethinkdb:"myName,omitempty"` // Field appears as key "Field" (the default), but // the field is skipped if empty. // Note the leading comma. Field int `rethinkdb:",omitempty"` // When the tag name includes an index expression // a compound field is created Field1 int `rethinkdb:"myName[0]"` Field2 int `rethinkdb:"myName[1]"` ``` **NOTE:** It is strongly recommended that struct tags are used to explicitly define the mapping between your Go type and how the data is stored by RethinkDB. This is especially important when using an `Id` field as by default RethinkDB will create a field named `id` as the primary key (note that the RethinkDB field is lowercase but the Go version starts with a capital letter). When encoding maps with non-string keys the key values are automatically converted to strings where possible, however it is recommended that you use strings where possible (for example `map[string]T`). If you wish to use the `json` tags for RethinkDB-go then you can call `SetTags("rethinkdb", "json")` when starting your program, this will cause RethinkDB-go to check for `json` tags after checking for `rethinkdb` tags. By default this feature is disabled. This function will also let you support any other tags, the driver will check for tags in the same order as the parameters. **NOTE:** Old-style `gorethink` struct tags are supported but deprecated. ### Pseudo-types RethinkDB contains some special types which can be used to store special value types, currently supports are binary values, times and geometry data types. RethinkDB-go supports these data types natively however there are some gotchas: - Time types: To store times in RethinkDB with RethinkDB-go you must pass a `time.Time` value to your query, due to the way Go works type aliasing or embedding is not support here - Binary types: To store binary data pass a byte slice (`[]byte`) to your query - Geometry types: As Go does not include any built-in data structures for storing geometry data RethinkDB-go includes its own in the `github.com/rethinkdb/rethinkdb-go/types` package, Any of the types (`Geometry`, `Point`, `Line` and `Lines`) can be passed to a query to create a RethinkDB geometry type. ### Compound Keys RethinkDB unfortunately does not support compound primary keys using multiple fields however it does support compound keys using an array of values. For example if you wanted to create a compound key for a book where the key contained the author ID and book name then the ID might look like this `["author_id", "book name"]`. Luckily RethinkDB-go allows you to easily manage these keys while keeping the fields separate in your structs. For example: ```go type Book struct { AuthorID string `rethinkdb:"id[0]"` Name string `rethinkdb:"id[1]"` } // Creates the following document in RethinkDB {"id": [AUTHORID, NAME]} ``` ### References Sometimes you may want to use a Go struct that references a document in another table, instead of creating a new struct which is just used when writing to RethinkDB you can annotate your struct with the reference tag option. This will tell RethinkDB-go that when encoding your data it should "pluck" the ID field from the nested document and use that instead. This is all quite complicated so hopefully this example should help. First lets assume you have two types `Author` and `Book` and you want to insert a new book into your database however you dont want to include the entire author struct in the books table. As you can see the `Author` field in the `Book` struct has some extra tags, firstly we have added the `reference` tag option which tells RethinkDB-go to pluck a field from the `Author` struct instead of inserting the whole author document. We also have the `rethinkdb_ref` tag which tells RethinkDB-go to look for the `id` field in the `Author` document, without this tag RethinkDB-go would instead look for the `author_id` field. ```go type Author struct { ID string `rethinkdb:"id,omitempty"` Name string `rethinkdb:"name"` } type Book struct { ID string `rethinkdb:"id,omitempty"` Title string `rethinkdb:"title"` Author Author `rethinkdb:"author_id,reference" rethinkdb_ref:"id"` } ``` The resulting data in RethinkDB should look something like this: ```json { "author_id": "author_1", "id": "book_1", "title": "The Hobbit" } ``` If you wanted to read back the book with the author included then you could run the following RethinkDB-go query: ```go r.Table("books").Get("1").Merge(func(p r.Term) interface{} { return map[string]interface{}{ "author_id": r.Table("authors").Get(p.Field("author_id")), } }).Run(session) ``` You are also able to reference an array of documents, for example if each book stored multiple authors you could do the following: ```go type Book struct { ID string `rethinkdb:"id,omitempty"` Title string `rethinkdb:"title"` Authors []Author `rethinkdb:"author_ids,reference" rethinkdb_ref:"id"` } ``` ```json { "author_ids": ["author_1", "author_2"], "id": "book_1", "title": "The Hobbit" } ``` The query for reading the data back is slightly more complicated but is very similar: ```go r.Table("books").Get("book_1").Merge(func(p r.Term) interface{} { return map[string]interface{}{ "author_ids": r.Table("authors").GetAll(r.Args(p.Field("author_ids"))).CoerceTo("array"), } }) ``` ### Custom `Marshaler`s/`Unmarshaler`s Sometimes the default behaviour for converting Go types to and from ReQL is not desired, for these situations the driver allows you to implement both the [`Marshaler`](https://godoc.org/github.com/rethinkdb/rethinkdb-go/encoding#Marshaler) and [`Unmarshaler`](https://godoc.org/github.com/rethinkdb/rethinkdb-go/encoding#Unmarshaler) interfaces. These interfaces might look familiar if you are using to using the `encoding/json` package however instead of dealing with `[]byte` the interfaces deal with `interface{}` values (which are later encoded by the `encoding/json` package when communicating with the database). An good example of how to use these interfaces is in the [`types`](https://github.com/rethinkdb/rethinkdb-go/blob/master/types/geometry.go#L84-L106) package, in this package the `Point` type is encoded as the `GEOMETRY` pseudo-type instead of a normal JSON object. On the other side, you can implement external encode/decode functions with [`SetTypeEncoding`](https://godoc.org/github.com/rethinkdb/rethinkdb-go/encoding#SetTypeEncoding) function. ## Logging By default the driver logs are disabled however when enabled the driver will log errors when it fails to connect to the database. If you would like more verbose error logging you can call `r.SetVerbose(true)`. Alternatively if you wish to modify the logging behaviour you can modify the logger provided by `github.com/sirupsen/logrus`. For example the following code completely disable the logger: ```go // Enabled r.Log.Out = os.Stderr // Disabled r.Log.Out = ioutil.Discard ``` ## Tracing The driver supports [opentracing-go](https://github.com/opentracing/opentracing-go/). You can enable this feature by setting `UseOpentracing` to true in the `ConnectOpts`. Then driver will expect `opentracing.Span` in the `RunOpts.Context` and will start new child spans for queries. Also you need to configure tracer in your program by yourself. The driver starts span for the whole query, from the first byte is sent to the cursor closed, and second-level span for each query for fetching data. So you can trace how much time you program spends for RethinkDB queries. ## Mocking The driver includes the ability to mock queries meaning that you can test your code without needing to talk to a real RethinkDB cluster, this is perfect for ensuring that your application has high unit test coverage. To write tests with mocking you should create an instance of `Mock` and then setup expectations using `On` and `Return`. Expectations allow you to define what results should be returned when a known query is executed, they are configured by passing the query term you want to mock to `On` and then the response and error to `Return`, if a non-nil error is passed to `Return` then any time that query is executed the error will be returned, if no error is passed then a cursor will be built using the value passed to `Return`. Once all your expectations have been created you should then execute you queries using the `Mock` instead of a `Session`. Here is an example that shows how to mock a query that returns multiple rows and the resulting cursor can be used as normal. ```go func TestSomething(t *testing.T) { mock := r.NewMock() mock.On(r.Table("people")).Return([]interface{}{ map[string]interface{}{"id": 1, "name": "John Smith"}, map[string]interface{}{"id": 2, "name": "Jane Smith"}, }, nil) cursor, err := r.Table("people").Run(mock) if err != nil { t.Errorf("err is: %v", err) } var rows []interface{} err = cursor.All(&rows) if err != nil { t.Errorf("err is: %v", err) } // Test result of rows mock.AssertExpectations(t) } ``` If you want the cursor to block on some of the response values, you can pass in a value of type `chan interface{}` and the cursor will block until a value is available to read on the channel. Or you can pass in a function with signature `func() interface{}`: the cursor will call the function (which may block). Here is the example above adapted to use a channel. ```go func TestSomething(t *testing.T) { mock := r.NewMock() ch := make(chan []interface{}) mock.On(r.Table("people")).Return(ch, nil) go func() { ch <- []interface{}{ map[string]interface{}{"id": 1, "name": "John Smith"}, map[string]interface{}{"id": 2, "name": "Jane Smith"}, } ch <- []interface{}{map[string]interface{}{"id": 3, "name": "Jack Smith"}} close(ch) }() cursor, err := r.Table("people").Run(mock) if err != nil { t.Errorf("err is: %v", err) } var rows []interface{} err = cursor.All(&rows) if err != nil { t.Errorf("err is: %v", err) } // Test result of rows mock.AssertExpectations(t) } ``` The mocking implementation is based on amazing https://github.com/stretchr/testify library, thanks to @stretchr for their awesome work! ## Benchmarks Everyone wants their project's benchmarks to be speedy. And while we know that RethinkDB and the RethinkDB-go driver are quite fast, our primary goal is for our benchmarks to be correct. They are designed to give you, the user, an accurate picture of writes per second (w/s). If you come up with a accurate test that meets this aim, submit a pull request please. Thanks to @jaredfolkins for the contribution. | Type | Value | | ------------------------- | -------------- | | **Model Name** | MacBook Pro | | **Model Identifier** | MacBookPro11,3 | | **Processor Name** | Intel Core i7 | | **Processor Speed** | 2.3 GHz | | **Number of Processors** | 1 | | **Total Number of Cores** | 4 | | **L2 Cache (per Core)** | 256 KB | | **L3 Cache** | 6 MB | | **Memory** | 16 GB | ```bash BenchmarkBatch200RandomWrites 20 557227775 ns/op BenchmarkBatch200RandomWritesParallel10 30 354465417 ns/op BenchmarkBatch200SoftRandomWritesParallel10 100 761639276 ns/op BenchmarkRandomWrites 100 10456580 ns/op BenchmarkRandomWritesParallel10 1000 1614175 ns/op BenchmarkRandomSoftWrites 3000 589660 ns/op BenchmarkRandomSoftWritesParallel10 10000 247588 ns/op BenchmarkSequentialWrites 50 24408285 ns/op BenchmarkSequentialWritesParallel10 1000 1755373 ns/op BenchmarkSequentialSoftWrites 3000 631211 ns/op BenchmarkSequentialSoftWritesParallel10 10000 263481 ns/op ``` ## Examples Many functions have examples and are viewable in the godoc, alternatively view some more full features examples on the [wiki](https://github.com/rethinkdb/rethinkdb-go/wiki/Examples). Another good place to find examples are the tests, almost every term will have a couple of tests that demonstrate how they can be used. ## Further reading - [RethinkDB-go Goes 1.0](https://www.compose.io/articles/gorethink-goes-1-0/) - [Go, RethinkDB & Changefeeds](https://www.compose.io/articles/go-rethinkdb-and-changefeeds-part-1/) - [Build an IRC bot in Go with RethinkDB changefeeds](http://rethinkdb.com/blog/go-irc-bot/) ## License Copyright 2013 Daniel Cannon 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 http://www.apache.org/licenses/LICENSE-2.0 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. rethinkdb-go-6.2.1/cluster.go000066400000000000000000000264261363464422500161300ustar00rootroot00000000000000package rethinkdb import ( "errors" "fmt" "sort" "strings" "sync" "sync/atomic" "time" "github.com/hailocab/go-hostpool" "github.com/sirupsen/logrus" "golang.org/x/net/context" "gopkg.in/cenkalti/backoff.v2" ) var errClusterClosed = errors.New("rethinkdb: cluster is closed") const ( clusterWorking = 0 clusterClosed = 1 ) // A Cluster represents a connection to a RethinkDB cluster, a cluster is created // by the Session and should rarely be created manually. // // The cluster keeps track of all nodes in the cluster and if requested can listen // for cluster changes and start tracking a new node if one appears. Currently // nodes are removed from the pool if they become unhealthy (100 failed queries). // This should hopefully soon be replaced by a backoff system. type Cluster struct { opts *ConnectOpts mu sync.RWMutex seeds []Host // Initial host nodes specified by user. hp hostpool.HostPool nodes map[string]*Node // Active nodes in cluster. closed int32 // 0 - working, 1 - closed connFactory connFactory discoverInterval time.Duration } // NewCluster creates a new cluster by connecting to the given hosts. func NewCluster(hosts []Host, opts *ConnectOpts) (*Cluster, error) { c := &Cluster{ hp: newHostPool(opts), seeds: hosts, opts: opts, closed: clusterWorking, connFactory: NewConnection, } err := c.run() if err != nil { return nil, err } return c, nil } func newHostPool(opts *ConnectOpts) hostpool.HostPool { return hostpool.NewEpsilonGreedy([]string{}, opts.HostDecayDuration, &hostpool.LinearEpsilonValueCalculator{}) } func (c *Cluster) run() error { // Attempt to connect to each host and discover any additional hosts if host // discovery is enabled if err := c.connectCluster(); err != nil { return err } if !c.IsConnected() { return ErrNoConnectionsStarted } return nil } // Query executes a ReQL query using the cluster to connect to the database func (c *Cluster) Query(ctx context.Context, q Query) (cursor *Cursor, err error) { for i := 0; i < c.numRetries(); i++ { var node *Node var hpr hostpool.HostPoolResponse node, hpr, err = c.GetNextNode() if err != nil { return nil, err } cursor, err = node.Query(ctx, q) hpr.Mark(err) if !shouldRetryQuery(q, err) { break } } return cursor, err } // Exec executes a ReQL query using the cluster to connect to the database func (c *Cluster) Exec(ctx context.Context, q Query) (err error) { for i := 0; i < c.numRetries(); i++ { var node *Node var hpr hostpool.HostPoolResponse node, hpr, err = c.GetNextNode() if err != nil { return err } err = node.Exec(ctx, q) hpr.Mark(err) if !shouldRetryQuery(q, err) { break } } return err } // Server returns the server name and server UUID being used by a connection. func (c *Cluster) Server() (response ServerResponse, err error) { for i := 0; i < c.numRetries(); i++ { var node *Node var hpr hostpool.HostPoolResponse node, hpr, err = c.GetNextNode() if err != nil { return ServerResponse{}, err } response, err = node.Server() hpr.Mark(err) // This query should not fail so retry if any error is detected if err == nil { break } } return response, err } // SetInitialPoolCap sets the initial capacity of the connection pool. func (c *Cluster) SetInitialPoolCap(n int) { for _, node := range c.GetNodes() { node.SetInitialPoolCap(n) } } // SetMaxIdleConns sets the maximum number of connections in the idle // connection pool. func (c *Cluster) SetMaxIdleConns(n int) { for _, node := range c.GetNodes() { node.SetMaxIdleConns(n) } } // SetMaxOpenConns sets the maximum number of open connections to the database. func (c *Cluster) SetMaxOpenConns(n int) { for _, node := range c.GetNodes() { node.SetMaxOpenConns(n) } } // Close closes the cluster func (c *Cluster) Close(optArgs ...CloseOpts) error { if c.isClosed() { return nil } for _, node := range c.GetNodes() { err := node.Close(optArgs...) if err != nil { return err } } c.hp.Close() atomic.StoreInt32(&c.closed, clusterClosed) return nil } func (c *Cluster) isClosed() bool { return atomic.LoadInt32(&c.closed) == clusterClosed } // discover attempts to find new nodes in the cluster using the current nodes func (c *Cluster) discover() { // Keep retrying with exponential backoff. b := backoff.NewExponentialBackOff() // Never finish retrying (max interval is still 60s) b.MaxElapsedTime = 0 if c.discoverInterval != 0 { b.InitialInterval = c.discoverInterval } // Keep trying to discover new nodes for { if c.isClosed() { return } _ = backoff.RetryNotify(func() error { if c.isClosed() { return backoff.Permanent(errClusterClosed) } // If no hosts try seeding nodes if len(c.GetNodes()) == 0 { return c.connectCluster() } return c.listenForNodeChanges() }, b, func(err error, wait time.Duration) { Log.Debugf("Error discovering hosts %s, waiting: %s", err, wait) }) } } // listenForNodeChanges listens for changes to node status using change feeds. // This function will block until the query fails func (c *Cluster) listenForNodeChanges() error { // Start listening to changes from a random active node node, hpr, err := c.GetNextNode() if err != nil { return err } q, err := newQuery( DB(SystemDatabase).Table(ServerStatusSystemTable).Changes(ChangesOpts{IncludeInitial: true}), map[string]interface{}{}, c.opts, ) if err != nil { return fmt.Errorf("Error building query: %s", err) } cursor, err := node.Query(context.Background(), q) // no need for timeout due to Changes() if err != nil { hpr.Mark(err) return err } defer func() { _ = cursor.Close() }() // Keep reading node status updates from changefeed var result struct { NewVal *nodeStatus `rethinkdb:"new_val"` OldVal *nodeStatus `rethinkdb:"old_val"` } for cursor.Next(&result) { addr := fmt.Sprintf("%s:%d", result.NewVal.Network.Hostname, result.NewVal.Network.ReqlPort) addr = strings.ToLower(addr) if result.NewVal != nil && result.OldVal == nil { // added new node if !c.nodeExists(result.NewVal.ID) { // Connect to node using exponential backoff (give up after waiting 5s) // to give the node time to start-up. b := backoff.NewExponentialBackOff() b.MaxElapsedTime = time.Second * 5 err = backoff.Retry(func() error { node, err := c.connectNodeWithStatus(result.NewVal) if err == nil { c.addNode(node) Log.WithFields(logrus.Fields{ "id": node.ID, "host": node.Host.String(), }).Debug("Connected to node") } return err }, b) if err != nil { return err } } } else if result.OldVal != nil && result.NewVal == nil { // removed old node oldNode := c.removeNode(result.OldVal.ID) if oldNode != nil { _ = oldNode.Close() } } else { // node updated // nothing to do - assuming node can't change it's hostname in a single Changes() message } } err = cursor.Err() hpr.Mark(err) return err } func (c *Cluster) connectCluster() error { nodeSet := map[string]*Node{} var attemptErr error // Attempt to connect to each seed host for _, host := range c.seeds { conn, err := c.connFactory(host.String(), c.opts) if err != nil { attemptErr = err Log.Warnf("Error creating connection: %s", err.Error()) continue } svrRsp, err := conn.Server() if err != nil { attemptErr = err Log.Warnf("Error fetching server ID: %s", err) _ = conn.Close() continue } _ = conn.Close() node, err := c.connectNode(svrRsp.ID, []Host{host}) if err != nil { attemptErr = err Log.Warnf("Error connecting to node: %s", err) continue } if _, ok := nodeSet[node.ID]; !ok { Log.WithFields(logrus.Fields{ "id": node.ID, "host": node.Host.String(), }).Debug("Connected to node") nodeSet[node.ID] = node } else { // dublicate node _ = node.Close() } } // If no nodes were contactable then return the last error, this does not // include driver errors such as if there was an issue building the // query if len(nodeSet) == 0 { if attemptErr != nil { return attemptErr } return ErrNoConnections } var nodes []*Node for _, node := range nodeSet { nodes = append(nodes, node) } c.replaceNodes(nodes) if c.opts.DiscoverHosts { go c.discover() } return nil } func (c *Cluster) connectNodeWithStatus(s *nodeStatus) (*Node, error) { aliases := make([]Host, len(s.Network.CanonicalAddresses)) for i, aliasAddress := range s.Network.CanonicalAddresses { aliases[i] = NewHost(aliasAddress.Host, int(s.Network.ReqlPort)) } return c.connectNode(s.ID, aliases) } func (c *Cluster) connectNode(id string, aliases []Host) (*Node, error) { var pool *Pool var err error for len(aliases) > 0 { pool, err = newPool(aliases[0], c.opts, c.connFactory) if err != nil { aliases = aliases[1:] continue } err = pool.Ping() if err != nil { aliases = aliases[1:] continue } // Ping successful so break out of loop break } if err != nil { return nil, err } if len(aliases) == 0 { return nil, ErrInvalidNode } return newNode(id, aliases, pool), nil } // IsConnected returns true if cluster has nodes and is not already connClosed. func (c *Cluster) IsConnected() bool { return (len(c.GetNodes()) > 0) && !c.isClosed() } // GetNextNode returns a random node on the cluster func (c *Cluster) GetNextNode() (*Node, hostpool.HostPoolResponse, error) { if !c.IsConnected() { return nil, nil, ErrNoConnections } c.mu.RLock() defer c.mu.RUnlock() nodes := c.nodes hpr := c.hp.Get() if n, ok := nodes[hpr.Host()]; ok { if !n.Closed() { return n, hpr, nil } } return nil, nil, ErrNoConnections } // GetNodes returns a list of all nodes in the cluster func (c *Cluster) GetNodes() []*Node { c.mu.RLock() defer c.mu.RUnlock() nodes := make([]*Node, 0, len(c.nodes)) for _, n := range c.nodes { nodes = append(nodes, n) } return nodes } func (c *Cluster) nodeExists(nodeID string) bool { c.mu.RLock() defer c.mu.RUnlock() for _, node := range c.nodes { if node.ID == nodeID { return true } } return false } func (c *Cluster) addNode(node *Node) { host := node.Host.String() c.mu.Lock() defer c.mu.Unlock() if _, exist := c.nodes[host]; exist { // addNode() should be called only if the node doesn't exist return } c.nodes[host] = node hosts := make([]string, 0, len(c.nodes)) for _, n := range c.nodes { hosts = append(hosts, n.Host.String()) } c.hp.SetHosts(hosts) } func (c *Cluster) replaceNodes(nodes []*Node) { nodesMap := make(map[string]*Node, len(nodes)) hosts := make([]string, len(nodes)) for i, node := range nodes { host := node.Host.String() nodesMap[host] = node hosts[i] = host } sort.Strings(hosts) // unit tests stability c.mu.Lock() c.nodes = nodesMap c.hp.SetHosts(hosts) c.mu.Unlock() } func (c *Cluster) removeNode(nodeID string) *Node { c.mu.Lock() defer c.mu.Unlock() var rmNode *Node for _, node := range c.nodes { if node.ID == nodeID { rmNode = node break } } if rmNode == nil { return nil } delete(c.nodes, rmNode.Host.String()) hosts := make([]string, 0, len(c.nodes)) for _, n := range c.nodes { hosts = append(hosts, n.Host.String()) } c.hp.SetHosts(hosts) return rmNode } func (c *Cluster) numRetries() int { if n := c.opts.NumRetries; n > 0 { return n } return 3 } rethinkdb-go-6.2.1/cluster_test.go000066400000000000000000000370631363464422500171660ustar00rootroot00000000000000package rethinkdb import ( "bytes" "encoding/binary" "encoding/json" "fmt" "github.com/stretchr/testify/mock" test "gopkg.in/check.v1" "gopkg.in/rethinkdb/rethinkdb-go.v6/encoding" p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" "io" "net" "time" ) type ClusterSuite struct{} var _ = test.Suite(&ClusterSuite{}) func (s *ClusterSuite) TestCluster_NewSingle_NoDiscover_Ok(c *test.C) { host1 := Host{Name: "host1", Port: 28015} node1 := "node1" conn1 := &connMock{} expectServerQuery(conn1, 1, node1) conn1.onCloseReturn(nil) conn2 := &connMock{} conn2.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() dialMock.On("Dial", host1.String()).Return(conn2, nil).Once() opts := &ConnectOpts{} seeds := []Host{host1} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.IsNil) conn1.waitDial() conn2.waitDial() err = cluster.Close() c.Assert(err, test.IsNil) conn1.waitDone() conn2.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1, conn2) } func (s *ClusterSuite) TestCluster_NewMultiple_NoDiscover_Ok(c *test.C) { host1 := Host{Name: "host1", Port: 28015} host2 := Host{Name: "host2", Port: 28015} node1 := "node1" node2 := "node2" conn1 := &connMock{} expectServerQuery(conn1, 1, node1) conn1.onCloseReturn(nil) conn2 := &connMock{} conn2.onCloseReturn(nil) conn3 := &connMock{} expectServerQuery(conn3, 1, node2) conn3.onCloseReturn(nil) conn4 := &connMock{} conn4.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() dialMock.On("Dial", host1.String()).Return(conn2, nil).Once() dialMock.On("Dial", host2.String()).Return(conn3, nil).Once() dialMock.On("Dial", host2.String()).Return(conn4, nil).Once() opts := &ConnectOpts{} seeds := []Host{host1, host2} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.IsNil) conn1.waitDial() conn2.waitDial() conn3.waitDial() conn4.waitDial() err = cluster.Close() c.Assert(err, test.IsNil) conn1.waitDone() conn2.waitDone() conn3.waitDone() conn4.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1, conn2, conn3, conn4) } func (s *ClusterSuite) TestCluster_NewSingle_NoDiscover_DialFail(c *test.C) { host1 := Host{Name: "host1", Port: 28015} dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(nil, io.EOF).Once() opts := &ConnectOpts{} seeds := []Host{host1} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.Equals, io.EOF) mock.AssertExpectationsForObjects(c, dialMock) } func (s *ClusterSuite) TestCluster_NewMultiple_NoDiscover_DialHalfFail(c *test.C) { host1 := Host{Name: "host1", Port: 28015} host2 := Host{Name: "host2", Port: 28015} node1 := "node1" conn1 := &connMock{} expectServerQuery(conn1, 1, node1) conn1.onCloseReturn(nil) conn2 := &connMock{} conn2.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() dialMock.On("Dial", host1.String()).Return(conn2, nil).Once() dialMock.On("Dial", host2.String()).Return(nil, io.EOF).Once() opts := &ConnectOpts{} seeds := []Host{host1, host2} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.IsNil) conn1.waitDial() conn2.waitDial() err = cluster.Close() c.Assert(err, test.IsNil) conn1.waitDone() conn2.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1, conn2) } func (s *ClusterSuite) TestCluster_NewMultiple_NoDiscover_DialFail(c *test.C) { host1 := Host{Name: "host1", Port: 28015} host2 := Host{Name: "host2", Port: 28015} dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(nil, io.EOF).Once() dialMock.On("Dial", host2.String()).Return(nil, io.EOF).Once() opts := &ConnectOpts{} seeds := []Host{host1, host2} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.Equals, io.EOF) mock.AssertExpectationsForObjects(c, dialMock) } func (s *ClusterSuite) TestCluster_NewSingle_NoDiscover_ServerFail(c *test.C) { host1 := Host{Name: "host1", Port: 28015} conn1 := &connMock{} expectServerQueryFail(conn1, 1, io.EOF) conn1.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() opts := &ConnectOpts{} seeds := []Host{host1} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.NotNil) if _, ok := err.(RQLConnectionError); ok { c.Assert(err, test.Equals, RQLConnectionError{rqlError(io.EOF.Error())}) } else { c.Assert(err, test.Equals, ErrConnectionClosed) } conn1.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1) } func (s *ClusterSuite) TestCluster_NewSingle_NoDiscover_PingFail(c *test.C) { host1 := Host{Name: "host1", Port: 28015} node1 := "node1" conn1 := &connMock{} expectServerQuery(conn1, 1, node1) conn1.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() dialMock.On("Dial", host1.String()).Return(nil, io.EOF).Once() opts := &ConnectOpts{} seeds := []Host{host1} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), } err := cluster.run() c.Assert(err, test.Equals, io.EOF) conn1.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1) } func (s *ClusterSuite) TestCluster_NewSingle_Discover_Ok(c *test.C) { host1 := Host{Name: "host1", Port: 28015} host2 := Host{Name: "1.1.1.1", Port: 2222} host3 := Host{Name: "2.2.2.2", Port: 3333} node1 := "node1" node2 := "node2" node3 := "node3" conn1 := &connMock{} expectServerQuery(conn1, 1, node1) conn1.onCloseReturn(nil) conn2 := &connMock{} expectServerStatus(conn2, 1, []string{node1, node2, node3}, []Host{host1, host2, host3}) conn2.onCloseReturn(nil) conn3 := &connMock{} conn3.onCloseReturn(nil) conn4 := &connMock{} // doesn't need call Server() due to it's known through ServerStatus() conn4.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() dialMock.On("Dial", host1.String()).Return(conn2, nil).Once() dialMock.On("Dial", host2.String()).Return(conn3, nil).Once() dialMock.On("Dial", host3.String()).Return(conn4, nil).Once() opts := &ConnectOpts{DiscoverHosts: true} seeds := []Host{host1} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), discoverInterval: 10 * time.Second, } err := cluster.run() c.Assert(err, test.IsNil) conn1.waitDial() conn2.waitDial() conn3.waitDial() conn4.waitDial() for !cluster.nodeExists(node2) || !cluster.nodeExists(node3) { // wait node to be added to list to be closed with cluster time.Sleep(time.Millisecond) } err = cluster.Close() c.Assert(err, test.IsNil) conn1.waitDone() conn2.waitDone() conn3.waitDone() conn4.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1, conn2, conn3, conn4) } func (s *ClusterSuite) TestCluster_NewMultiple_Discover_Ok(c *test.C) { host1 := Host{Name: "host1", Port: 28015} host2 := Host{Name: "host2", Port: 28016} host3 := Host{Name: "2.2.2.2", Port: 3333} node1 := "node1" node2 := "node2" node3 := "node3" conn1 := &connMock{} expectServerQuery(conn1, 1, node1) conn1.onCloseReturn(nil) conn2 := &connMock{} expectServerStatus(conn2, 1, []string{node1, node2, node3}, []Host{host1, host2, host3}) conn2.onCloseReturn(nil) conn3 := &connMock{} expectServerQuery(conn3, 1, node2) conn3.onCloseReturn(nil) conn4 := &connMock{} conn4.onCloseReturn(nil) conn5 := &connMock{} // doesn't need call Server() due to it's known through ServerStatus() conn5.onCloseReturn(nil) dialMock := &mockDial{} dialMock.On("Dial", host1.String()).Return(conn1, nil).Once() dialMock.On("Dial", host1.String()).Return(conn2, nil).Once() dialMock.On("Dial", host2.String()).Return(conn3, nil).Once() dialMock.On("Dial", host2.String()).Return(conn4, nil).Once() dialMock.On("Dial", host3.String()).Return(conn5, nil).Once() opts := &ConnectOpts{DiscoverHosts: true} seeds := []Host{host1, host2} cluster := &Cluster{ hp: newHostPool(opts), seeds: seeds, opts: opts, closed: clusterWorking, connFactory: mockedConnectionFactory(dialMock), discoverInterval: 10 * time.Second, } err := cluster.run() c.Assert(err, test.IsNil) conn1.waitDial() conn2.waitDial() conn3.waitDial() conn4.waitDial() conn5.waitDial() for !cluster.nodeExists(node3) { // wait node to be added to list to be closed with cluster time.Sleep(time.Millisecond) } err = cluster.Close() c.Assert(err, test.IsNil) conn1.waitDone() conn2.waitDone() conn3.waitDone() conn4.waitDone() conn5.waitDone() mock.AssertExpectationsForObjects(c, dialMock, conn1, conn2, conn3, conn4, conn5) } type mockDial struct { mock.Mock } func mockedConnectionFactory(dial *mockDial) connFactory { return func(host string, opts *ConnectOpts) (connection *Connection, err error) { args := dial.MethodCalled("Dial", host) err = args.Error(1) if err != nil { return nil, err } connection = newConnection(args.Get(0).(net.Conn), host, opts) done := runConnection(connection) m := args.Get(0).(*connMock) m.setDone(done) return connection, nil } } func expectServerQuery(conn *connMock, token int64, nodeID string) { writeChan := make(chan struct{}) readChan := make(chan struct{}) rawQ := makeServerQueryRaw(token) conn.On("Write", rawQ).Return(0, nil, nil).Once().Run(func(args mock.Arguments) { close(writeChan) }) rawR := makeServerResponseRaw(token, nodeID) rawH := makeResponseHeaderRaw(token, len(rawR)) conn.On("Read", respHeaderLen).Return(rawH, len(rawH), nil, nil).Once().Run(func(args mock.Arguments) { <-writeChan close(readChan) }) conn.On("Read", len(rawR)).Return(rawR, len(rawR), nil, nil).Once().Run(func(args mock.Arguments) { <-readChan }) } func expectServerQueryFail(conn *connMock, token int64, err error) { writeChan := make(chan struct{}) rawQ := makeServerQueryRaw(token) conn.On("Write", rawQ).Return(0, nil, nil).Once().Run(func(args mock.Arguments) { close(writeChan) }) conn.On("Read", respHeaderLen).Return(nil, 0, err, nil).Once().Run(func(args mock.Arguments) { <-writeChan }) } func makeServerQueryRaw(token int64) []byte { buf := &bytes.Buffer{} buf.Grow(respHeaderLen) buf.Write(buf.Bytes()[:respHeaderLen]) enc := json.NewEncoder(buf) q := Query{ Token: token, Type: p.Query_SERVER_INFO, } err := enc.Encode(q.Build()) if err != nil { panic(fmt.Sprintf("must encode failed: %v", err)) } b := buf.Bytes() binary.LittleEndian.PutUint64(b, uint64(q.Token)) binary.LittleEndian.PutUint32(b[8:], uint32(len(b)-respHeaderLen)) return b } func makeResponseHeaderRaw(token int64, respLen int) []byte { buf1 := &bytes.Buffer{} buf1.Grow(respHeaderLen) buf1.Write(buf1.Bytes()[:respHeaderLen]) // reserve for header b1 := buf1.Bytes() binary.LittleEndian.PutUint64(b1, uint64(token)) binary.LittleEndian.PutUint32(b1[8:], uint32(respLen)) return b1 } func makeServerResponseRaw(token int64, nodeID string) []byte { buf2 := &bytes.Buffer{} enc := json.NewEncoder(buf2) coded, err := encoding.Encode(&ServerResponse{ID: nodeID}) if err != nil { panic(fmt.Sprintf("must encode response failed: %v", err)) } jresp, err := json.Marshal(coded) if err != nil { panic(fmt.Sprintf("must encode response failed: %v", err)) } resp := Response{Token: token, Type: p.Response_SERVER_INFO, Responses: []json.RawMessage{jresp}} err = enc.Encode(resp) if err != nil { panic(fmt.Sprintf("must encode failed: %v", err)) } return buf2.Bytes() } func expectServerStatus(conn *connMock, token int64, nodeIDs []string, hosts []Host) { writeChan := make(chan struct{}) readHChan := make(chan struct{}) readRChan := make(chan struct{}) rawQ := makeServerStatusQueryRaw(token) conn.On("Write", rawQ).Return(0, nil, nil).Once().Run(func(args mock.Arguments) { close(writeChan) }) rawR := makeServerStatusResponseRaw(token, nodeIDs, hosts) rawH := makeResponseHeaderRaw(token, len(rawR)) conn.On("Read", respHeaderLen).Return(rawH, len(rawH), nil, nil).Once().Run(func(args mock.Arguments) { <-writeChan close(readHChan) }) conn.On("Read", len(rawR)).Return(rawR, len(rawR), nil, nil).Once().Run(func(args mock.Arguments) { <-readHChan close(readRChan) }) rawQ2 := makeContinueQueryRaw(token) // maybe - connection may be closed until cursor fetchs next batch conn.On("Write", rawQ2).Return(0, nil, nil).Maybe().Run(func(args mock.Arguments) { <-readRChan }) } func makeServerStatusQueryRaw(token int64) []byte { buf := &bytes.Buffer{} buf.Grow(respHeaderLen) buf.Write(buf.Bytes()[:respHeaderLen]) // reserve for header enc := json.NewEncoder(buf) t := DB(SystemDatabase).Table(ServerStatusSystemTable).Changes(ChangesOpts{IncludeInitial: true}) q, err := newQuery(t, map[string]interface{}{}, &ConnectOpts{}) if err != nil { panic(fmt.Sprintf("must newQuery failed: %v", err)) } q.Token = token err = enc.Encode(q.Build()) if err != nil { panic(fmt.Sprintf("must encode failed: %v", err)) } b := buf.Bytes() binary.LittleEndian.PutUint64(b, uint64(q.Token)) binary.LittleEndian.PutUint32(b[8:], uint32(len(b)-respHeaderLen)) return b } func makeServerStatusResponseRaw(token int64, nodeIDs []string, hosts []Host) []byte { buf2 := &bytes.Buffer{} enc := json.NewEncoder(buf2) type change struct { NewVal *nodeStatus `rethinkdb:"new_val"` OldVal *nodeStatus `rethinkdb:"old_val"` } jresps := make([]json.RawMessage, len(nodeIDs)) for i := range nodeIDs { status := &nodeStatus{ID: nodeIDs[i], Network: nodeStatusNetwork{ ReqlPort: int64(hosts[i].Port), CanonicalAddresses: []nodeStatusNetworkAddr{ {Host: hosts[i].Name}, }, }} coded, err := encoding.Encode(&change{NewVal: status}) if err != nil { panic(fmt.Sprintf("must encode response failed: %v", err)) } jresps[i], err = json.Marshal(coded) if err != nil { panic(fmt.Sprintf("must encode response failed: %v", err)) } } resp := Response{Token: token, Type: p.Response_SUCCESS_PARTIAL, Responses: jresps} err := enc.Encode(resp) if err != nil { panic(fmt.Sprintf("must encode failed: %v", err)) } return buf2.Bytes() } func makeContinueQueryRaw(token int64) []byte { buf := &bytes.Buffer{} buf.Grow(respHeaderLen) buf.Write(buf.Bytes()[:respHeaderLen]) // reserve for header enc := json.NewEncoder(buf) q := Query{Token: token, Type: p.Query_CONTINUE} err := enc.Encode(q.Build()) if err != nil { panic(fmt.Sprintf("must encode failed: %v", err)) } b := buf.Bytes() binary.LittleEndian.PutUint64(b, uint64(q.Token)) binary.LittleEndian.PutUint32(b[8:], uint32(len(b)-respHeaderLen)) return b } rethinkdb-go-6.2.1/connection.go000066400000000000000000000357211363464422500166040ustar00rootroot00000000000000package rethinkdb import ( "crypto/tls" "encoding/binary" "encoding/json" "fmt" "net" "sync/atomic" "time" "bytes" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/log" "golang.org/x/net/context" p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" "sync" ) const ( respHeaderLen = 12 defaultKeepAlivePeriod = time.Second * 30 connNotBad = 0 connBad = 1 connWorking = 0 connClosed = 1 ) // Response represents the raw response from a query, most of the time you // should instead use a Cursor when reading from the database. type Response struct { Token int64 Type p.Response_ResponseType `json:"t"` ErrorType p.Response_ErrorType `json:"e"` Notes []p.Response_ResponseNote `json:"n"` Responses []json.RawMessage `json:"r"` Backtrace []interface{} `json:"b"` Profile interface{} `json:"p"` } // Connection is a connection to a rethinkdb database. Connection is not thread // safe and should only be accessed be a single goroutine type Connection struct { net.Conn address string opts *ConnectOpts _ [4]byte token int64 cursors map[int64]*Cursor bad int32 // 0 - not bad, 1 - bad closed int32 // 0 - working, 1 - closed stopReadChan chan bool readRequestsChan chan tokenAndPromise responseChan chan responseAndError stopProcessingChan chan struct{} mu sync.Mutex } type responseAndError struct { response *Response err error } type responseAndCursor struct { response *Response cursor *Cursor err error } type tokenAndPromise struct { ctx context.Context query *Query promise chan responseAndCursor span opentracing.Span } // NewConnection creates a new connection to the database server func NewConnection(address string, opts *ConnectOpts) (*Connection, error) { keepAlivePeriod := defaultKeepAlivePeriod if opts.KeepAlivePeriod > 0 { keepAlivePeriod = opts.KeepAlivePeriod } // Connect to Server var err error var conn net.Conn nd := net.Dialer{Timeout: opts.Timeout, KeepAlive: keepAlivePeriod} if opts.TLSConfig == nil { conn, err = nd.Dial("tcp", address) } else { conn, err = tls.DialWithDialer(&nd, "tcp", address, opts.TLSConfig) } if err != nil { return nil, RQLConnectionError{rqlError(err.Error())} } c := newConnection(conn, address, opts) // Send handshake handshake, err := c.handshake(opts.HandshakeVersion) if err != nil { return nil, err } if err = handshake.Send(); err != nil { return nil, err } // NOTE: mock.go: Mock.Query() // NOTE: connection_test.go: runConnection() go c.readSocket() go c.processResponses() return c, nil } func newConnection(conn net.Conn, address string, opts *ConnectOpts) *Connection { c := &Connection{ Conn: conn, address: address, opts: opts, cursors: make(map[int64]*Cursor), stopReadChan: make(chan bool, 1), bad: connNotBad, closed: connWorking, readRequestsChan: make(chan tokenAndPromise, 16), responseChan: make(chan responseAndError, 16), stopProcessingChan: make(chan struct{}), } return c } // Close closes the underlying net.Conn func (c *Connection) Close() error { var err error c.mu.Lock() defer c.mu.Unlock() if !c.isClosed() { c.setClosed() close(c.stopReadChan) err = c.Conn.Close() } return err } // Query sends a Query to the database, returning both the raw Response and a // Cursor which should be used to view the query's response. // // This function is used internally by Run which should be used for most queries. func (c *Connection) Query(ctx context.Context, q Query) (*Response, *Cursor, error) { if c == nil { return nil, nil, ErrConnectionClosed } if c.Conn == nil || c.isClosed() { c.setBad() return nil, nil, ErrConnectionClosed } if ctx == nil { ctx = c.contextFromConnectionOpts() } // Add token if query is a START/NOREPLY_WAIT if q.Type == p.Query_START || q.Type == p.Query_NOREPLY_WAIT || q.Type == p.Query_SERVER_INFO { q.Token = c.nextToken() } if q.Type == p.Query_START || q.Type == p.Query_NOREPLY_WAIT { if c.opts.Database != "" { var err error q.Opts["db"], err = DB(c.opts.Database).Build() if err != nil { return nil, nil, RQLDriverError{rqlError(err.Error())} } } } var fetchingSpan opentracing.Span if c.opts.UseOpentracing { parentSpan := opentracing.SpanFromContext(ctx) if parentSpan != nil { if q.Type == p.Query_START { querySpan := c.startTracingSpan(parentSpan, &q) // will be Finished when cursor connClosed parentSpan = querySpan ctx = opentracing.ContextWithSpan(ctx, querySpan) } fetchingSpan = c.startTracingSpan(parentSpan, &q) // will be Finished when response arrived } } err := c.sendQuery(q) if err != nil { if fetchingSpan != nil { ext.Error.Set(fetchingSpan, true) fetchingSpan.LogFields(log.Error(err)) fetchingSpan.Finish() if q.Type == p.Query_START { opentracing.SpanFromContext(ctx).Finish() } } return nil, nil, err } if noreply, ok := q.Opts["noreply"]; ok && noreply.(bool) { return nil, nil, nil } promise := make(chan responseAndCursor, 1) select { case c.readRequestsChan <- tokenAndPromise{ctx: ctx, query: &q, span: fetchingSpan, promise: promise}: case <-ctx.Done(): return c.stopQuery(&q) } select { case future := <-promise: return future.response, future.cursor, future.err case <-ctx.Done(): return c.stopQuery(&q) case <-c.stopProcessingChan: // connection readRequests processing stopped, promise can be never answered return nil, nil, ErrConnectionClosed } } func (c *Connection) stopQuery(q *Query) (*Response, *Cursor, error) { if q.Type != p.Query_STOP && !c.isClosed() && !c.isBad() { stopQuery := newStopQuery(q.Token) _, _, _ = c.Query(c.contextFromConnectionOpts(), stopQuery) } return nil, nil, ErrQueryTimeout } func (c *Connection) startTracingSpan(parentSpan opentracing.Span, q *Query) opentracing.Span { span := parentSpan.Tracer().StartSpan( "Query_"+q.Type.String(), opentracing.ChildOf(parentSpan.Context()), ext.SpanKindRPCClient) ext.PeerAddress.Set(span, c.address) ext.Component.Set(span, "rethinkdb-go") if q.Type == p.Query_START { span.LogFields(log.String("query", q.Term.String())) } return span } func (c *Connection) readSocket() { for { response, err := c.readResponse() c.responseChan <- responseAndError{ response: response, err: err, } select { case <-c.stopReadChan: close(c.responseChan) return default: } } } func (c *Connection) processResponses() { readRequests := make([]tokenAndPromise, 0, 16) responses := make([]*Response, 0, 16) for { var response *Response var readRequest tokenAndPromise var ok bool select { case respPair, openned := <-c.responseChan: if respPair.err != nil { // Transport socket error, can't continue to work // Don't know return to who (no token) - return to all broadcastError(readRequests, respPair.err) readRequests = []tokenAndPromise{} _ = c.Close() // next `if` will be called indirect cascade by closing chans continue } if !openned { // responseChan is connClosed (stopReadChan is closed too) close(c.stopProcessingChan) broadcastError(readRequests, ErrConnectionClosed) c.cursors = nil return } response = respPair.response readRequest, ok = getReadRequest(readRequests, respPair.response.Token) if !ok { responses = append(responses, respPair.response) continue } readRequests = removeReadRequest(readRequests, respPair.response.Token) case readRequest = <-c.readRequestsChan: response, ok = getResponse(responses, readRequest.query.Token) if !ok { readRequests = append(readRequests, readRequest) continue } responses = removeResponse(responses, readRequest.query.Token) } response, cursor, err := c.processResponse(readRequest.ctx, *readRequest.query, response, readRequest.span) if readRequest.promise != nil { readRequest.promise <- responseAndCursor{response: response, cursor: cursor, err: err} close(readRequest.promise) } } } func broadcastError(readRequests []tokenAndPromise, err error) { for _, rr := range readRequests { if rr.promise != nil { rr.promise <- responseAndCursor{err: err} close(rr.promise) } } } type ServerResponse struct { ID string `rethinkdb:"id"` Name string `rethinkdb:"name"` } // Server returns the server name and server UUID being used by a connection. func (c *Connection) Server() (ServerResponse, error) { var response ServerResponse _, cur, err := c.Query(c.contextFromConnectionOpts(), Query{ Type: p.Query_SERVER_INFO, }) if err != nil { return response, err } if err = cur.One(&response); err != nil { return response, err } if err = cur.Close(); err != nil { return response, err } return response, nil } // sendQuery marshals the Query and sends the JSON to the server. func (c *Connection) sendQuery(q Query) error { buf := &bytes.Buffer{} buf.Grow(respHeaderLen) buf.Write(buf.Bytes()[:respHeaderLen]) // reserve for header enc := json.NewEncoder(buf) // Build query err := enc.Encode(q.Build()) if err != nil { return RQLDriverError{rqlError(fmt.Sprintf("Error building query: %s", err.Error()))} } b := buf.Bytes() // Write header binary.LittleEndian.PutUint64(b, uint64(q.Token)) binary.LittleEndian.PutUint32(b[8:], uint32(len(b)-respHeaderLen)) // Send the JSON encoding of the query itself. if err = c.writeData(b); err != nil { c.setBad() return RQLConnectionError{rqlError(err.Error())} } return nil } // getToken generates the next query token, used to number requests and match // responses with requests. func (c *Connection) nextToken() int64 { // requires c.token to be 64-bit aligned on ARM return atomic.AddInt64(&c.token, 1) } // readResponse attempts to read a Response from the server, if no response // could be read then an error is returned. func (c *Connection) readResponse() (*Response, error) { // due to this is pooled connection, it always reads from socket even if idle // timeouts should be only on query-level with context // Read response header (token+length) headerBuf := [respHeaderLen]byte{} if _, err := c.read(headerBuf[:]); err != nil { c.setBad() return nil, RQLConnectionError{rqlError(err.Error())} } responseToken := int64(binary.LittleEndian.Uint64(headerBuf[:8])) messageLength := binary.LittleEndian.Uint32(headerBuf[8:]) // Read the JSON encoding of the Response itself. b := make([]byte, int(messageLength)) if _, err := c.read(b); err != nil { c.setBad() return nil, RQLConnectionError{rqlError(err.Error())} } // Decode the response var response = new(Response) if err := json.Unmarshal(b, response); err != nil { c.setBad() return nil, RQLDriverError{rqlError(err.Error())} } response.Token = responseToken return response, nil } // Called to fill response for the query func (c *Connection) processResponse(ctx context.Context, q Query, response *Response, span opentracing.Span) (r *Response, cur *Cursor, err error) { if span != nil { defer func() { if err != nil { ext.Error.Set(span, true) span.LogFields(log.Error(err)) } span.Finish() }() } switch response.Type { case p.Response_CLIENT_ERROR: return response, c.processErrorResponse(response), createClientError(response, q.Term) case p.Response_COMPILE_ERROR: return response, c.processErrorResponse(response), createCompileError(response, q.Term) case p.Response_RUNTIME_ERROR: return response, c.processErrorResponse(response), createRuntimeError(response.ErrorType, response, q.Term) case p.Response_SUCCESS_ATOM, p.Response_SERVER_INFO: return c.processAtomResponse(ctx, q, response) case p.Response_SUCCESS_PARTIAL: return c.processPartialResponse(ctx, q, response) case p.Response_SUCCESS_SEQUENCE: return c.processSequenceResponse(ctx, q, response) case p.Response_WAIT_COMPLETE: return c.processWaitResponse(response) default: return nil, nil, RQLDriverError{rqlError(fmt.Sprintf("Unexpected response type: %v", response.Type.String()))} } } func (c *Connection) processErrorResponse(response *Response) *Cursor { cursor := c.cursors[response.Token] delete(c.cursors, response.Token) return cursor } func (c *Connection) processAtomResponse(ctx context.Context, q Query, response *Response) (*Response, *Cursor, error) { cursor := newCursor(ctx, c, "Cursor", response.Token, q.Term, q.Opts) cursor.profile = response.Profile cursor.extend(response) return response, cursor, nil } func (c *Connection) processPartialResponse(ctx context.Context, q Query, response *Response) (*Response, *Cursor, error) { cursorType := "Cursor" if len(response.Notes) > 0 { switch response.Notes[0] { case p.Response_SEQUENCE_FEED: cursorType = "Feed" case p.Response_ATOM_FEED: cursorType = "AtomFeed" case p.Response_ORDER_BY_LIMIT_FEED: cursorType = "OrderByLimitFeed" case p.Response_UNIONED_FEED: cursorType = "UnionedFeed" case p.Response_INCLUDES_STATES: cursorType = "IncludesFeed" } } cursor, ok := c.cursors[response.Token] if !ok { // Create a new cursor if needed cursor = newCursor(ctx, c, cursorType, response.Token, q.Term, q.Opts) cursor.profile = response.Profile c.cursors[response.Token] = cursor } cursor.extend(response) return response, cursor, nil } func (c *Connection) processSequenceResponse(ctx context.Context, q Query, response *Response) (*Response, *Cursor, error) { cursor, ok := c.cursors[response.Token] if !ok { // Create a new cursor if needed cursor = newCursor(ctx, c, "Cursor", response.Token, q.Term, q.Opts) cursor.profile = response.Profile } delete(c.cursors, response.Token) cursor.extend(response) return response, cursor, nil } func (c *Connection) processWaitResponse(response *Response) (*Response, *Cursor, error) { delete(c.cursors, response.Token) return response, nil, nil } func (c *Connection) setBad() { atomic.StoreInt32(&c.bad, connBad) } func (c *Connection) isBad() bool { return atomic.LoadInt32(&c.bad) == connBad } func (c *Connection) setClosed() { atomic.StoreInt32(&c.closed, connClosed) } func (c *Connection) isClosed() bool { return atomic.LoadInt32(&c.closed) == connClosed } func getReadRequest(list []tokenAndPromise, token int64) (tokenAndPromise, bool) { for _, e := range list { if e.query.Token == token { return e, true } } return tokenAndPromise{}, false } func getResponse(list []*Response, token int64) (*Response, bool) { for _, e := range list { if e.Token == token { return e, true } } return nil, false } func removeReadRequest(list []tokenAndPromise, token int64) []tokenAndPromise { for i := range list { if list[i].query.Token == token { return append(list[:i], list[i+1:]...) } } return list } func removeResponse(list []*Response, token int64) []*Response { for i := range list { if list[i].Token == token { return append(list[:i], list[i+1:]...) } } return list } rethinkdb-go-6.2.1/connection_handshake.go000066400000000000000000000256571363464422500206210ustar00rootroot00000000000000package rethinkdb import ( "bufio" "crypto/hmac" "crypto/rand" "crypto/sha256" "encoding/base64" "encoding/binary" "encoding/json" "fmt" "hash" "io" "strconv" "strings" "golang.org/x/crypto/pbkdf2" p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" ) type HandshakeVersion int const ( HandshakeV1_0 HandshakeVersion = iota HandshakeV0_4 ) type connectionHandshake interface { Send() error } func (c *Connection) handshake(version HandshakeVersion) (connectionHandshake, error) { switch version { case HandshakeV0_4: return &connectionHandshakeV0_4{conn: c}, nil case HandshakeV1_0: return &connectionHandshakeV1_0{conn: c}, nil default: return nil, fmt.Errorf("Unrecognised handshake version") } } type connectionHandshakeV0_4 struct { conn *Connection } func (c *connectionHandshakeV0_4) Send() error { // Send handshake request if err := c.writeHandshakeReq(); err != nil { c.conn.Close() return RQLConnectionError{rqlError(err.Error())} } // Read handshake response if err := c.readHandshakeSuccess(); err != nil { c.conn.Close() return RQLConnectionError{rqlError(err.Error())} } return nil } func (c *connectionHandshakeV0_4) writeHandshakeReq() error { pos := 0 dataLen := 4 + 4 + len(c.conn.opts.AuthKey) + 4 data := make([]byte, dataLen) // Send the protocol version to the server as a 4-byte little-endian-encoded integer binary.LittleEndian.PutUint32(data[pos:], uint32(p.VersionDummy_V0_4)) pos += 4 // Send the length of the auth key to the server as a 4-byte little-endian-encoded integer binary.LittleEndian.PutUint32(data[pos:], uint32(len(c.conn.opts.AuthKey))) pos += 4 // Send the auth key as an ASCII string if len(c.conn.opts.AuthKey) > 0 { pos += copy(data[pos:], c.conn.opts.AuthKey) } // Send the protocol type as a 4-byte little-endian-encoded integer binary.LittleEndian.PutUint32(data[pos:], uint32(p.VersionDummy_JSON)) pos += 4 return c.conn.writeData(data) } func (c *connectionHandshakeV0_4) readHandshakeSuccess() error { reader := bufio.NewReader(c.conn.Conn) line, err := reader.ReadBytes('\x00') if err != nil { if err == io.EOF { return fmt.Errorf("Unexpected EOF: %s", string(line)) } return err } // convert to string and remove trailing NUL byte response := string(line[:len(line)-1]) if response != "SUCCESS" { response = strings.TrimSpace(response) // we failed authorization or something else terrible happened return RQLDriverError{rqlError(fmt.Sprintf("Server dropped connection with message: \"%s\"", response))} } return nil } const ( handshakeV1_0_protocolVersionNumber = 0 handshakeV1_0_authenticationMethod = "SCRAM-SHA-256" ) type connectionHandshakeV1_0 struct { conn *Connection reader *bufio.Reader authMsg string } func (c *connectionHandshakeV1_0) Send() error { c.reader = bufio.NewReader(c.conn.Conn) // Generate client nonce clientNonce, err := c.generateNonce() if err != nil { c.conn.Close() return RQLDriverError{rqlError(fmt.Sprintf("Failed to generate client nonce: %s", err))} } // Send client first message if err := c.writeFirstMessage(clientNonce); err != nil { c.conn.Close() return err } // Read status if err := c.checkServerVersions(); err != nil { c.conn.Close() return err } // Read server first message i, salt, serverNonce, err := c.readFirstMessage() if err != nil { c.conn.Close() return err } // Check server nonce if !strings.HasPrefix(serverNonce, clientNonce) { return RQLAuthError{RQLDriverError{rqlError("Invalid nonce from server")}} } // Generate proof saltedPass := c.saltPassword(i, salt) clientProof := c.calculateProof(saltedPass, clientNonce, serverNonce) serverSignature := c.serverSignature(saltedPass) // Send client final message if err := c.writeFinalMessage(serverNonce, clientProof); err != nil { c.conn.Close() return err } // Read server final message if err := c.readFinalMessage(serverSignature); err != nil { c.conn.Close() return err } return nil } func (c *connectionHandshakeV1_0) writeFirstMessage(clientNonce string) error { // Default username to admin if not set username := "admin" if c.conn.opts.Username != "" { username = c.conn.opts.Username } c.authMsg = fmt.Sprintf("n=%s,r=%s", username, clientNonce) msg := fmt.Sprintf( `{"protocol_version": %d,"authentication": "n,,%s","authentication_method": "%s"}`, handshakeV1_0_protocolVersionNumber, c.authMsg, handshakeV1_0_authenticationMethod, ) pos := 0 dataLen := 4 + len(msg) + 1 data := make([]byte, dataLen) // Send the protocol version to the server as a 4-byte little-endian-encoded integer binary.LittleEndian.PutUint32(data[pos:], uint32(p.VersionDummy_V1_0)) pos += 4 // Send the auth message as an ASCII string pos += copy(data[pos:], msg) // Add null terminating byte data[pos] = '\x00' return c.writeData(data) } func (c *connectionHandshakeV1_0) checkServerVersions() error { b, err := c.readResponse() if err != nil { return err } // Read status type versionsResponse struct { Success bool `json:"success"` MinProtocolVersion int `json:"min_protocol_version"` MaxProtocolVersion int `json:"max_protocol_version"` ServerVersion string `json:"server_version"` ErrorCode int `json:"error_code"` Error string `json:"error"` } var rsp *versionsResponse statusStr := string(b) if err := json.Unmarshal(b, &rsp); err != nil { if strings.HasPrefix(statusStr, "ERROR: ") { statusStr = strings.TrimPrefix(statusStr, "ERROR: ") return RQLConnectionError{rqlError(statusStr)} } return RQLDriverError{rqlError(fmt.Sprintf("Error reading versions: %s", err))} } if !rsp.Success { return c.handshakeError(rsp.ErrorCode, rsp.Error) } if rsp.MinProtocolVersion > handshakeV1_0_protocolVersionNumber || rsp.MaxProtocolVersion < handshakeV1_0_protocolVersionNumber { return RQLDriverError{rqlError( fmt.Sprintf( "Unsupported protocol version %d, expected between %d and %d.", handshakeV1_0_protocolVersionNumber, rsp.MinProtocolVersion, rsp.MaxProtocolVersion, ), )} } return nil } func (c *connectionHandshakeV1_0) readFirstMessage() (i int64, salt []byte, serverNonce string, err error) { b, err2 := c.readResponse() if err2 != nil { err = err2 return } // Read server message type firstMessageResponse struct { Success bool `json:"success"` Authentication string `json:"authentication"` ErrorCode int `json:"error_code"` Error string `json:"error"` } var rsp *firstMessageResponse if err2 := json.Unmarshal(b, &rsp); err2 != nil { err = RQLDriverError{rqlError(fmt.Sprintf("Error parsing auth response: %s", err2))} return } if !rsp.Success { err = c.handshakeError(rsp.ErrorCode, rsp.Error) return } c.authMsg += "," c.authMsg += rsp.Authentication // Parse authentication field auth := map[string]string{} parts := strings.Split(rsp.Authentication, ",") for _, part := range parts { i := strings.Index(part, "=") if i != -1 { auth[part[:i]] = part[i+1:] } } // Extract return values if v, ok := auth["i"]; ok { i, err = strconv.ParseInt(v, 10, 64) if err != nil { return } } if v, ok := auth["s"]; ok { salt, err = base64.StdEncoding.DecodeString(v) if err != nil { return } } if v, ok := auth["r"]; ok { serverNonce = v } return } func (c *connectionHandshakeV1_0) writeFinalMessage(serverNonce, clientProof string) error { authMsg := "c=biws,r=" authMsg += serverNonce authMsg += ",p=" authMsg += clientProof msg := fmt.Sprintf(`{"authentication": "%s"}`, authMsg) pos := 0 dataLen := len(msg) + 1 data := make([]byte, dataLen) // Send the auth message as an ASCII string pos += copy(data[pos:], msg) // Add null terminating byte data[pos] = '\x00' return c.writeData(data) } func (c *connectionHandshakeV1_0) readFinalMessage(serverSignature string) error { b, err := c.readResponse() if err != nil { return err } // Read server message type finalMessageResponse struct { Success bool `json:"success"` Authentication string `json:"authentication"` ErrorCode int `json:"error_code"` Error string `json:"error"` } var rsp *finalMessageResponse if err := json.Unmarshal(b, &rsp); err != nil { return RQLDriverError{rqlError(fmt.Sprintf("Error parsing auth response: %s", err))} } if !rsp.Success { return c.handshakeError(rsp.ErrorCode, rsp.Error) } // Parse authentication field auth := map[string]string{} parts := strings.Split(rsp.Authentication, ",") for _, part := range parts { i := strings.Index(part, "=") if i != -1 { auth[part[:i]] = part[i+1:] } } // Validate server response if serverSignature != auth["v"] { return RQLAuthError{RQLDriverError{rqlError("Invalid server signature")}} } return nil } func (c *connectionHandshakeV1_0) writeData(data []byte) error { if err := c.conn.writeData(data); err != nil { return RQLConnectionError{rqlError(err.Error())} } return nil } func (c *connectionHandshakeV1_0) readResponse() ([]byte, error) { line, err := c.reader.ReadBytes('\x00') if err != nil { if err == io.EOF { return nil, RQLConnectionError{rqlError(fmt.Sprintf("Unexpected EOF: %s", string(line)))} } return nil, RQLConnectionError{rqlError(err.Error())} } // Strip null byte and return return line[:len(line)-1], nil } func (c *connectionHandshakeV1_0) generateNonce() (string, error) { const nonceSize = 24 b := make([]byte, nonceSize) _, err := rand.Read(b) if err != nil { return "", err } return base64.StdEncoding.EncodeToString(b), nil } func (c *connectionHandshakeV1_0) saltPassword(iter int64, salt []byte) []byte { pass := []byte(c.conn.opts.Password) return pbkdf2.Key(pass, salt, int(iter), sha256.Size, sha256.New) } func (c *connectionHandshakeV1_0) calculateProof(saltedPass []byte, clientNonce, serverNonce string) string { // Generate proof c.authMsg += ",c=biws,r=" + serverNonce mac := hmac.New(c.hashFunc(), saltedPass) mac.Write([]byte("Client Key")) clientKey := mac.Sum(nil) hash := c.hashFunc()() hash.Write(clientKey) storedKey := hash.Sum(nil) mac = hmac.New(c.hashFunc(), storedKey) mac.Write([]byte(c.authMsg)) clientSignature := mac.Sum(nil) clientProof := make([]byte, len(clientKey)) for i, _ := range clientKey { clientProof[i] = clientKey[i] ^ clientSignature[i] } return base64.StdEncoding.EncodeToString(clientProof) } func (c *connectionHandshakeV1_0) serverSignature(saltedPass []byte) string { mac := hmac.New(c.hashFunc(), saltedPass) mac.Write([]byte("Server Key")) serverKey := mac.Sum(nil) mac = hmac.New(c.hashFunc(), serverKey) mac.Write([]byte(c.authMsg)) serverSignature := mac.Sum(nil) return base64.StdEncoding.EncodeToString(serverSignature) } func (c *connectionHandshakeV1_0) handshakeError(code int, message string) error { if code >= 10 || code <= 20 { return RQLAuthError{RQLDriverError{rqlError(message)}} } return RQLDriverError{rqlError(message)} } func (c *connectionHandshakeV1_0) hashFunc() func() hash.Hash { return sha256.New } rethinkdb-go-6.2.1/connection_helper.go000066400000000000000000000011151363464422500201310ustar00rootroot00000000000000package rethinkdb import ( "golang.org/x/net/context" "io" ) // Write 'data' to conn func (c *Connection) writeData(data []byte) error { _, err := c.Conn.Write(data[:]) return err } func (c *Connection) read(buf []byte) (total int, err error) { return io.ReadFull(c.Conn, buf) } func (c *Connection) contextFromConnectionOpts() context.Context { // back compatibility min := c.opts.ReadTimeout if c.opts.WriteTimeout < min { min = c.opts.WriteTimeout } if min == 0 { return context.Background() } ctx, _ := context.WithTimeout(context.Background(), min) return ctx } rethinkdb-go-6.2.1/connection_test.go000066400000000000000000000451201363464422500176350ustar00rootroot00000000000000package rethinkdb import ( "encoding/binary" "encoding/json" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" "github.com/stretchr/testify/mock" "golang.org/x/net/context" test "gopkg.in/check.v1" p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" "io" "sync" "time" ) func runConnection(c *Connection) <-chan struct{} { wg := &sync.WaitGroup{} wg.Add(2) go func() { c.readSocket() wg.Done() }() go func() { c.processResponses() wg.Done() }() doneChan := make(chan struct{}) go func() { wg.Wait() close(doneChan) }() return doneChan } type ConnectionSuite struct{} var _ = test.Suite(&ConnectionSuite{}) func (s *ConnectionSuite) TestConnection_Query_Ok(c *test.C) { ctx := context.Background() token := int64(1) q := testQuery(DB("db").Table("table").Get("id")) writeData := serializeQuery(token, q) respData := serializeAtomResponse() header := respHeader(token, respData) conn := &connMock{} conn.On("Write", writeData).Return(len(writeData), nil, nil) conn.On("Read", respHeaderLen).Return(header, respHeaderLen, nil, nil) conn.On("Read", len(respData)).Return(respData, len(respData), nil, nil) conn.On("Close").Return(nil) connection := newConnection(conn, "addr", &ConnectOpts{}) closed := runConnection(connection) response, cursor, err := connection.Query(ctx, q) connection.Close() <-closed c.Assert(response, test.NotNil) c.Assert(response.Token, test.Equals, token) c.Assert(response.Type, test.Equals, p.Response_SUCCESS_ATOM) c.Assert(response.Responses, test.HasLen, 1) c.Assert(response.Responses[0], test.DeepEquals, json.RawMessage([]byte(`"response"`))) c.Assert(cursor, test.NotNil) c.Assert(cursor.token, test.Equals, token) c.Assert(cursor.conn, test.Equals, connection) c.Assert(cursor.ctx, test.Equals, ctx) c.Assert(cursor.responses, test.DeepEquals, response.Responses) c.Assert(err, test.IsNil) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_Query_DefaultDBOk(c *test.C) { ctx := context.Background() token := int64(1) q := testQuery(Table("table").Get("id")) q2 := q q2.Opts["db"], _ = DB("db").Build() writeData := serializeQuery(token, q2) respData := serializeAtomResponse() header := respHeader(token, respData) conn := &connMock{} conn.On("Write", writeData).Return(len(writeData), nil, nil) conn.On("Read", respHeaderLen).Return(header, respHeaderLen, nil, nil) conn.On("Read", len(respData)).Return(respData, len(respData), nil, nil) conn.On("Close").Return(nil) connection := newConnection(conn, "addr", &ConnectOpts{Database: "db"}) done := runConnection(connection) response, cursor, err := connection.Query(ctx, q) connection.Close() <-done c.Assert(response, test.NotNil) c.Assert(response.Token, test.Equals, token) c.Assert(response.Type, test.Equals, p.Response_SUCCESS_ATOM) c.Assert(response.Responses, test.HasLen, 1) c.Assert(response.Responses[0], test.DeepEquals, json.RawMessage([]byte(`"response"`))) c.Assert(cursor, test.NotNil) c.Assert(cursor.token, test.Equals, token) c.Assert(cursor.conn, test.Equals, connection) c.Assert(cursor.ctx, test.Equals, ctx) c.Assert(cursor.responses, test.DeepEquals, response.Responses) c.Assert(err, test.IsNil) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_Query_Nil(c *test.C) { response, cursor, err := (*Connection)(nil).Query(nil, Query{}) c.Assert(err, test.Equals, ErrConnectionClosed) c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) } func (s *ConnectionSuite) TestConnection_Query_NilConn(c *test.C) { connection := newConnection(nil, "addr", &ConnectOpts{Database: "db"}) response, cursor, err := connection.Query(nil, Query{}) c.Assert(err, test.Equals, ErrConnectionClosed) c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) } func (s *ConnectionSuite) TestConnection_Query_SendFail(c *test.C) { ctx := context.Background() token := int64(1) q := testQuery(DB("db").Table("table").Get("id")) writeData := serializeQuery(token, q) conn := &connMock{} conn.On("Write", writeData).Return(0, io.EOF, nil) connection := newConnection(conn, "addr", &ConnectOpts{}) response, cursor, err := connection.Query(ctx, q) c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) c.Assert(err, test.Equals, RQLConnectionError{rqlError(io.EOF.Error())}) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_Query_NoReplyOk(c *test.C) { token := int64(1) q := testQuery(DB("db").Table("table").Get("id")) q.Opts["noreply"] = true writeData := serializeQuery(token, q) respData := serializeAtomResponse() header := respHeader(token, respData) conn := &connMock{} conn.On("Write", writeData).Return(len(writeData), nil, nil) conn.On("Read", respHeaderLen).Return(header, respHeaderLen, nil, nil) conn.On("Read", len(respData)).Return(respData, len(respData), nil, nil) conn.On("Close").Return(nil) connection := newConnection(conn, "addr", &ConnectOpts{}) done := runConnection(connection) response, cursor, err := connection.Query(nil, q) connection.Close() <-done c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) c.Assert(err, test.IsNil) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_Query_TimeoutWrite(c *test.C) { ctx, cancel := context.WithCancel(context.Background()) token := int64(1) q := testQuery(DB("db").Table("table").Get("id")) writeData := serializeQuery(token, q) stopData := serializeQuery(token, newStopQuery(token)) conn := &connMock{} conn.On("Write", writeData).Return(len(writeData), nil, nil) conn.On("Write", stopData).Return(len(stopData), nil, nil) connection := newConnection(conn, "addr", &ConnectOpts{ReadTimeout: time.Millisecond, WriteTimeout: time.Millisecond}) connection.readRequestsChan = make(chan tokenAndPromise, 0) cancel() response, cursor, err := connection.Query(ctx, q) c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) c.Assert(err, test.Equals, ErrQueryTimeout) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_Query_TimeoutRead(c *test.C) { ctx, _ := context.WithTimeout(context.Background(), 5*time.Millisecond) token := int64(1) q := testQuery(DB("db").Table("table").Get("id")) writeData := serializeQuery(token, q) stopData := serializeQuery(token, newStopQuery(token)) conn := &connMock{} conn.On("Write", writeData).Return(len(writeData), nil, 10*time.Millisecond) conn.On("Write", stopData).Return(len(stopData), nil, nil) connection := newConnection(conn, "addr", &ConnectOpts{ReadTimeout: time.Millisecond, WriteTimeout: time.Millisecond}) response, cursor, err := connection.Query(ctx, q) c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) c.Assert(err, test.Equals, ErrQueryTimeout) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_Query_SendFailTracing(c *test.C) { tracer := mocktracer.New() rootSpan := tracer.StartSpan("root") ctx := opentracing.ContextWithSpan(context.Background(), rootSpan) token := int64(1) q := testQuery(DB("db").Table("table").Get("id")) writeData := serializeQuery(token, q) conn := &connMock{} conn.On("Write", writeData).Return(0, io.EOF, nil) connection := newConnection(conn, "addr", &ConnectOpts{UseOpentracing: true}) response, cursor, err := connection.Query(ctx, q) c.Assert(response, test.IsNil) c.Assert(cursor, test.IsNil) c.Assert(err, test.Equals, RQLConnectionError{rqlError(io.EOF.Error())}) conn.AssertExpectations(c) c.Assert(tracer.FinishedSpans(), test.HasLen, 2) } func (s *ConnectionSuite) TestConnection_processResponses_SocketErr(c *test.C) { promise1 := make(chan responseAndCursor, 1) promise2 := make(chan responseAndCursor, 1) promise3 := make(chan responseAndCursor, 1) conn := &connMock{} connection := newConnection(conn, "addr", &ConnectOpts{}) conn.On("Close").Return(nil).Run(func(args mock.Arguments) { close(connection.responseChan) }) done := make(chan struct{}) go func() { connection.processResponses() close(done) }() connection.readRequestsChan <- tokenAndPromise{query: &Query{Token: 1}, promise: promise1} connection.readRequestsChan <- tokenAndPromise{query: &Query{Token: 2}, promise: promise2} connection.readRequestsChan <- tokenAndPromise{query: &Query{Token: 2}, promise: promise3} time.Sleep(5 * time.Millisecond) connection.responseChan <- responseAndError{err: io.EOF} <-done select { case f := <-promise1: c.Assert(f.err, test.Equals, io.EOF) c.Assert(f.response, test.IsNil) default: c.Fail() } select { case f := <-promise2: c.Assert(f.err, test.Equals, io.EOF) c.Assert(f.response, test.IsNil) default: c.Fail() } select { case f := <-promise3: c.Assert(f.err, test.Equals, io.EOF) c.Assert(f.response, test.IsNil) default: c.Fail() } conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_processResponses_StopOk(c *test.C) { promise1 := make(chan responseAndCursor, 1) connection := newConnection(nil, "addr", &ConnectOpts{}) done := make(chan struct{}) go func() { connection.processResponses() close(done) }() connection.readRequestsChan <- tokenAndPromise{query: &Query{Token: 1}, promise: promise1} time.Sleep(5 * time.Millisecond) close(connection.responseChan) <-done select { case f := <-promise1: c.Assert(f.err, test.Equals, ErrConnectionClosed) c.Assert(f.response, test.IsNil) default: c.Fail() } } func (s *ConnectionSuite) TestConnection_processResponses_ResponseFirst(c *test.C) { promise1 := make(chan responseAndCursor, 1) response1 := &Response{Token: 1, Type: p.Response_RUNTIME_ERROR, ErrorType: p.Response_INTERNAL} conn := &connMock{} conn.On("Close").Return(nil) connection := newConnection(conn, "addr", &ConnectOpts{}) go connection.processResponses() connection.responseChan <- responseAndError{response: response1} time.Sleep(5 * time.Millisecond) connection.readRequestsChan <- tokenAndPromise{query: &Query{Token: 1}, promise: promise1} time.Sleep(5 * time.Millisecond) connection.Close() time.Sleep(5 * time.Millisecond) select { case f := <-promise1: c.Assert(f.err, test.FitsTypeOf, RQLInternalError{}) c.Assert(f.response, test.Equals, response1) c.Assert(f.cursor, test.IsNil) default: c.Fail() } conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_readResponse_TimeoutHeader(c *test.C) { timeout := time.Second conn := &connMock{} conn.On("Read", respHeaderLen).Return(nil, 0, io.EOF, nil) connection := newConnection(conn, "addr", &ConnectOpts{ReadTimeout: timeout}) response, err := connection.readResponse() c.Assert(response, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLConnectionError{}) c.Assert(connection.isBad(), test.Equals, true) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_readResponse_BodySocketErr(c *test.C) { token := int64(5) respData := serializeAtomResponse() header := respHeader(token, respData) conn := &connMock{} conn.On("Read", respHeaderLen).Return(header, len(header), nil, nil) conn.On("Read", len(respData)).Return(nil, 0, io.EOF, nil) connection := newConnection(conn, "addr", &ConnectOpts{}) response, err := connection.readResponse() c.Assert(response, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLConnectionError{}) c.Assert(connection.isBad(), test.Equals, true) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_readResponse_BodyUnmarshalErr(c *test.C) { token := int64(5) respData := serializeAtomResponse() header := respHeader(token, respData) conn := &connMock{} conn.On("Read", respHeaderLen).Return(header, len(header), nil, nil) conn.On("Read", len(respData)).Return(make([]byte, len(respData)), len(respData), nil, nil) connection := newConnection(conn, "addr", &ConnectOpts{}) response, err := connection.readResponse() c.Assert(response, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLDriverError{}) c.Assert(connection.isBad(), test.Equals, true) conn.AssertExpectations(c) } func (s *ConnectionSuite) TestConnection_processResponse_ClientErrOk(c *test.C) { ctx := context.Background() token := int64(3) q := Query{Token: token} response := &Response{Token: token, Type: p.Response_CLIENT_ERROR} connection := newConnection(nil, "addr", &ConnectOpts{}) resp, cursor, err := connection.processResponse(ctx, q, response, nil) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLClientError{}) } func (s *ConnectionSuite) TestConnection_processResponse_CompileErrOk(c *test.C) { ctx := context.Background() token := int64(3) q := Query{Token: token} response := &Response{Token: token, Type: p.Response_COMPILE_ERROR} connection := newConnection(nil, "addr", &ConnectOpts{}) resp, cursor, err := connection.processResponse(ctx, q, response, nil) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLCompileError{}) } func (s *ConnectionSuite) TestConnection_processResponse_RuntimeErrOk(c *test.C) { tracer := mocktracer.New() rootSpan := tracer.StartSpan("root") ctx := opentracing.ContextWithSpan(context.Background(), rootSpan) qSpan := rootSpan.Tracer().StartSpan("q", opentracing.ChildOf(rootSpan.Context())) token := int64(3) term := Table("test") q := Query{Token: token, Term: &term} response := &Response{Token: token, Type: p.Response_RUNTIME_ERROR, Responses: []json.RawMessage{{'e', 'r', 'r'}}} connection := newConnection(nil, "addr", &ConnectOpts{}) resp, cursor, err := connection.processResponse(ctx, q, response, qSpan) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLRuntimeError{}) c.Assert(tracer.FinishedSpans(), test.HasLen, 1) c.Assert(tracer.FinishedSpans()[0].Tags()["error"], test.Equals, true) } func (s *ConnectionSuite) TestConnection_processResponse_FirstPartialOk(c *test.C) { ctx := context.Background() token := int64(3) q := Query{Token: token} rawResponse1 := json.RawMessage{1, 2, 3} rawResponse2 := json.RawMessage{3, 4, 5} response := &Response{Token: token, Type: p.Response_SUCCESS_PARTIAL, Responses: []json.RawMessage{rawResponse1, rawResponse2}} connection := newConnection(nil, "addr", &ConnectOpts{}) resp, cursor, err := connection.processResponse(ctx, q, response, nil) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.NotNil) c.Assert(cursor.token, test.Equals, token) c.Assert(cursor.ctx, test.Equals, ctx) c.Assert(cursor.responses, test.HasLen, 2) c.Assert(cursor.responses[0], test.DeepEquals, rawResponse1) c.Assert(cursor.responses[1], test.DeepEquals, rawResponse2) c.Assert(cursor.conn, test.Equals, connection) c.Assert(err, test.IsNil) c.Assert(connection.cursors, test.HasLen, 1) c.Assert(connection.cursors[token], test.Equals, cursor) } func (s *ConnectionSuite) TestConnection_processResponse_PartialOk(c *test.C) { ctx := context.Background() token := int64(3) term := Table("test") q := Query{Token: token} rawResponse1 := json.RawMessage{1, 2, 3} rawResponse2 := json.RawMessage{3, 4, 5} response := &Response{Token: token, Type: p.Response_SUCCESS_PARTIAL, Responses: []json.RawMessage{rawResponse1, rawResponse2}} connection := newConnection(nil, "addr", &ConnectOpts{}) oldCursor := newCursor(ctx, connection, "Cursor", token, &term, q.Opts) connection.cursors[token] = oldCursor resp, cursor, err := connection.processResponse(ctx, q, response, nil) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.Equals, oldCursor) c.Assert(cursor.responses, test.HasLen, 2) c.Assert(cursor.responses[0], test.DeepEquals, rawResponse1) c.Assert(cursor.responses[1], test.DeepEquals, rawResponse2) c.Assert(err, test.IsNil) c.Assert(connection.cursors, test.HasLen, 1) c.Assert(connection.cursors[token], test.Equals, cursor) } func (s *ConnectionSuite) TestConnection_processResponse_SequenceOk(c *test.C) { tracer := mocktracer.New() rootSpan := tracer.StartSpan("root") ctx := opentracing.ContextWithSpan(context.Background(), rootSpan) qSpan := rootSpan.Tracer().StartSpan("q", opentracing.ChildOf(rootSpan.Context())) token := int64(3) q := Query{Token: token} rawResponse1 := json.RawMessage{1, 2, 3} rawResponse2 := json.RawMessage{3, 4, 5} response := &Response{Token: token, Type: p.Response_SUCCESS_SEQUENCE, Responses: []json.RawMessage{rawResponse1, rawResponse2}} connection := newConnection(nil, "addr", &ConnectOpts{}) resp, cursor, err := connection.processResponse(ctx, q, response, qSpan) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.NotNil) c.Assert(cursor.token, test.Equals, token) c.Assert(cursor.ctx, test.Equals, ctx) c.Assert(cursor.responses, test.HasLen, 2) c.Assert(cursor.responses[0], test.DeepEquals, rawResponse1) c.Assert(cursor.responses[1], test.DeepEquals, rawResponse2) c.Assert(cursor.conn, test.Equals, connection) c.Assert(err, test.IsNil) c.Assert(connection.cursors, test.HasLen, 0) c.Assert(tracer.FinishedSpans(), test.HasLen, 1) c.Assert(tracer.FinishedSpans()[0].Tags(), test.HasLen, 0) } func (s *ConnectionSuite) TestConnection_processResponse_WaitOk(c *test.C) { ctx := context.Background() token := int64(3) q := Query{Token: token} response := &Response{Token: token, Type: p.Response_WAIT_COMPLETE} connection := newConnection(nil, "addr", &ConnectOpts{}) connection.cursors[token] = &Cursor{} resp, cursor, err := connection.processResponse(ctx, q, response, nil) c.Assert(resp, test.Equals, response) c.Assert(cursor, test.IsNil) c.Assert(err, test.IsNil) c.Assert(connection.cursors, test.HasLen, 0) } func (s *ConnectionSuite) TestConnection_processResponse_UnexpectedOk(c *test.C) { ctx := context.Background() token := int64(3) q := Query{Token: token} response := &Response{Token: token, Type: 99} connection := newConnection(nil, "addr", &ConnectOpts{}) resp, cursor, err := connection.processResponse(ctx, q, response, nil) c.Assert(resp, test.IsNil) c.Assert(cursor, test.IsNil) c.Assert(err, test.FitsTypeOf, RQLDriverError{}) } func testQuery(t Term) Query { q, _ := newQuery( t, map[string]interface{}{}, &ConnectOpts{}, ) return q } func respHeader(token int64, msg []byte) []byte { header := [respHeaderLen]byte{} binary.LittleEndian.PutUint64(header[:], uint64(token)) binary.LittleEndian.PutUint32(header[8:], uint32(len(msg))) return header[:] } func serializeQuery(token int64, q Query) []byte { b, _ := json.Marshal(q.Build()) msg := make([]byte, len(b)+respHeaderLen+1) binary.LittleEndian.PutUint64(msg, uint64(token)) binary.LittleEndian.PutUint32(msg[8:], uint32(len(b)+1)) copy(msg[respHeaderLen:], b) msg[len(msg)-1] = '\n' // encoder.Marshal do this, json.Marshal doesn't return msg } func serializeAtomResponse() []byte { b, _ := json.Marshal(map[string]interface{}{ "t": p.Response_SUCCESS_ATOM, "r": []interface{}{"response"}, }) return b } rethinkdb-go-6.2.1/cursor.go000066400000000000000000000370741363464422500157650ustar00rootroot00000000000000package rethinkdb import ( "bytes" "encoding/json" "errors" "reflect" "sync" "github.com/opentracing/opentracing-go" "golang.org/x/net/context" "gopkg.in/rethinkdb/rethinkdb-go.v6/encoding" p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" ) var ( errNilCursor = errors.New("cursor is nil") errCursorClosed = errors.New("connection connClosed, cannot read cursor") ) func newCursor(ctx context.Context, conn *Connection, cursorType string, token int64, term *Term, opts map[string]interface{}) *Cursor { if cursorType == "" { cursorType = "Cursor" } connOpts := &ConnectOpts{} if conn != nil { connOpts = conn.opts } cursor := &Cursor{ conn: conn, connOpts: connOpts, token: token, cursorType: cursorType, term: term, opts: opts, buffer: make([]interface{}, 0), responses: make([]json.RawMessage, 0), ctx: ctx, } return cursor } // Cursor is the result of a query. Its cursor starts before the first row // of the result set. A Cursor is not thread safe and should only be accessed // by a single goroutine at any given time. Use Next to advance through the // rows: // // cursor, err := query.Run(session) // ... // defer cursor.Close() // // var response interface{} // for cursor.Next(&response) { // ... // } // err = cursor.Err() // get any error encountered during iteration // ... type Cursor struct { releaseConn func() error conn *Connection connOpts *ConnectOpts token int64 cursorType string term *Term opts map[string]interface{} ctx context.Context mu sync.RWMutex lastErr error fetching bool closed bool finished bool isAtom bool isSingleValue bool pendingSkips int buffer []interface{} responses []json.RawMessage profile interface{} } // Profile returns the information returned from the query profiler. func (c *Cursor) Profile() interface{} { if c == nil { return nil } c.mu.RLock() defer c.mu.RUnlock() return c.profile } // Type returns the cursor type (by default "Cursor") func (c *Cursor) Type() string { if c == nil { return "Cursor" } c.mu.RLock() defer c.mu.RUnlock() return c.cursorType } // Err returns nil if no errors happened during iteration, or the actual // error otherwise. func (c *Cursor) Err() error { if c == nil { return errNilCursor } c.mu.RLock() defer c.mu.RUnlock() return c.lastErr } // Close closes the cursor, preventing further enumeration. If the end is // encountered, the cursor is connClosed automatically. Close is idempotent. func (c *Cursor) Close() error { if c == nil { return errNilCursor } c.mu.Lock() defer c.mu.Unlock() var err error // If cursor is already connClosed return immediately closed := c.closed if closed { return nil } // Get connection and check its valid, don't need to lock as this is only // set when the cursor is created conn := c.conn if conn == nil { return nil } if conn.isClosed() { return nil } // Stop any unfinished queries if !c.finished { _, _, err = conn.Query(c.ctx, newStopQuery(c.token)) } if c.releaseConn != nil { if err := c.releaseConn(); err != nil { return err } } if span := opentracing.SpanFromContext(c.ctx); span != nil { span.Finish() } c.closed = true c.conn = nil c.buffer = nil c.responses = nil return err } // Next retrieves the next document from the result set, blocking if necessary. // This method will also automatically retrieve another batch of documents from // the server when the current one is exhausted, or before that in background // if possible. // // Next returns true if a document was successfully unmarshalled onto result, // and false at the end of the result set or if an error happened. // When Next returns false, the Err method should be called to verify if // there was an error during iteration. // // Also note that you are able to reuse the same variable multiple times as // `Next` zeroes the value before scanning in the result. func (c *Cursor) Next(dest interface{}) bool { if c == nil { return false } c.mu.Lock() if c.closed { c.mu.Unlock() return false } hasMore, err := c.nextLocked(dest, true) if c.handleErrorLocked(err) != nil { c.mu.Unlock() c.Close() return false } c.mu.Unlock() if !hasMore { c.Close() } return hasMore } func (c *Cursor) nextLocked(dest interface{}, progressCursor bool) (bool, error) { for { if err := c.seekCursor(true); err != nil { return false, err } if c.closed { return false, nil } if len(c.buffer) == 0 && c.finished { return false, nil } if len(c.buffer) > 0 { data := c.buffer[0] if progressCursor { c.buffer = c.buffer[1:] } err := encoding.Decode(dest, data) if err != nil { return false, err } return true, nil } } } // Peek behaves similarly to Next, retreiving the next document from the result set // and blocking if necessary. Peek, however, does not progress the position of the cursor. // This can be useful for expressions which can return different types to attempt to // decode them into different interfaces. // // Like Next, it will also automatically retrieve another batch of documents from // the server when the current one is exhausted, or before that in background // if possible. // // Unlike Next, Peek does not progress the position of the cursor. Peek // will return errors from decoding, but they will not be persisted in the cursor // and therefore will not be available on cursor.Err(). This can be useful for // expressions that can return different types to attempt to decode them into // different interfaces. // // Peek returns true if a document was successfully unmarshalled onto result, // and false at the end of the result set or if an error happened. Peek also // returns the error (if any) that occured func (c *Cursor) Peek(dest interface{}) (bool, error) { if c == nil { return false, errNilCursor } c.mu.Lock() if c.closed { c.mu.Unlock() return false, nil } hasMore, err := c.nextLocked(dest, false) if _, isDecodeErr := err.(*encoding.DecodeTypeError); isDecodeErr { c.mu.Unlock() return false, err } if c.handleErrorLocked(err) != nil { c.mu.Unlock() c.Close() return false, err } c.mu.Unlock() return hasMore, nil } // Skip progresses the cursor by one record. It is useful after a successful // Peek to avoid duplicate decoding work. func (c *Cursor) Skip() { if c == nil { return } c.mu.Lock() defer c.mu.Unlock() c.pendingSkips++ } // NextResponse retrieves the next raw response from the result set, blocking if necessary. // Unlike Next the returned response is the raw JSON document returned from the // database. // // NextResponse returns false (and a nil byte slice) at the end of the result // set or if an error happened. func (c *Cursor) NextResponse() ([]byte, bool) { if c == nil { return nil, false } c.mu.Lock() if c.closed { c.mu.Unlock() return nil, false } b, hasMore, err := c.nextResponseLocked() if c.handleErrorLocked(err) != nil { c.mu.Unlock() c.Close() return nil, false } c.mu.Unlock() if !hasMore { c.Close() } return b, hasMore } func (c *Cursor) nextResponseLocked() ([]byte, bool, error) { for { if err := c.seekCursor(false); err != nil { return nil, false, err } if len(c.responses) == 0 && c.finished { return nil, false, nil } if len(c.responses) > 0 { var response json.RawMessage response, c.responses = c.responses[0], c.responses[1:] return []byte(response), true, nil } } } // All retrieves all documents from the result set into the provided slice // and closes the cursor. // // The result argument must necessarily be the address for a slice. The slice // may be nil or previously allocated. // // Also note that you are able to reuse the same variable multiple times as // `All` zeroes the value before scanning in the result. It also attempts // to reuse the existing slice without allocating any more space by either // resizing or returning a selection of the slice if necessary. func (c *Cursor) All(result interface{}) error { if c == nil { return errNilCursor } resultv := reflect.ValueOf(result) if resultv.Kind() != reflect.Ptr || resultv.Elem().Kind() != reflect.Slice { panic("result argument must be a slice address") } slicev := resultv.Elem() slicev = slicev.Slice(0, slicev.Cap()) elemt := slicev.Type().Elem() i := 0 for { if slicev.Len() == i { elemp := reflect.New(elemt) if !c.Next(elemp.Interface()) { break } slicev = reflect.Append(slicev, elemp.Elem()) slicev = slicev.Slice(0, slicev.Cap()) } else { if !c.Next(slicev.Index(i).Addr().Interface()) { break } } i++ } resultv.Elem().Set(slicev.Slice(0, i)) if err := c.Err(); err != nil { _ = c.Close() return err } if err := c.Close(); err != nil { return err } return nil } // One retrieves a single document from the result set into the provided // slice and closes the cursor. // // Also note that you are able to reuse the same variable multiple times as // `One` zeroes the value before scanning in the result. func (c *Cursor) One(result interface{}) error { if c == nil { return errNilCursor } if c.IsNil() { c.Close() return ErrEmptyResult } hasResult := c.Next(result) if err := c.Err(); err != nil { c.Close() return err } if err := c.Close(); err != nil { return err } if !hasResult { return ErrEmptyResult } return nil } // Interface retrieves all documents from the result set and returns the data // as an interface{} and closes the cursor. // // If the query returns multiple documents then a slice will be returned, // otherwise a single value will be returned. func (c *Cursor) Interface() (interface{}, error) { if c == nil { return nil, errNilCursor } var results []interface{} var result interface{} for c.Next(&result) { results = append(results, result) } if err := c.Err(); err != nil { return nil, err } c.mu.RLock() isSingleValue := c.isSingleValue c.mu.RUnlock() if isSingleValue { if len(results) == 0 { return nil, nil } return results[0], nil } return results, nil } // Listen listens for rows from the database and sends the result onto the given // channel. The type that the row is scanned into is determined by the element // type of the channel. // // Also note that this function returns immediately. // // cursor, err := r.Expr([]int{1,2,3}).Run(session) // if err != nil { // panic(err) // } // // ch := make(chan int) // cursor.Listen(ch) // <- ch // 1 // <- ch // 2 // <- ch // 3 func (c *Cursor) Listen(channel interface{}) { go func() { channelv := reflect.ValueOf(channel) if channelv.Kind() != reflect.Chan { panic("input argument must be a channel") } elemt := channelv.Type().Elem() for { elemp := reflect.New(elemt) if !c.Next(elemp.Interface()) { break } channelv.Send(elemp.Elem()) } c.Close() channelv.Close() }() } // IsNil tests if the current row is nil. func (c *Cursor) IsNil() bool { if c == nil { return true } c.mu.RLock() defer c.mu.RUnlock() if len(c.buffer) > 0 { return c.buffer[0] == nil } if len(c.responses) > 0 { response := c.responses[0] if response == nil { return true } if string(response) == "null" { return true } return false } return true } // fetchMore fetches more rows from the database. // // If wait is true then it will wait for the database to reply otherwise it // will return after sending the continue query. func (c *Cursor) fetchMore() error { var err error if !c.fetching { c.fetching = true if c.closed { return errCursorClosed } q := Query{ Type: p.Query_CONTINUE, Token: c.token, } c.mu.Unlock() _, _, err = c.conn.Query(c.ctx, q) c.mu.Lock() } return err } // handleError sets the value of lastErr to err if lastErr is not yet set. func (c *Cursor) handleError(err error) error { c.mu.Lock() defer c.mu.Unlock() return c.handleErrorLocked(err) } func (c *Cursor) handleErrorLocked(err error) error { if c.lastErr == nil { c.lastErr = err } return c.lastErr } // extend adds the result of a continue query to the cursor. func (c *Cursor) extend(response *Response) { c.mu.Lock() defer c.mu.Unlock() c.extendLocked(response) } func (c *Cursor) extendLocked(response *Response) { c.responses = append(c.responses, response.Responses...) c.finished = response.Type != p.Response_SUCCESS_PARTIAL c.fetching = false c.isAtom = response.Type == p.Response_SUCCESS_ATOM } // seekCursor takes care of loading more data if needed and applying pending skips // // bufferResponse determines whether the response will be parsed into the buffer func (c *Cursor) seekCursor(bufferResponse bool) error { if c.lastErr != nil { return c.lastErr } if len(c.buffer) == 0 && len(c.responses) == 0 && c.closed { return errCursorClosed } // Loop over loading data, applying skips as necessary and loading more data as needed // until either the cursor is connClosed or finished, or we have applied all outstanding // skips and data is available for { c.applyPendingSkips(bufferResponse) // if we are buffering the responses, skip can drain from the buffer if bufferResponse && len(c.buffer) == 0 && len(c.responses) > 0 { if err := c.bufferNextResponse(); err != nil { return err } continue // go around the loop again to re-apply pending skips } else if len(c.buffer) == 0 && len(c.responses) == 0 && !c.finished { // We skipped all of our data, load some more if err := c.fetchMore(); err != nil { return err } if c.closed { return nil } continue // go around the loop again to re-apply pending skips } return nil } } // applyPendingSkips applies all pending skips to the buffer and // returns whether there are more pending skips to be applied // // if drainFromBuffer is true, we will drain from the buffer, otherwise // we drain from the responses func (c *Cursor) applyPendingSkips(drainFromBuffer bool) (stillPending bool) { if c.pendingSkips == 0 { return false } if drainFromBuffer { if len(c.buffer) > c.pendingSkips { c.buffer = c.buffer[c.pendingSkips:] c.pendingSkips = 0 return false } c.pendingSkips -= len(c.buffer) c.buffer = c.buffer[:0] return c.pendingSkips > 0 } if len(c.responses) > c.pendingSkips { c.responses = c.responses[c.pendingSkips:] c.pendingSkips = 0 return false } c.pendingSkips -= len(c.responses) c.responses = c.responses[:0] return c.pendingSkips > 0 } // bufferResponse reads a single response and stores the result into the buffer // if the response is from an atomic response, it will check if the // response contains multiple records and store them all into the buffer func (c *Cursor) bufferNextResponse() error { if c.closed { return errCursorClosed } // If there are no responses, nothing to do if len(c.responses) == 0 { return nil } response := c.responses[0] c.responses = c.responses[1:] var value interface{} decoder := json.NewDecoder(bytes.NewBuffer(response)) if c.connOpts.UseJSONNumber { decoder.UseNumber() } err := decoder.Decode(&value) if err != nil { return err } value, err = recursivelyConvertPseudotype(value, c.opts) if err != nil { return err } // If response is an ATOM then try and convert to an array if data, ok := value.([]interface{}); ok && c.isAtom { c.buffer = append(c.buffer, data...) } else if value == nil { c.buffer = append(c.buffer, nil) } else { c.buffer = append(c.buffer, value) // If this is the only value in the response and the response was an // atom then set the single value flag if c.isAtom { c.isSingleValue = true } } return nil } rethinkdb-go-6.2.1/cursor_test.go000066400000000000000000000012601363464422500170100ustar00rootroot00000000000000package rethinkdb import ( test "gopkg.in/check.v1" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests" ) type CursorSuite struct{} var _ = test.Suite(&CursorSuite{}) func (s *CursorSuite) TestCursor_One_Ok(c *test.C) { data := map[string]interface{}{ "A": 1, "B": true, } mock := NewMock() ch := make(chan []interface{}) mock.On(DB("test").Table("test")).Return(ch, nil) go func() { ch <- []interface{}{data} close(ch) }() res, err := DB("test").Table("test").Run(mock) c.Assert(err, test.IsNil) var response interface{} err = res.One(&response) c.Assert(err, test.IsNil) c.Assert(response, tests.JsonEquals, data) mock.AssertExpectations(c) } rethinkdb-go-6.2.1/doc.go000066400000000000000000000003551363464422500152050ustar00rootroot00000000000000// Package rethinkdb-go implements a Go driver for RethinkDB // // Current version: v3.0.2 (RethinkDB v2.3) // For more in depth information on how to use RethinkDB check out the API docs // at http://rethinkdb.com/api package rethinkdb rethinkdb-go-6.2.1/encoding/000077500000000000000000000000001363464422500156745ustar00rootroot00000000000000rethinkdb-go-6.2.1/encoding/cache.go000066400000000000000000000160731363464422500172750ustar00rootroot00000000000000// This code is based on encoding/json and gorilla/schema package encoding import ( "reflect" "sort" "sync" "time" ) // A field represents a single field found in a struct. type field struct { name string nameBytes []byte // []byte(name) equalFold func(s, t []byte) bool tag bool index []int typ reflect.Type omitEmpty bool quoted bool reference bool refName string compound bool compoundIndex int } func fillField(f field) field { f.nameBytes = []byte(f.name) f.equalFold = foldFunc(f.nameBytes) return f } // byName sorts field by name, breaking ties with depth, // then breaking ties with "name came from tag", then // breaking ties with index sequence. type byName []field func (x byName) Len() int { return len(x) } func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func (x byName) Less(i, j int) bool { if x[i].name != x[j].name { return x[i].name < x[j].name } if len(x[i].index) != len(x[j].index) { return len(x[i].index) < len(x[j].index) } if x[i].tag != x[j].tag { return x[i].tag } return byIndex(x).Less(i, j) } // byIndex sorts field by index sequence. type byIndex []field func (x byIndex) Len() int { return len(x) } func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func (x byIndex) Less(i, j int) bool { for k, xik := range x[i].index { if k >= len(x[j].index) { return false } if xik != x[j].index[k] { return xik < x[j].index[k] } } return len(x[i].index) < len(x[j].index) } // typeFields returns a list of fields that should be recognized for the given type. // The algorithm is breadth-first search over the set of structs to include - the top struct // and then any reachable anonymous structs. func typeFields(t reflect.Type) []field { // Anonymous fields to explore at the current level and the next. current := []field{} next := []field{{typ: t}} // Count of queued names for current level and the next. count := map[reflect.Type]int{} nextCount := map[reflect.Type]int{} // Types already visited at an earlier level. visited := map[reflect.Type]bool{} // Fields found. var fields []field for len(next) > 0 { current, next = next, current[:0] count, nextCount = nextCount, map[reflect.Type]int{} for _, f := range current { if visited[f.typ] { continue } visited[f.typ] = true // Scan f.typ for fields to include. for i := 0; i < f.typ.NumField(); i++ { sf := f.typ.Field(i) if sf.PkgPath != "" && !sf.Anonymous { // unexported continue } // Extract field name from tag tag := getTag(sf) if tag == "-" { continue } name, opts := parseTag(tag) name, compoundIndex, isCompound := parseCompoundIndex(name) if !isValidTag(name) { name = "" } // Extract referenced field from tags refTag := getRefTag(sf) ref, _ := parseTag(refTag) if !isValidTag(ref) { ref = "" } index := make([]int, len(f.index)+1) copy(index, f.index) index[len(f.index)] = i ft := sf.Type if ft.Name() == "" && ft.Kind() == reflect.Ptr { // Follow pointer. ft = ft.Elem() } // Record found field and index sequence. if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct || isPseudoType(ft) { tagged := name != "" if name == "" { name = sf.Name } fields = append(fields, fillField(field{ name: name, tag: tagged, index: index, typ: ft, omitEmpty: opts.Contains("omitempty"), reference: opts.Contains("reference"), refName: ref, compound: isCompound, compoundIndex: compoundIndex, })) if count[f.typ] > 1 { // If there were multiple instances, add a second, // so that the annihilation code will see a duplicate. // It only cares about the distinction between 1 or 2, // so don't bother generating any more copies. fields = append(fields, fields[len(fields)-1]) } continue } // Record new anonymous struct to explore in next round. nextCount[ft]++ if nextCount[ft] == 1 { next = append(next, fillField(field{name: ft.Name(), index: index, typ: ft})) } } } } sort.Sort(byName(fields)) // Delete all fields that are hidden by the Go rules for embedded fields, // except that fields with valid tags are promoted. // The fields are sorted in primary order of name, secondary order // of field index length. Loop over names; for each name, delete // hidden fields by choosing the one dominant field that survives. out := fields[:0] for advance, i := 0, 0; i < len(fields); i += advance { // One iteration per name. // Find the sequence of fields with the name of this first field. fi := fields[i] for advance = 1; i+advance < len(fields); advance++ { fj := fields[i+advance] if fj.name != fi.name { break } if fi.compound && fj.compound && fi.compoundIndex != fj.compoundIndex { break } } if advance == 1 { // Only one field with this name out = append(out, fi) continue } dominant, ok := dominantField(fields[i : i+advance]) if ok { out = append(out, dominant) } } fields = out sort.Sort(byIndex(fields)) return fields } func isPseudoType(t reflect.Type) bool { return t == reflect.TypeOf(time.Time{}) } // dominantField looks through the fields, all of which are known to // have the same name, to find the single field that dominates the // others using Go's embedding rules, modified by the presence of // valid tags. If there are multiple top-level fields, the boolean // will be false: This condition is an error in Go and we skip all // the fields. func dominantField(fields []field) (field, bool) { // The fields are sorted in increasing index-length order. The winner // must therefore be one with the shortest index length. Drop all // longer entries, which is easy: just truncate the slice. length := len(fields[0].index) tagged := -1 // Index of first tagged field. for i, f := range fields { if len(f.index) > length { fields = fields[:i] break } if f.tag { if tagged >= 0 { // Multiple tagged fields at the same level: conflict. // Return no field. return field{}, false } tagged = i } } if tagged >= 0 { return fields[tagged], true } // All remaining fields have the same length. If there's more than one, // we have a conflict (two fields named "X" at the same level) and we // return no field. if len(fields) > 1 { return field{}, false } return fields[0], true } var fieldCache struct { sync.RWMutex m map[reflect.Type][]field } // cachedTypeFields is like typeFields but uses a cache to avoid repeated work. func cachedTypeFields(t reflect.Type) []field { fieldCache.RLock() f := fieldCache.m[t] fieldCache.RUnlock() if f != nil { return f } // Compute fields without lock. // Might duplicate effort but won't hold other computations back. f = typeFields(t) if f == nil { f = []field{} } fieldCache.Lock() if fieldCache.m == nil { fieldCache.m = map[reflect.Type][]field{} } fieldCache.m[t] = f fieldCache.Unlock() return f } rethinkdb-go-6.2.1/encoding/decoder.go000066400000000000000000000066071363464422500176410ustar00rootroot00000000000000package encoding import ( "errors" "reflect" "runtime" "sync" ) var byteSliceType = reflect.TypeOf([]byte(nil)) type decoderFunc func(dv reflect.Value, sv reflect.Value) error // Decode decodes map[string]interface{} into a struct. The first parameter // must be a pointer. func Decode(dst interface{}, src interface{}) (err error) { return decode(dst, src, true) } func Merge(dst interface{}, src interface{}) (err error) { return decode(dst, src, false) } func decode(dst interface{}, src interface{}, blank bool) (err error) { defer func() { if r := recover(); r != nil { if _, ok := r.(runtime.Error); ok { panic(r) } if v, ok := r.(string); ok { err = errors.New(v) } else { err = r.(error) } } }() dv := reflect.ValueOf(dst) sv := reflect.ValueOf(src) if dv.Kind() != reflect.Ptr { return &DecodeTypeError{ DestType: dv.Type(), SrcType: sv.Type(), Reason: "must be a pointer", } } dv = dv.Elem() if !dv.CanAddr() { return &DecodeTypeError{ DestType: dv.Type(), SrcType: sv.Type(), Reason: "must be addressable", } } return decodeValue(dv, sv, blank) } // decodeValue decodes the source value into the destination value func decodeValue(dv, sv reflect.Value, blank bool) error { return valueDecoder(dv, sv, blank)(dv, sv) } type decoderCacheKey struct { dt, st reflect.Type } var decoderCache struct { sync.RWMutex m map[decoderCacheKey]decoderFunc } func valueDecoder(dv, sv reflect.Value, blank bool) decoderFunc { if !sv.IsValid() { return invalidValueDecoder } if dv.IsValid() { dv = indirect(dv, false) if sv.Kind() == reflect.Ptr { sv = indirect(sv, false) dv.Set(sv) } else if blank { dv.Set(reflect.Zero(dv.Type())) } } return typeDecoder(dv.Type(), sv.Type(), blank) } func typeDecoder(dt, st reflect.Type, blank bool) decoderFunc { decoderCache.RLock() f := decoderCache.m[decoderCacheKey{dt, st}] decoderCache.RUnlock() if f != nil { return f } // To deal with recursive types, populate the map with an // indirect func before we build it. This type waits on the // real func (f) to be ready and then calls it. This indirect // func is only used for recursive types. decoderCache.Lock() var wg sync.WaitGroup wg.Add(1) decoderCache.m[decoderCacheKey{dt, st}] = func(dv, sv reflect.Value) error { wg.Wait() return f(dv, sv) } decoderCache.Unlock() // Compute fields without lock. // Might duplicate effort but won't hold other computations back. f = newTypeDecoder(dt, st, blank) wg.Done() decoderCache.Lock() decoderCache.m[decoderCacheKey{dt, st}] = f decoderCache.Unlock() return f } // indirect walks down v allocating pointers as needed, // until it gets to a non-pointer. func indirect(v reflect.Value, decodeNull bool) reflect.Value { // If v is a named type and is addressable, // start with its address, so that if the type has pointer methods, // we find them. if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() { v = v.Addr() } for { // Load value from interface, but only if the result will be // usefully addressable. if v.Kind() == reflect.Interface && !v.IsNil() { e := v.Elem() if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodeNull || e.Elem().Kind() == reflect.Ptr) { v = e continue } } if v.Kind() != reflect.Ptr { break } if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } v = v.Elem() } return v } rethinkdb-go-6.2.1/encoding/decoder_test.go000066400000000000000000000337151363464422500207000ustar00rootroot00000000000000package encoding import ( "bytes" "encoding/json" "errors" "image" "reflect" "testing" ) type T struct { X string Y int Z int `rethinkdb:"-"` } type U struct { Alphabet string `rethinkdb:"alpha"` } type V struct { F1 interface{} F2 int32 F3 string } type tx struct { x int } var txType = reflect.TypeOf((*tx)(nil)).Elem() // Test data structures for anonymous fields. type Point struct { Z int } type Top struct { Level0 int Embed0 *Embed0a *Embed0b `rethinkdb:"e,omitempty"` // treated as named Embed0c `rethinkdb:"-"` // ignored Loop Embed0p // has Point with X, Y, used Embed0q // has Point with Z, used } type Embed0 struct { Level1a int // overridden by Embed0a's Level1a with tag Level1b int // used because Embed0a's Level1b is renamed Level1c int // used because Embed0a's Level1c is ignored Level1d int // annihilated by Embed0a's Level1d Level1e int `rethinkdb:"x"` // annihilated by Embed0a.Level1e } type Embed0a struct { Level1a int `rethinkdb:"Level1a,omitempty"` Level1b int `rethinkdb:"LEVEL1B,omitempty"` Level1c int `rethinkdb:"-"` Level1d int // annihilated by Embed0's Level1d Level1f int `rethinkdb:"x"` // annihilated by Embed0's Level1e } type Embed0b Embed0 type Embed0c Embed0 type Embed0p struct { image.Point } type Embed0q struct { Point } type Loop struct { Loop1 int `rethinkdb:",omitempty"` Loop2 int `rethinkdb:",omitempty"` *Loop } // From reflect test: // The X in S6 and S7 annihilate, but they also block the X in S8.S9. type S5 struct { S6 S7 S8 } type S6 struct { X int } type S7 S6 type S8 struct { S9 } type S9 struct { X int Y int } // From reflect test: // The X in S11.S6 and S12.S6 annihilate, but they also block the X in S13.S8.S9. type S10 struct { S11 S12 S13 } type S11 struct { S6 } type S12 struct { S6 } type S13 struct { S8 } type PointerBasic struct { X int Y *int } type Pointer struct { PPoint *Point Point Point } type decodeTest struct { in interface{} ptr interface{} out interface{} err error } type Ambig struct { // Given "hello", the first match should win. First int `rethinkdb:"HELLO"` Second int `rethinkdb:"Hello"` } type SliceStruct struct { X []string } // Decode test helper vars var ( sampleInt = 2 ) var decodeTests = []decodeTest{ // basic types {in: true, ptr: new(bool), out: true}, {in: 1, ptr: new(int), out: 1}, {in: 1.2, ptr: new(float64), out: 1.2}, {in: -5, ptr: new(int16), out: int16(-5)}, {in: 2, ptr: new(string), out: string("2")}, {in: float64(2.0), ptr: new(interface{}), out: float64(2.0)}, {in: string("2"), ptr: new(interface{}), out: string("2")}, {in: "a\u1234", ptr: new(string), out: "a\u1234"}, {in: []interface{}{}, ptr: new([]string), out: []string{}}, {in: map[string]interface{}{"X": []interface{}{1, 2, 3}, "Y": 4}, ptr: new(T), out: T{}, err: &DecodeTypeError{reflect.TypeOf(""), reflect.TypeOf([]interface{}{}), ""}}, {in: map[string]interface{}{"x": 1}, ptr: new(tx), out: tx{}}, {in: map[string]interface{}{"F1": float64(1), "F2": 2, "F3": 3}, ptr: new(V), out: V{F1: float64(1), F2: int32(2), F3: string("3")}}, {in: map[string]interface{}{"F1": string("1"), "F2": 2, "F3": 3}, ptr: new(V), out: V{F1: string("1"), F2: int32(2), F3: string("3")}}, { in: map[string]interface{}{"k1": int64(1), "k2": "s", "k3": []interface{}{int64(1), 2.0, 3e-3}, "k4": map[string]interface{}{"kk1": "s", "kk2": int64(2)}}, out: map[string]interface{}{"k1": int64(1), "k2": "s", "k3": []interface{}{int64(1), 2.0, 3e-3}, "k4": map[string]interface{}{"kk1": "s", "kk2": int64(2)}}, ptr: new(interface{}), }, // Z has a "-" tag. {in: map[string]interface{}{"Y": 1, "Z": 2}, ptr: new(T), out: T{Y: 1}}, {in: map[string]interface{}{"alpha": "abc", "alphabet": "xyz"}, ptr: new(U), out: U{Alphabet: "abc"}}, {in: map[string]interface{}{"alpha": "abc"}, ptr: new(U), out: U{Alphabet: "abc"}}, {in: map[string]interface{}{"alphabet": "xyz"}, ptr: new(U), out: U{}}, // array tests {in: []interface{}{1, 2, 3}, ptr: new([3]int), out: [3]int{1, 2, 3}}, {in: []interface{}{1, 2, 3}, ptr: new([1]int), out: [1]int{1}}, {in: []interface{}{1, 2, 3}, ptr: new([5]int), out: [5]int{1, 2, 3, 0, 0}}, // empty array to interface test {in: map[string]interface{}{"T": []interface{}{}}, ptr: new(map[string]interface{}), out: map[string]interface{}{"T": []interface{}{}}}, { in: map[string]interface{}{ "Level0": 1, "Level1b": 2, "Level1c": 3, "level1d": 4, "Level1a": 5, "LEVEL1B": 6, "e": map[string]interface{}{ "Level1a": 8, "Level1b": 9, "Level1c": 10, "Level1d": 11, "x": 12, }, "Loop1": 13, "Loop2": 14, "X": 15, "Y": 16, "Z": 17, }, ptr: new(Top), out: Top{ Level0: 1, Embed0: Embed0{ Level1b: 2, Level1c: 3, }, Embed0a: &Embed0a{ Level1a: 5, Level1b: 6, }, Embed0b: &Embed0b{ Level1a: 8, Level1b: 9, Level1c: 10, Level1d: 11, }, Loop: Loop{ Loop1: 13, Loop2: 14, }, Embed0p: Embed0p{ Point: image.Point{X: 15, Y: 16}, }, Embed0q: Embed0q{ Point: Point{Z: 17}, }, }, }, { in: map[string]interface{}{"hello": 1}, ptr: new(Ambig), out: Ambig{First: 1}, }, { in: map[string]interface{}{"X": 1, "Y": 2}, ptr: new(S5), out: S5{S8: S8{S9: S9{Y: 2}}}, }, { in: map[string]interface{}{"X": 1, "Y": 2}, ptr: new(S10), out: S10{S13: S13{S8: S8{S9: S9{Y: 2}}}}, }, { in: map[string]interface{}{"PPoint": map[string]interface{}{"Z": 1}, "Point": map[string]interface{}{"Z": 2}}, ptr: new(Pointer), out: Pointer{PPoint: &Point{Z: 1}, Point: Point{Z: 2}}, }, { in: map[string]interface{}{"Point": map[string]interface{}{"Z": 2}}, ptr: new(Pointer), out: Pointer{PPoint: nil, Point: Point{Z: 2}}, }, { in: map[string]interface{}{"x": 2}, ptr: new(PointerBasic), out: PointerBasic{X: 2, Y: nil}, }, { in: map[string]interface{}{"x": 2, "y": 2}, ptr: new(PointerBasic), out: PointerBasic{X: 2, Y: &sampleInt}, }, } func TestDecode(t *testing.T) { for i, tt := range decodeTests { if tt.ptr == nil { continue } // v = new(right-type) v := reflect.New(reflect.TypeOf(tt.ptr).Elem()) err := Decode(v.Interface(), tt.in) if !jsonEqual(err, tt.err) { t.Errorf("#%d: got error %v want %v", i, err, tt.err) continue } if tt.err == nil && !jsonEqual(v.Elem().Interface(), tt.out) { t.Errorf("#%d: mismatch\nhave: %+v\nwant: %+v", i, v.Elem().Interface(), tt.out) continue } // Check round trip. if tt.err == nil { enc, err := Encode(v.Interface()) if err != nil { t.Errorf("#%d: error re-marshaling: %v", i, err) continue } vv := reflect.New(reflect.TypeOf(tt.ptr).Elem()) if err := Decode(vv.Interface(), enc); err != nil { t.Errorf("#%d: error re-decodeing: %v", i, err) continue } if !jsonEqual(v.Elem().Interface(), vv.Elem().Interface()) { t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.Elem().Interface(), vv.Elem().Interface()) continue } } } } func TestStringKind(t *testing.T) { type aMap map[string]int var m1, m2 map[string]int m1 = map[string]int{ "foo": 42, } data, err := Encode(m1) if err != nil { t.Errorf("Unexpected error encoding: %v", err) } err = Decode(&m2, data) if err != nil { t.Errorf("Unexpected error decoding: %v", err) } if !jsonEqual(m1, m2) { t.Error("Items should be equal after encoding and then decoding") } } // Test handling of unexported fields that should be ignored. type unexportedFields struct { Name string m map[string]interface{} `rethinkdb:"-"` m2 map[string]interface{} `rethinkdb:"abcd"` } func TestDecodeUnexported(t *testing.T) { input := map[string]interface{}{ "Name": "Bob", "m": map[string]interface{}{ "x": 123, }, "m2": map[string]interface{}{ "y": 123, }, "abcd": map[string]interface{}{ "z": 789, }, } want := &unexportedFields{Name: "Bob"} out := &unexportedFields{} err := Decode(out, input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } type Foo struct { FooBar interface{} `rethinkdb:"foobar"` } type Bar struct { Baz int `rethinkdb:"baz"` } type UnmarshalerPointer struct { Value *UnmarshalerValue } type UnmarshalerValue struct { ValueInt int64 ValueString string } func (v *UnmarshalerValue) MarshalRQL() (interface{}, error) { if v.ValueInt != int64(0) { return Encode(v.ValueInt) } if v.ValueString != "" { return Encode(v.ValueString) } return Encode(nil) } func (v *UnmarshalerValue) UnmarshalRQL(b interface{}) (err error) { n, s := int64(0), "" if err = Decode(&s, b); err == nil { v.ValueString = s return } if err = Decode(&n, b); err == nil { v.ValueInt = n } return } func TestDecodeUnmarshalerPointer(t *testing.T) { input := map[string]interface{}{ "Value": "abc", } want := &UnmarshalerPointer{ Value: &UnmarshalerValue{ValueString: "abc"}, } out := &UnmarshalerPointer{} err := Decode(out, input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %+v, want %+v", out, want) } } func TestDecodeMapIntKeys(t *testing.T) { input := map[string]int{"1": 1, "2": 2, "3": 3} want := map[int]int{1: 1, 2: 2, 3: 3} out := map[int]int{} err := Decode(&out, input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestDecodeCompoundKey(t *testing.T) { input := map[string]interface{}{"id": []string{"1", "2"}, "err_a[]": "3", "err_b[": "4", "err_c]": "5"} want := Compound{"1", "2", "3", "4", "5"} out := Compound{} err := Decode(&out, input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestDecodeNilSlice(t *testing.T) { input := map[string]interface{}{"X": nil} want := SliceStruct{} out := SliceStruct{} err := Decode(&out, input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func jsonEqual(a, b interface{}) bool { // First check using reflect.DeepEqual if reflect.DeepEqual(a, b) { return true } // Then use jsonEqual ba, err := json.Marshal(a) if err != nil { panic(err) } bb, err := json.Marshal(b) if err != nil { panic(err) } return bytes.Compare(ba, bb) == 0 } func TestMergeStruct(t *testing.T) { var dst struct { Field string AnotherField string } dst.Field = "change me" dst.AnotherField = "don't blank me" err := Merge(&dst, map[string]interface{}{"Field": "Changed!"}) if err != nil { t.Error("Cannot merge:", err) } if dst.AnotherField == "" { t.Error("Field has been wiped") } } func TestMergeMap(t *testing.T) { var dst = make(map[string]string) dst["field"] = "change me" dst["another_field"] = "don't blank me" err := Merge(&dst, map[string]interface{}{"field": "Changed!"}) if err != nil { t.Error("Cannot merge:", err) } if dst["another_field"] == "" { t.Error("Field has been wiped") } } func TestDecodeCustomTypeEncodingValue(t *testing.T) { type innerType struct { Val int } type outerType struct { Inner innerType `rethinkdb:"inner"` } want := outerType{Inner: innerType{Val: 5}} in := map[string]interface{}{ "inner": map[string]interface{}{ "someval": 5, }, } SetTypeEncoding(reflect.TypeOf(innerType{}), nil, func(enc interface{}, val reflect.Value) error { m := enc.(map[string]interface{}) val.Set(reflect.ValueOf(innerType{Val: m["someval"].(int)})) return nil }) var out outerType err := Decode(&out, in) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestDecodeCustomTypeEncodingPointer(t *testing.T) { type innerType struct { Val int } type outerType struct { Inner *innerType `rethinkdb:"inner"` } want := outerType{Inner: &innerType{Val: 5}} in := map[string]interface{}{ "inner": map[string]interface{}{ "someval": 5, }, } SetTypeEncoding(reflect.TypeOf((*innerType)(nil)), nil, func(enc interface{}, val reflect.Value) error { m := enc.(map[string]interface{}) val.Set(reflect.ValueOf(&innerType{Val: m["someval"].(int)})) return nil }) var out outerType err := Decode(&out, in) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %+v, want %+v", out, want) } } func TestDecodeCustomRootTypeEncodingValue(t *testing.T) { type cType struct { Val int } want := cType{Val: 5} in := map[string]interface{}{ "someval": 5, } SetTypeEncoding(reflect.TypeOf(cType{}), nil, func(enc interface{}, val reflect.Value) error { m := enc.(map[string]interface{}) val.Set(reflect.ValueOf(cType{Val: m["someval"].(int)})) return nil }) var out cType err := Decode(&out, in) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestDecodeCustomRootTypeEncodingPointer(t *testing.T) { type cType struct { Val int } want := cType{Val: 5} in := map[string]interface{}{ "someval": 5, } SetTypeEncoding(reflect.TypeOf((*cType)(nil)), nil, func(enc interface{}, val reflect.Value) error { m := enc.(map[string]interface{}) val.Set(reflect.ValueOf(&cType{Val: m["someval"].(int)})) return nil }) var out *cType err := Decode(&out, in) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestDecodeCustomTypeEncodingError(t *testing.T) { type cType struct { Val int } in := map[string]interface{}{ "val": 5, } cerr := errors.New("decode error") SetTypeEncoding(reflect.TypeOf(cType{}), nil, func(enc interface{}, val reflect.Value) error { return cerr }) var out cType err := Decode(&out, in) if err == nil { t.Errorf("got no error, expected %v", cerr) } if err != cerr { t.Errorf("got %v, want %v", err, cerr) } } rethinkdb-go-6.2.1/encoding/decoder_types.go000066400000000000000000000330551363464422500210620ustar00rootroot00000000000000package encoding import ( "bytes" "fmt" "reflect" "strconv" ) // newTypeDecoder constructs an decoderFunc for a type. func newTypeDecoder(dt, st reflect.Type, blank bool) decoderFunc { if reflect.PtrTo(dt).Implements(unmarshalerType) || dt.Implements(unmarshalerType) { return unmarshalerDecoder } if st.Kind() == reflect.Interface { return newInterfaceAsTypeDecoder(blank) } switch dt.Kind() { case reflect.Bool: switch st.Kind() { case reflect.Bool: return boolAsBoolDecoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intAsBoolDecoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintAsBoolDecoder case reflect.Float32, reflect.Float64: return floatAsBoolDecoder case reflect.String: return stringAsBoolDecoder default: return decodeTypeError } case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: switch st.Kind() { case reflect.Bool: return boolAsIntDecoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intAsIntDecoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintAsIntDecoder case reflect.Float32, reflect.Float64: return floatAsIntDecoder case reflect.String: return stringAsIntDecoder default: return decodeTypeError } case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: switch st.Kind() { case reflect.Bool: return boolAsUintDecoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intAsUintDecoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintAsUintDecoder case reflect.Float32, reflect.Float64: return floatAsUintDecoder case reflect.String: return stringAsUintDecoder default: return decodeTypeError } case reflect.Float32, reflect.Float64: switch st.Kind() { case reflect.Bool: return boolAsFloatDecoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intAsFloatDecoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintAsFloatDecoder case reflect.Float32, reflect.Float64: return floatAsFloatDecoder case reflect.String: return stringAsFloatDecoder default: return decodeTypeError } case reflect.String: switch st.Kind() { case reflect.Bool: return boolAsStringDecoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intAsStringDecoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintAsStringDecoder case reflect.Float32, reflect.Float64: return floatAsStringDecoder case reflect.String: return stringAsStringDecoder default: return decodeTypeError } case reflect.Interface: if !st.AssignableTo(dt) { return decodeTypeError } return interfaceDecoder case reflect.Ptr: return newPtrDecoder(dt, st, blank) case reflect.Map: if st.AssignableTo(dt) { return interfaceDecoder } switch st.Kind() { case reflect.Map: return newMapAsMapDecoder(dt, st, blank) default: return decodeTypeError } case reflect.Struct: if st.AssignableTo(dt) { return interfaceDecoder } switch st.Kind() { case reflect.Map: if kind := st.Key().Kind(); kind != reflect.String && kind != reflect.Interface { return newDecodeTypeError(fmt.Errorf("map needs string keys")) } return newMapAsStructDecoder(dt, st, blank) default: return decodeTypeError } case reflect.Slice: if st.AssignableTo(dt) { return interfaceDecoder } switch st.Kind() { case reflect.Array, reflect.Slice: return newSliceDecoder(dt, st) default: return decodeTypeError } case reflect.Array: if st.AssignableTo(dt) { return interfaceDecoder } switch st.Kind() { case reflect.Array, reflect.Slice: return newArrayDecoder(dt, st) default: return decodeTypeError } default: return unsupportedTypeDecoder } } func invalidValueDecoder(dv, sv reflect.Value) error { dv.Set(reflect.Zero(dv.Type())) return nil } func unsupportedTypeDecoder(dv, sv reflect.Value) error { return &UnsupportedTypeError{dv.Type()} } func decodeTypeError(dv, sv reflect.Value) error { return &DecodeTypeError{ DestType: dv.Type(), SrcType: sv.Type(), } } func newDecodeTypeError(err error) decoderFunc { return func(dv, sv reflect.Value) error { return &DecodeTypeError{ DestType: dv.Type(), SrcType: sv.Type(), Reason: err.Error(), } } } func interfaceDecoder(dv, sv reflect.Value) error { dv.Set(sv) return nil } func newInterfaceAsTypeDecoder(blank bool) decoderFunc { return func(dv, sv reflect.Value) error { if !sv.IsNil() { dv = indirect(dv, false) if blank { dv.Set(reflect.Zero(dv.Type())) } return decodeValue(dv, sv.Elem(), blank) } return nil } } type ptrDecoder struct { elemDec decoderFunc } func (d *ptrDecoder) decode(dv, sv reflect.Value) error { v := reflect.New(dv.Type().Elem()) err := d.elemDec(v, sv) dv.Set(v) return err } func newPtrDecoder(dt, st reflect.Type, blank bool) decoderFunc { dec := &ptrDecoder{typeDecoder(dt.Elem(), st, blank)} return dec.decode } func unmarshalerDecoder(dv, sv reflect.Value) error { // modeled off of https://golang.org/src/encoding/json/decode.go?#L325 if dv.Kind() != reflect.Ptr && dv.Type().Name() != "" && dv.CanAddr() { dv = dv.Addr() } if dv.IsNil() { dv.Set(reflect.New(dv.Type().Elem())) } u := dv.Interface().(Unmarshaler) err := u.UnmarshalRQL(sv.Interface()) if err != nil { return &DecodeTypeError{dv.Type(), sv.Type(), err.Error()} } return nil } // Boolean decoders func boolAsBoolDecoder(dv, sv reflect.Value) error { dv.SetBool(sv.Bool()) return nil } func boolAsIntDecoder(dv, sv reflect.Value) error { if sv.Bool() { dv.SetInt(1) } else { dv.SetInt(0) } return nil } func boolAsUintDecoder(dv, sv reflect.Value) error { if sv.Bool() { dv.SetUint(1) } else { dv.SetUint(0) } return nil } func boolAsFloatDecoder(dv, sv reflect.Value) error { if sv.Bool() { dv.SetFloat(1) } else { dv.SetFloat(0) } return nil } func boolAsStringDecoder(dv, sv reflect.Value) error { if sv.Bool() { dv.SetString("1") } else { dv.SetString("0") } return nil } // Int decoders func intAsBoolDecoder(dv, sv reflect.Value) error { dv.SetBool(sv.Int() != 0) return nil } func intAsIntDecoder(dv, sv reflect.Value) error { dv.SetInt(sv.Int()) return nil } func intAsUintDecoder(dv, sv reflect.Value) error { dv.SetUint(uint64(sv.Int())) return nil } func intAsFloatDecoder(dv, sv reflect.Value) error { dv.SetFloat(float64(sv.Int())) return nil } func intAsStringDecoder(dv, sv reflect.Value) error { dv.SetString(strconv.FormatInt(sv.Int(), 10)) return nil } // Uint decoders func uintAsBoolDecoder(dv, sv reflect.Value) error { dv.SetBool(sv.Uint() != 0) return nil } func uintAsIntDecoder(dv, sv reflect.Value) error { dv.SetInt(int64(sv.Uint())) return nil } func uintAsUintDecoder(dv, sv reflect.Value) error { dv.SetUint(sv.Uint()) return nil } func uintAsFloatDecoder(dv, sv reflect.Value) error { dv.SetFloat(float64(sv.Uint())) return nil } func uintAsStringDecoder(dv, sv reflect.Value) error { dv.SetString(strconv.FormatUint(sv.Uint(), 10)) return nil } // Float decoders func floatAsBoolDecoder(dv, sv reflect.Value) error { dv.SetBool(sv.Float() != 0) return nil } func floatAsIntDecoder(dv, sv reflect.Value) error { dv.SetInt(int64(sv.Float())) return nil } func floatAsUintDecoder(dv, sv reflect.Value) error { dv.SetUint(uint64(sv.Float())) return nil } func floatAsFloatDecoder(dv, sv reflect.Value) error { dv.SetFloat(float64(sv.Float())) return nil } func floatAsStringDecoder(dv, sv reflect.Value) error { dv.SetString(strconv.FormatFloat(sv.Float(), 'f', -1, 64)) return nil } // String decoders func stringAsBoolDecoder(dv, sv reflect.Value) error { b, err := strconv.ParseBool(sv.String()) if err == nil { dv.SetBool(b) } else if sv.String() == "" { dv.SetBool(false) } else { return &DecodeTypeError{dv.Type(), sv.Type(), err.Error()} } return nil } func stringAsIntDecoder(dv, sv reflect.Value) error { i, err := strconv.ParseInt(sv.String(), 0, dv.Type().Bits()) if err == nil { dv.SetInt(i) } else { return &DecodeTypeError{dv.Type(), sv.Type(), err.Error()} } return nil } func stringAsUintDecoder(dv, sv reflect.Value) error { i, err := strconv.ParseUint(sv.String(), 0, dv.Type().Bits()) if err == nil { dv.SetUint(i) } else { return &DecodeTypeError{dv.Type(), sv.Type(), err.Error()} } return nil } func stringAsFloatDecoder(dv, sv reflect.Value) error { f, err := strconv.ParseFloat(sv.String(), dv.Type().Bits()) if err == nil { dv.SetFloat(f) } else { return &DecodeTypeError{dv.Type(), sv.Type(), err.Error()} } return nil } func stringAsStringDecoder(dv, sv reflect.Value) error { dv.SetString(sv.String()) return nil } // Slice/Array decoder type sliceDecoder struct { arrayDec decoderFunc } func (d *sliceDecoder) decode(dv, sv reflect.Value) error { if dv.Kind() == reflect.Slice { dv.Set(reflect.MakeSlice(dv.Type(), dv.Len(), dv.Cap())) } if !sv.IsNil() { err := d.arrayDec(dv, sv) if err != nil { return err } } return nil } func newSliceDecoder(dt, st reflect.Type) decoderFunc { dec := &sliceDecoder{newArrayDecoder(dt, st)} return dec.decode } type arrayDecoder struct { elemDec decoderFunc } func (d *arrayDecoder) decode(dv, sv reflect.Value) error { // Iterate through the slice/array and decode each element before adding it // to the dest slice/array i := 0 for i < sv.Len() { if dv.Kind() == reflect.Slice { // Get element of array, growing if necessary. if i >= dv.Cap() { newcap := dv.Cap() + dv.Cap()/2 if newcap < 4 { newcap = 4 } newdv := reflect.MakeSlice(dv.Type(), dv.Len(), newcap) reflect.Copy(newdv, dv) dv.Set(newdv) } if i >= dv.Len() { dv.SetLen(i + 1) } } if i < dv.Len() { // Decode into element. err := d.elemDec(dv.Index(i), sv.Index(i)) if err != nil { return err } } i++ } // Ensure that the destination is the correct size if i < dv.Len() { if dv.Kind() == reflect.Array { // Array. Zero the rest. z := reflect.Zero(dv.Type().Elem()) for ; i < dv.Len(); i++ { dv.Index(i).Set(z) } } else { dv.SetLen(i) } } return nil } func newArrayDecoder(dt, st reflect.Type) decoderFunc { dec := &arrayDecoder{typeDecoder(dt.Elem(), st.Elem(), true)} return dec.decode } // Map decoder type mapAsMapDecoder struct { keyDec, elemDec decoderFunc blank bool } func (d *mapAsMapDecoder) decode(dv, sv reflect.Value) error { dt := dv.Type() if d.blank { dv.Set(reflect.MakeMap(reflect.MapOf(dt.Key(), dt.Elem()))) } var mapKey reflect.Value var mapElem reflect.Value keyType := dv.Type().Key() elemType := dv.Type().Elem() for _, sElemKey := range sv.MapKeys() { var dElemKey reflect.Value var dElemVal reflect.Value if !mapKey.IsValid() { mapKey = reflect.New(keyType).Elem() } else { mapKey.Set(reflect.Zero(keyType)) } dElemKey = mapKey if !mapElem.IsValid() { mapElem = reflect.New(elemType).Elem() } else { mapElem.Set(reflect.Zero(elemType)) } dElemVal = mapElem err := d.keyDec(dElemKey, sElemKey) if err != nil { return err } err = d.elemDec(dElemVal, sv.MapIndex(sElemKey)) if err != nil { return err } dv.SetMapIndex(dElemKey, dElemVal) } return nil } func newMapAsMapDecoder(dt, st reflect.Type, blank bool) decoderFunc { d := &mapAsMapDecoder{typeDecoder(dt.Key(), st.Key(), blank), typeDecoder(dt.Elem(), st.Elem(), blank), blank} return d.decode } type mapAsStructDecoder struct { fields []field fieldDecs []decoderFunc blank bool } func (d *mapAsStructDecoder) decode(dv, sv reflect.Value) error { for _, kv := range sv.MapKeys() { var f *field var compoundFields = []*field{} var fieldDec decoderFunc key := []byte(kv.String()) for i := range d.fields { ff := &d.fields[i] ffd := d.fieldDecs[i] if bytes.Equal(ff.nameBytes, key) { f = ff fieldDec = ffd if ff.compound { compoundFields = append(compoundFields, ff) } } if f == nil && ff.equalFold(ff.nameBytes, key) { f = ff fieldDec = ffd if ff.compound { compoundFields = append(compoundFields, ff) } } } if len(compoundFields) > 0 { for _, compoundField := range compoundFields { dElemVal := fieldByIndex(dv, compoundField.index) sElemVal := sv.MapIndex(kv) if sElemVal.Kind() == reflect.Interface { sElemVal = sElemVal.Elem() } sElemVal = sElemVal.Index(compoundField.compoundIndex) fieldDec = typeDecoder(dElemVal.Type(), sElemVal.Type(), d.blank) if !sElemVal.IsValid() || !dElemVal.CanSet() { continue } err := fieldDec(dElemVal, sElemVal) if err != nil { return err } } } else if f != nil { dElemVal := fieldByIndex(dv, f.index) sElemVal := sv.MapIndex(kv) if !sElemVal.IsValid() || !dElemVal.CanSet() { continue } err := fieldDec(dElemVal, sElemVal) if err != nil { return err } } } return nil } func newMapAsStructDecoder(dt, st reflect.Type, blank bool) decoderFunc { fields := cachedTypeFields(dt) se := &mapAsStructDecoder{ fields: fields, fieldDecs: make([]decoderFunc, len(fields)), blank: blank, } for i, f := range fields { se.fieldDecs[i] = typeDecoder(typeByIndex(dt, f.index), st.Elem(), blank) } return se.decode } rethinkdb-go-6.2.1/encoding/encoder.go000066400000000000000000000033521363464422500176450ustar00rootroot00000000000000// This code is based on encoding/json and gorilla/schema package encoding import ( "errors" "reflect" "runtime" "sync" ) type encoderFunc func(v reflect.Value) (interface{}, error) // Encode returns the encoded value of v. // // Encode traverses the value v recursively and looks for structs. If a struct // is found then it is checked for tagged fields and convert to // map[string]interface{} func Encode(v interface{}) (ev interface{}, err error) { defer func() { if r := recover(); r != nil { if _, ok := r.(runtime.Error); ok { panic(r) } if v, ok := r.(string); ok { err = errors.New(v) } else { err = r.(error) } } }() return encode(reflect.ValueOf(v)) } func encode(v reflect.Value) (interface{}, error) { return valueEncoder(v)(v) } var encoderCache struct { sync.RWMutex m map[reflect.Type]encoderFunc } func valueEncoder(v reflect.Value) encoderFunc { if !v.IsValid() { return invalidValueEncoder } return typeEncoder(v.Type()) } func typeEncoder(t reflect.Type) encoderFunc { encoderCache.RLock() f := encoderCache.m[t] encoderCache.RUnlock() if f != nil { return f } // To deal with recursive types, populate the map with an // indirect func before we build it. This type waits on the // real func (f) to // be ready and then calls it. This indirect // func is only used for recursive types. encoderCache.Lock() var wg sync.WaitGroup wg.Add(1) encoderCache.m[t] = func(v reflect.Value) (interface{}, error) { wg.Wait() return f(v) } encoderCache.Unlock() // Compute fields without lock. // Might duplicate effort but won't hold other computations back. f = newTypeEncoder(t, true) wg.Done() encoderCache.Lock() encoderCache.m[t] = f encoderCache.Unlock() return f } rethinkdb-go-6.2.1/encoding/encoder_test.go000066400000000000000000000264351363464422500207130ustar00rootroot00000000000000package encoding import ( "errors" "image" "reflect" "testing" "time" ) var encodeExpected = map[string]interface{}{ "Level0": int64(1), "Level1b": int64(2), "Level1c": int64(3), "Level1a": int64(5), "LEVEL1B": int64(6), "e": map[string]interface{}{ "Level1a": int64(8), "Level1b": int64(9), "Level1c": int64(10), "Level1d": int64(11), "x": int64(12), }, "Loop1": int64(13), "Loop2": int64(14), "X": int64(15), "Y": int64(16), "Z": int64(17), } func TestEncode(t *testing.T) { // Top is defined in decoder_test.go var in = Top{ Level0: 1, Embed0: Embed0{ Level1b: 2, Level1c: 3, }, Embed0a: &Embed0a{ Level1a: 5, Level1b: 6, }, Embed0b: &Embed0b{ Level1a: 8, Level1b: 9, Level1c: 10, Level1d: 11, Level1e: 12, }, Loop: Loop{ Loop1: 13, Loop2: 14, }, Embed0p: Embed0p{ Point: image.Point{X: 15, Y: 16}, }, Embed0q: Embed0q{ Point: Point{Z: 17}, }, } got, err := Encode(&in) if err != nil { t.Fatal(err) } if !reflect.DeepEqual(got, encodeExpected) { t.Errorf(" got: %v\nwant: %v\n", got, encodeExpected) } } type Optionals struct { Sr string `rethinkdb:"sr"` So string `rethinkdb:"so,omitempty"` Sw string `rethinkdb:"-"` Ir int `rethinkdb:"omitempty"` // actually named omitempty, not an option Io int `rethinkdb:"io,omitempty"` Tr time.Time `rethinkdb:"tr"` To time.Time `rethinkdb:"to,omitempty"` Slr []string `rethinkdb:"slr"` Slo []string `rethinkdb:"slo,omitempty"` Mr map[string]interface{} `rethinkdb:"mr"` Mo map[string]interface{} `rethinkdb:",omitempty"` } var optionalsExpected = map[string]interface{}{ "sr": "", "omitempty": int64(0), "tr": map[string]interface{}{"$reql_type$": "TIME", "epoch_time": 0, "timezone": "+00:00"}, "slr": []interface{}(nil), "mr": map[string]interface{}{}, } func TestOmitEmpty(t *testing.T) { var o Optionals o.Sw = "something" o.Tr = time.Unix(0, 0).In(time.UTC) o.Mr = map[string]interface{}{} o.Mo = map[string]interface{}{} got, err := Encode(&o) if err != nil { t.Fatal(err) } if !jsonEqual(got, optionalsExpected) { t.Errorf("\ngot: %#v\nwant: %#v\n", got, optionalsExpected) } } type IntType int type MyStruct struct { IntType } func TestAnonymousNonstruct(t *testing.T) { var i IntType = 11 a := MyStruct{i} var want = map[string]interface{}{"IntType": int64(11)} got, err := Encode(a) if err != nil { t.Fatalf("Encode: %v", err) } if !reflect.DeepEqual(got, want) { t.Errorf("got %v, want %v", got, want) } } func TestEncodePointer(t *testing.T) { v := Pointer{PPoint: &Point{Z: 1}, Point: Point{Z: 2}} var want = map[string]interface{}{ "PPoint": map[string]interface{}{"Z": int64(1)}, "Point": map[string]interface{}{"Z": int64(2)}, } got, err := Encode(v) if err != nil { t.Fatalf("Encode: %v", err) } if !reflect.DeepEqual(got, want) { t.Errorf("got %v, want %v", got, want) } } func TestEncodeNilPointer(t *testing.T) { v := Pointer{PPoint: nil, Point: Point{Z: 2}} var want = map[string]interface{}{ "PPoint": nil, "Point": map[string]interface{}{"Z": int64(2)}, } got, err := Encode(v) if err != nil { t.Fatalf("Encode: %v", err) } if !reflect.DeepEqual(got, want) { t.Errorf("got %v, want %v", got, want) } } type BugA struct { S string } type BugB struct { BugA S string } type BugC struct { S string } // Legal Go: We never use the repeated embedded field (S). type BugX struct { A int BugA BugB } // Issue 5245. func TestEmbeddedBug(t *testing.T) { v := BugB{ BugA{"A"}, "B", } got, err := Encode(v) if err != nil { t.Fatal("Encode:", err) } want := map[string]interface{}{"S": "B"} if !reflect.DeepEqual(got, want) { t.Fatalf("Encode: got %v want %v", got, want) } // Now check that the duplicate field, S, does not appear. x := BugX{ A: 23, } got, err = Encode(x) if err != nil { t.Fatal("Encode:", err) } want = map[string]interface{}{"A": int64(23)} if !reflect.DeepEqual(got, want) { t.Fatalf("Encode: got %v want %v", got, want) } } type BugD struct { // Same as BugA after tagging. XXX string `rethinkdb:"S"` } // BugD's tagged S field should dominate BugA's. type BugY struct { BugA BugD } // Test that a field with a tag dominates untagged fields. func TestTaggedFieldDominates(t *testing.T) { v := BugY{ BugA{"BugA"}, BugD{"BugD"}, } got, err := Encode(v) if err != nil { t.Fatal("Encode:", err) } want := map[string]interface{}{"S": "BugD"} if !reflect.DeepEqual(got, want) { t.Fatalf("Encode: got %v want %v", got, want) } } // There are no tags here, so S should not appear. type BugZ struct { BugA BugC BugY // Contains a tagged S field through BugD; should not dominate. } func TestDuplicatedFieldDisappears(t *testing.T) { v := BugZ{ BugA{"BugA"}, BugC{"BugC"}, BugY{ BugA{"nested BugA"}, BugD{"nested BugD"}, }, } got, err := Encode(v) if err != nil { t.Fatal("Encode:", err) } want := map[string]interface{}{} if !reflect.DeepEqual(got, want) { t.Fatalf("Encode: got %v want %v", got, want) } } func TestEncodeMapIntKeys(t *testing.T) { input := map[int]int{1: 1, 2: 2, 3: 3} want := map[string]int{"1": 1, "2": 2, "3": 3} out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } type RefA struct { ID string `rethinkdb:"id,omitempty"` B *RefB `rethinkdb:"b_id,reference" rethinkdb_ref:"id"` } type RefB struct { ID string `rethinkdb:"id,omitempty"` Name string `rethinkdb:"name"` } func TestReferenceField(t *testing.T) { input := RefA{"1", &RefB{"2", "Name"}} want := map[string]interface{}{"id": "1", "b_id": "2"} out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } type RefC struct { ID string `rethinkdb:"id,omitempty"` B *RefB `rethinkdb:"b_id,reference" rethinkdb_ref:"b_id"` } func TestReferenceFieldMissing(t *testing.T) { input := RefC{"1", &RefB{"2", "Name"}} _, err := Encode(input) if err == nil { t.Errorf("expected non-nil error but got nil") } } type RefD struct { ID string `rethinkdb:"id,omitempty"` B string `rethinkdb:"b_id,reference" rethinkdb_ref:"b_id"` } func TestReferenceFieldInvalid(t *testing.T) { input := RefD{"1", "B"} _, err := Encode(input) if err == nil { t.Errorf("expected non-nil error but got nil") } } type RefE struct { ID string `rethinkdb:"id,omitempty"` FIDs *[]RefF `rethinkdb:"f_ids,reference" rethinkdb_ref:"id"` } type RefF struct { ID string `rethinkdb:"id,omitempty"` Name string `rethinkdb:"name"` } func TestReferenceFieldArray(t *testing.T) { input := RefE{"1", &[]RefF{RefF{"2", "Name2"}, RefF{"3", "Name3"}}} want := map[string]interface{}{"id": "1", "f_ids": []string{"2", "3"}} out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeBytes(t *testing.T) { type BytesStruct struct { A []byte B [1]byte } input := BytesStruct{[]byte("A"), [1]byte{'B'}} want := map[string]interface{}{ "A": map[string]interface{}{"$reql_type$": "BINARY", "data": "QQ=="}, "B": map[string]interface{}{"$reql_type$": "BINARY", "data": "Qg=="}, } out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } type Compound struct { PartA string `rethinkdb:"id[0]"` PartB string `rethinkdb:"id[1]"` ErrA string `rethinkdb:"err_a[]"` ErrB string `rethinkdb:"err_b["` ErrC string `rethinkdb:"err_c]"` } func TestEncodeCompound(t *testing.T) { input := Compound{"1", "2", "3", "4", "5"} want := map[string]interface{}{"id": []string{"1", "2"}, "err_a[]": "3", "err_b[": "4", "err_c]": "5"} out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } type CompoundRef struct { PartA string `rethinkdb:"id[0]"` PartB *RefB `rethinkdb:"id[1],reference" rethinkdb_ref:"id"` } func TestEncodeCompoundRef(t *testing.T) { input := CompoundRef{"1", &RefB{"2", "Name"}} want := map[string]interface{}{"id": []string{"1", "2"}} out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeNilSlice(t *testing.T) { input := SliceStruct{} want := map[string]interface{}{"X": []string(nil)} out, err := Encode(input) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeCustomTypeEncodingValue(t *testing.T) { type innerType struct { Val int } outer := struct { Inner innerType `rethinkdb:"inner"` }{Inner: innerType{Val: 5}} want := map[string]interface{}{ "inner": map[string]interface{}{ "someval": 5, }, } SetTypeEncoding(reflect.TypeOf(innerType{}), func(v interface{}) (interface{}, error) { return map[string]interface{}{"someval": v.(innerType).Val}, nil }, nil) out, err := Encode(outer) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeCustomTypeEncodingPointer(t *testing.T) { type innerType struct { Val int } outer := struct { Inner *innerType `rethinkdb:"inner"` }{Inner: &innerType{Val: 5}} want := map[string]interface{}{ "inner": map[string]interface{}{ "someval": 5, }, } SetTypeEncoding(reflect.TypeOf((*innerType)(nil)), func(v interface{}) (interface{}, error) { return map[string]interface{}{"someval": v.(*innerType).Val}, nil }, nil) out, err := Encode(outer) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeCustomRootTypeEncodingValue(t *testing.T) { type cType struct { Val int } in := cType{Val: 5} want := map[string]interface{}{ "someval": 5, } SetTypeEncoding(reflect.TypeOf(cType{}), func(v interface{}) (interface{}, error) { return map[string]interface{}{"someval": v.(cType).Val}, nil }, nil) out, err := Encode(in) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeCustomRootTypeEncodingPointer(t *testing.T) { type cType struct { Val int } in := cType{Val: 5} want := map[string]interface{}{ "someval": 5, } SetTypeEncoding(reflect.TypeOf((*cType)(nil)), func(v interface{}) (interface{}, error) { return map[string]interface{}{"someval": v.(*cType).Val}, nil }, nil) out, err := Encode(&in) if err != nil { t.Errorf("got error %v, expected nil", err) } if !jsonEqual(out, want) { t.Errorf("got %q, want %q", out, want) } } func TestEncodeCustomRootTypeEncodingError(t *testing.T) { type cType struct { Val int } in := cType{Val: 5} cerr := errors.New("encode error") SetTypeEncoding(reflect.TypeOf((*cType)(nil)), func(v interface{}) (interface{}, error) { return nil, cerr }, nil) _, err := Encode(&in) if err == nil { t.Errorf("got nil error, expected %v", cerr) } if err != cerr { t.Errorf("got %q, want %q", err, cerr) } } rethinkdb-go-6.2.1/encoding/encoder_types.go000066400000000000000000000236361363464422500211000ustar00rootroot00000000000000package encoding import ( "encoding/base64" "fmt" "math" "reflect" "time" ) // newTypeEncoder constructs an encoderFunc for a type. // The returned encoder only checks CanAddr when allowAddr is true. func newTypeEncoder(t reflect.Type, allowAddr bool) encoderFunc { if t.Implements(marshalerType) { return marshalerEncoder } if t.Kind() != reflect.Ptr && allowAddr { if reflect.PtrTo(t).Implements(marshalerType) { return newCondAddrEncoder(addrMarshalerEncoder, newTypeEncoder(t, false)) } } // Check for psuedo-types first switch t { case timeType: return timePseudoTypeEncoder } switch t.Kind() { case reflect.Bool: return boolEncoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intEncoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintEncoder case reflect.Float32: return float32Encoder case reflect.Float64: return floatEncoder case reflect.String: return stringEncoder case reflect.Interface: return interfaceEncoder case reflect.Struct: return newStructEncoder(t) case reflect.Map: return newMapEncoder(t) case reflect.Slice: return newSliceEncoder(t) case reflect.Array: return newArrayEncoder(t) case reflect.Ptr: return newPtrEncoder(t) case reflect.Func: // functions are a special case as they can be used internally for // optional arguments. Just return the raw function, if somebody tries // to pass a function to the database the JSON marshaller will catch this // anyway. return funcEncoder default: return unsupportedTypeEncoder } } func invalidValueEncoder(v reflect.Value) (interface{}, error) { return nil, nil } func doNothingEncoder(v reflect.Value) (interface{}, error) { return v.Interface(), nil } func marshalerEncoder(v reflect.Value) (interface{}, error) { if v.Kind() == reflect.Ptr && v.IsNil() { return nil, nil } m := v.Interface().(Marshaler) ev, err := m.MarshalRQL() if err != nil { return nil, &MarshalerError{v.Type(), err} } return ev, nil } func addrMarshalerEncoder(v reflect.Value) (interface{}, error) { va := v.Addr() if va.IsNil() { return nil, nil } m := va.Interface().(Marshaler) ev, err := m.MarshalRQL() if err != nil { return nil, &MarshalerError{v.Type(), err} } return ev, nil } func boolEncoder(v reflect.Value) (interface{}, error) { if v.Bool() { return true, nil } else { return false, nil } } func intEncoder(v reflect.Value) (interface{}, error) { return v.Int(), nil } func uintEncoder(v reflect.Value) (interface{}, error) { return v.Uint(), nil } func floatEncoder(v reflect.Value) (interface{}, error) { return v.Float(), nil } func float32Encoder(v reflect.Value) (interface{}, error) { return float32(v.Float()), nil } func stringEncoder(v reflect.Value) (interface{}, error) { return v.String(), nil } func interfaceEncoder(v reflect.Value) (interface{}, error) { if v.IsNil() { return nil, nil } return encode(v.Elem()) } func funcEncoder(v reflect.Value) (interface{}, error) { if v.IsNil() { return nil, nil } return v.Interface(), nil } func asStringEncoder(v reflect.Value) (interface{}, error) { return fmt.Sprintf("%v", v.Interface()), nil } func unsupportedTypeEncoder(v reflect.Value) (interface{}, error) { return nil, &UnsupportedTypeError{v.Type()} } type structEncoder struct { fields []field fieldEncs []encoderFunc } func (se *structEncoder) encode(v reflect.Value) (interface{}, error) { m := make(map[string]interface{}) for i, f := range se.fields { fv := fieldByIndex(v, f.index) if !fv.IsValid() || f.omitEmpty && se.isEmptyValue(fv) { continue } encField, err := se.fieldEncs[i](fv) if err != nil { return nil, err } // If this field is a referenced field then attempt to extract the value. if f.reference { // Override the encoded field with the referenced field encField = getReferenceField(f, v, encField) } if f.compound { compoundField, ok := m[f.name].([]interface{}) if !ok { compoundField = make([]interface{}, f.compoundIndex+1) } else if len(compoundField) < f.compoundIndex+1 { tmp := make([]interface{}, f.compoundIndex+1) copy(tmp, compoundField) compoundField = tmp } compoundField[f.compoundIndex] = encField encField = compoundField } m[f.name] = encField } return m, nil } func getReferenceField(f field, v reflect.Value, encField interface{}) interface{} { refName := f.name if f.refName != "" { refName = f.refName } encFields, isArray := encField.([]interface{}) if isArray { refVals := make([]interface{}, len(encFields)) for i, e := range encFields { refVals[i] = extractValue(e, v, f.name, refName) } return refVals } refVal := extractValue(encField, v, f.name, refName) return refVal } func extractValue(encField interface{}, v reflect.Value, name string, refName string) interface{} { // referenced fields can only handle maps so return an error if the // encoded field is of a different type m, ok := encField.(map[string]interface{}) if !ok { err := fmt.Errorf("Error refing field %s in %s, expected object but got %t", refName, name, encField) panic(&MarshalerError{v.Type(), err}) } refVal, ok := m[refName] if !ok { err := fmt.Errorf("Error refing field %s in %s, could not find referenced field", refName, name) panic(&MarshalerError{v.Type(), err}) } return refVal } func (se *structEncoder) isEmptyValue(v reflect.Value) bool { if v.Type() == timeType { return v.Interface().(time.Time) == time.Time{} } return isEmptyValue(v) } func newStructEncoder(t reflect.Type) encoderFunc { fields := cachedTypeFields(t) se := &structEncoder{ fields: fields, fieldEncs: make([]encoderFunc, len(fields)), } for i, f := range fields { se.fieldEncs[i] = typeEncoder(typeByIndex(t, f.index)) } return se.encode } type mapEncoder struct { keyEnc, elemEnc encoderFunc } func (me *mapEncoder) encode(v reflect.Value) (interface{}, error) { if v.IsNil() { return nil, nil } m := make(map[string]interface{}) for _, k := range v.MapKeys() { encV, err := me.elemEnc(v.MapIndex(k)) if err != nil { return nil, err } encK, err := me.keyEnc(k) if err != nil { return nil, err } m[encK.(string)] = encV } return m, nil } func newMapEncoder(t reflect.Type) encoderFunc { var keyEnc encoderFunc switch t.Key().Kind() { case reflect.Bool: keyEnc = asStringEncoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: keyEnc = asStringEncoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: keyEnc = asStringEncoder case reflect.Float32, reflect.Float64: keyEnc = asStringEncoder case reflect.String: keyEnc = stringEncoder case reflect.Interface: keyEnc = asStringEncoder default: return unsupportedTypeEncoder } me := &mapEncoder{keyEnc, typeEncoder(t.Elem())} return me.encode } // sliceEncoder just wraps an arrayEncoder, checking to make sure the value isn't nil. type sliceEncoder struct { arrayEnc encoderFunc } func (se *sliceEncoder) encode(v reflect.Value) (interface{}, error) { if v.IsNil() { return []interface{}(nil), nil } return se.arrayEnc(v) } func newSliceEncoder(t reflect.Type) encoderFunc { // Byte slices get special treatment; arrays don't. if t.Elem().Kind() == reflect.Uint8 { return encodeByteSlice } enc := &sliceEncoder{newArrayEncoder(t)} return enc.encode } type arrayEncoder struct { elemEnc encoderFunc } func (ae *arrayEncoder) encode(v reflect.Value) (interface{}, error) { n := v.Len() a := make([]interface{}, n) for i := 0; i < n; i++ { var err error a[i], err = ae.elemEnc(v.Index(i)) if err != nil { return nil, err } } return a, nil } func newArrayEncoder(t reflect.Type) encoderFunc { if t.Elem().Kind() == reflect.Uint8 { return encodeByteArray } enc := &arrayEncoder{typeEncoder(t.Elem())} return enc.encode } type ptrEncoder struct { elemEnc encoderFunc } func (pe *ptrEncoder) encode(v reflect.Value) (interface{}, error) { if v.IsNil() { return nil, nil } return pe.elemEnc(v.Elem()) } func newPtrEncoder(t reflect.Type) encoderFunc { enc := &ptrEncoder{typeEncoder(t.Elem())} return enc.encode } type condAddrEncoder struct { canAddrEnc, elseEnc encoderFunc } func (ce *condAddrEncoder) encode(v reflect.Value) (interface{}, error) { if v.CanAddr() { return ce.canAddrEnc(v) } else { return ce.elseEnc(v) } } // newCondAddrEncoder returns an encoder that checks whether its value // CanAddr and delegates to canAddrEnc if so, else to elseEnc. func newCondAddrEncoder(canAddrEnc, elseEnc encoderFunc) encoderFunc { enc := &condAddrEncoder{canAddrEnc: canAddrEnc, elseEnc: elseEnc} return enc.encode } // Pseudo-type encoders // Encode a time.Time value to the TIME RQL type func timePseudoTypeEncoder(v reflect.Value) (interface{}, error) { t := v.Interface().(time.Time) timeVal := float64(t.UnixNano()) / float64(time.Second) // use seconds-since-epoch precision if time.Time `t` // is before the oldest nanosecond time if t.Before(time.Unix(0, math.MinInt64)) { timeVal = float64(t.Unix()) } return map[string]interface{}{ "$reql_type$": "TIME", "epoch_time": timeVal, "timezone": t.Format("-07:00"), }, nil } // Encode a byte slice to the BINARY RQL type func encodeByteSlice(v reflect.Value) (interface{}, error) { var b []byte if !v.IsNil() { b = v.Bytes() } dst := make([]byte, base64.StdEncoding.EncodedLen(len(b))) base64.StdEncoding.Encode(dst, b) return map[string]interface{}{ "$reql_type$": "BINARY", "data": string(dst), }, nil } // Encode a byte array to the BINARY RQL type func encodeByteArray(v reflect.Value) (interface{}, error) { b := make([]byte, v.Len()) for i := 0; i < v.Len(); i++ { b[i] = v.Index(i).Interface().(byte) } dst := make([]byte, base64.StdEncoding.EncodedLen(len(b))) base64.StdEncoding.Encode(dst, b) return map[string]interface{}{ "$reql_type$": "BINARY", "data": string(dst), }, nil } rethinkdb-go-6.2.1/encoding/encoding.go000066400000000000000000000035451363464422500200200ustar00rootroot00000000000000package encoding import ( "reflect" "time" ) var ( // type constants stringType = reflect.TypeOf("") timeType = reflect.TypeOf(new(time.Time)).Elem() marshalerType = reflect.TypeOf(new(Marshaler)).Elem() unmarshalerType = reflect.TypeOf(new(Unmarshaler)).Elem() emptyInterfaceType = reflect.TypeOf((*interface{})(nil)).Elem() mapInterfaceType = reflect.TypeOf((map[string]interface{})(nil)) ) // Marshaler is the interface implemented by objects that // can marshal themselves into a valid RQL pseudo-type. type Marshaler interface { MarshalRQL() (interface{}, error) } // Unmarshaler is the interface implemented by objects // that can unmarshal a pseudo-type object of themselves. type Unmarshaler interface { UnmarshalRQL(interface{}) error } func init() { encoderCache.m = make(map[reflect.Type]encoderFunc) decoderCache.m = make(map[decoderCacheKey]decoderFunc) } // IgnoreType causes the encoder to ignore a type when encoding func IgnoreType(t reflect.Type) { encoderCache.Lock() encoderCache.m[t] = doNothingEncoder encoderCache.Unlock() } func SetTypeEncoding( t reflect.Type, encode func(value interface{}) (interface{}, error), decode func(encoded interface{}, value reflect.Value) error, ) { encoderCache.Lock() encoderCache.m[t] = func(v reflect.Value) (interface{}, error) { return encode(v.Interface()) } encoderCache.Unlock() dec := func(dv reflect.Value, sv reflect.Value) error { return decode(sv.Interface(), dv) } decoderCache.Lock() // decode as pointer decoderCache.m[decoderCacheKey{dt: t, st: emptyInterfaceType}] = dec // decode as value decoderCache.m[decoderCacheKey{dt: t, st: mapInterfaceType}] = dec if t.Kind() == reflect.Ptr { decoderCache.m[decoderCacheKey{dt: t.Elem(), st: emptyInterfaceType}] = dec decoderCache.m[decoderCacheKey{dt: t.Elem(), st: mapInterfaceType}] = dec } decoderCache.Unlock() } rethinkdb-go-6.2.1/encoding/encoding_test.go000066400000000000000000000001531363464422500210470ustar00rootroot00000000000000package encoding import ( // Import gocheck so that flag are setup (but unused) _ "gopkg.in/check.v1" ) rethinkdb-go-6.2.1/encoding/errors.go000066400000000000000000000047001363464422500175400ustar00rootroot00000000000000package encoding import ( "fmt" "reflect" "strings" ) type MarshalerError struct { Type reflect.Type Err error } func (e *MarshalerError) Error() string { return "rethinkdb: error calling MarshalRQL for type " + e.Type.String() + ": " + e.Err.Error() } type InvalidUnmarshalError struct { Type reflect.Type } func (e *InvalidUnmarshalError) Error() string { if e.Type == nil { return "rethinkdb: UnmarshalRQL(nil)" } if e.Type.Kind() != reflect.Ptr { return "rethinkdb: UnmarshalRQL(non-pointer " + e.Type.String() + ")" } return "rethinkdb: UnmarshalRQL(nil " + e.Type.String() + ")" } // An InvalidTypeError describes a value that was // not appropriate for a value of a specific Go type. type DecodeTypeError struct { DestType, SrcType reflect.Type Reason string } func (e *DecodeTypeError) Error() string { if e.Reason != "" { return "rethinkdb: could not decode type " + e.SrcType.String() + " into Go value of type " + e.DestType.String() + ": " + e.Reason } else { return "rethinkdb: could not decode type " + e.SrcType.String() + " into Go value of type " + e.DestType.String() } } // An UnsupportedTypeError is returned by Marshal when attempting // to encode an unsupported value type. type UnsupportedTypeError struct { Type reflect.Type } func (e *UnsupportedTypeError) Error() string { return "rethinkdb: unsupported type: " + e.Type.String() } // An UnsupportedTypeError is returned by Marshal when attempting // to encode an unexpected value type. type UnexpectedTypeError struct { DestType, SrcType reflect.Type } func (e *UnexpectedTypeError) Error() string { return "rethinkdb: expected type: " + e.DestType.String() + ", got " + e.SrcType.String() } type UnsupportedValueError struct { Value reflect.Value Str string } func (e *UnsupportedValueError) Error() string { return "rethinkdb: unsupported value: " + e.Str } // Error implements the error interface and can represents multiple // errors that occur in the course of a single decode. type Error struct { Errors []string } func (e *Error) Error() string { points := make([]string, len(e.Errors)) for i, err := range e.Errors { points[i] = fmt.Sprintf("* %s", err) } return fmt.Sprintf( "%d error(s) decoding:\n\n%s", len(e.Errors), strings.Join(points, "\n")) } func appendErrors(errors []string, err error) []string { switch e := err.(type) { case *Error: return append(errors, e.Errors...) default: return append(errors, e.Error()) } } rethinkdb-go-6.2.1/encoding/fold.go000066400000000000000000000063621363464422500171560ustar00rootroot00000000000000package encoding import ( "bytes" "unicode/utf8" ) const ( caseMask = ^byte(0x20) // Mask to ignore case in ASCII. kelvin = '\u212a' smallLongEss = '\u017f' ) // foldFunc returns one of four different case folding equivalence // functions, from most general (and slow) to fastest: // // 1) bytes.EqualFold, if the key s contains any non-ASCII UTF-8 // 2) equalFoldRight, if s contains special folding ASCII ('k', 'K', 's', 'S') // 3) asciiEqualFold, no special, but includes non-letters (including _) // 4) simpleLetterEqualFold, no specials, no non-letters. // // The letters S and K are special because they map to 3 runes, not just 2: // * S maps to s and to U+017F 'ſ' Latin small letter long s // * k maps to K and to U+212A 'K' Kelvin sign // See http://play.golang.org/p/tTxjOc0OGo // // The returned function is specialized for matching against s and // should only be given s. It's not curried for performance reasons. func foldFunc(s []byte) func(s, t []byte) bool { nonLetter := false special := false // special letter for _, b := range s { if b >= utf8.RuneSelf { return bytes.EqualFold } upper := b & caseMask if upper < 'A' || upper > 'Z' { nonLetter = true } else if upper == 'K' || upper == 'S' { // See above for why these letters are special. special = true } } if special { return equalFoldRight } if nonLetter { return asciiEqualFold } return simpleLetterEqualFold } // equalFoldRight is a specialization of bytes.EqualFold when s is // known to be all ASCII (including punctuation), but contains an 's', // 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t. // See comments on foldFunc. func equalFoldRight(s, t []byte) bool { for _, sb := range s { if len(t) == 0 { return false } tb := t[0] if tb < utf8.RuneSelf { if sb != tb { sbUpper := sb & caseMask if 'A' <= sbUpper && sbUpper <= 'Z' { if sbUpper != tb&caseMask { return false } } else { return false } } t = t[1:] continue } // sb is ASCII and t is not. t must be either kelvin // sign or long s; sb must be s, S, k, or K. tr, size := utf8.DecodeRune(t) switch sb { case 's', 'S': if tr != smallLongEss { return false } case 'k', 'K': if tr != kelvin { return false } default: return false } t = t[size:] } if len(t) > 0 { return false } return true } // asciiEqualFold is a specialization of bytes.EqualFold for use when // s is all ASCII (but may contain non-letters) and contains no // special-folding letters. // See comments on foldFunc. func asciiEqualFold(s, t []byte) bool { if len(s) != len(t) { return false } for i, sb := range s { tb := t[i] if sb == tb { continue } if ('a' <= sb && sb <= 'z') || ('A' <= sb && sb <= 'Z') { if sb&caseMask != tb&caseMask { return false } } else { return false } } return true } // simpleLetterEqualFold is a specialization of bytes.EqualFold for // use when s is all ASCII letters (no underscores, etc) and also // doesn't contain 'k', 'K', 's', or 'S'. // See comments on foldFunc. func simpleLetterEqualFold(s, t []byte) bool { if len(s) != len(t) { return false } for i, b := range s { if b&caseMask != t[i]&caseMask { return false } } return true } rethinkdb-go-6.2.1/encoding/tags.go000066400000000000000000000044401363464422500171630ustar00rootroot00000000000000// This code is based on encoding/json and gorilla/schema package encoding import ( "reflect" "strconv" "strings" "unicode" ) var ( Tags []string ) const ( TagName = "rethinkdb" OldTagName = "gorethink" JSONTagName = "json" RefTagName = "rethinkdb_ref" OldRefTagName = "gorethink_ref" ) // tagOptions is the string following a comma in a struct field's // tag, or the empty string. It does not include the leading comma. type tagOptions string func getTag(sf reflect.StructField) string { if Tags == nil { value := sf.Tag.Get(TagName) if value == "" { return sf.Tag.Get(OldTagName) } return value } for _, tagName := range Tags { if tag := sf.Tag.Get(tagName); tag != "" { return tag } } return "" } func getRefTag(sf reflect.StructField) string { value := sf.Tag.Get(RefTagName) if value == "" { return sf.Tag.Get(OldRefTagName) } return value } // parseTag splits a struct field's tag into its name and // comma-separated options. func parseTag(tag string) (string, tagOptions) { if idx := strings.Index(tag, ","); idx != -1 { return tag[:idx], tagOptions(tag[idx+1:]) } return tag, tagOptions("") } func parseCompoundIndex(tag string) (string, int, bool) { lIdx := strings.Index(tag, "[") rIdx := strings.Index(tag, "]") if lIdx > 1 && rIdx > lIdx+1 { if elemIndex_, err := strconv.ParseInt(tag[lIdx+1:rIdx], 10, 64); err == nil { return tag[:lIdx], int(elemIndex_), true } } return tag, 0, false } func isValidTag(s string) bool { if s == "" { return false } for _, c := range s { switch { case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): // Backslash and quote chars are reserved, but // otherwise any punctuation chars are allowed // in a tag name. default: if !unicode.IsLetter(c) && !unicode.IsDigit(c) { return false } } } return true } // Contains returns whether checks that a comma-separated list of options // contains a particular substr flag. substr must be surrounded by a // string boundary or commas. func (o tagOptions) Contains(optionName string) bool { if len(o) == 0 { return false } s := string(o) for s != "" { var next string i := strings.Index(s, ",") if i >= 0 { s, next = s[:i], s[i+1:] } if s == optionName { return true } s = next } return false } rethinkdb-go-6.2.1/encoding/utils.go000066400000000000000000000032341363464422500173650ustar00rootroot00000000000000package encoding import "reflect" func getTypeKind(t reflect.Type) reflect.Kind { kind := t.Kind() switch { case kind >= reflect.Int && kind <= reflect.Int64: return reflect.Int case kind >= reflect.Uint && kind <= reflect.Uint64: return reflect.Uint case kind >= reflect.Float32 && kind <= reflect.Float64: return reflect.Float32 default: return kind } } func isEmptyValue(v reflect.Value) bool { switch v.Kind() { case reflect.Array, reflect.Map, reflect.Slice, reflect.String: return v.Len() == 0 case reflect.Bool: return !v.Bool() case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return v.Int() == 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return v.Uint() == 0 case reflect.Float32, reflect.Float64: return v.Float() == 0 case reflect.Interface, reflect.Ptr: return v.IsNil() } return false } func fieldByIndex(v reflect.Value, index []int) reflect.Value { for _, i := range index { if v.Kind() == reflect.Ptr { if v.IsNil() { v.Set(reflect.New(v.Type().Elem())) } v = v.Elem() } v = v.Field(i) } return v } func typeByIndex(t reflect.Type, index []int) reflect.Type { for _, i := range index { if t.Kind() == reflect.Ptr { t = t.Elem() } t = t.Field(i).Type } return t } // valueByString sorts reflect.Value by the string value, this is useful for // sorting the result of MapKeys type valueByString []reflect.Value func (x valueByString) Len() int { return len(x) } func (x valueByString) Swap(i, j int) { x[i], x[j] = x[j], x[i] } func (x valueByString) Less(i, j int) bool { return x[i].String() < x[j].String() } rethinkdb-go-6.2.1/errors.go000066400000000000000000000122471363464422500157570ustar00rootroot00000000000000package rethinkdb import ( "bytes" "encoding/json" "errors" "fmt" "strings" p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2" ) var ( // ErrNoHosts is returned when no hosts to the Connect method. ErrNoHosts = errors.New("no hosts provided") // ErrNoConnectionsStarted is returned when the driver couldn't to any of // the provided hosts. ErrNoConnectionsStarted = errors.New("no connections were made when creating the session") // ErrInvalidNode is returned when attempting to connect to a node which // returns an invalid response. ErrInvalidNode = errors.New("invalid node") // ErrNoConnections is returned when there are no active connections in the // clusters connection pool. ErrNoConnections = errors.New("rethinkdb: no connections were available") // ErrConnectionClosed is returned when trying to send a query with a connClosed // connection. ErrConnectionClosed = errors.New("rethinkdb: the connection is closed") // ErrQueryTimeout is returned when query context deadline exceeded. ErrQueryTimeout = errors.New("rethinkdb: query timeout") ) func printCarrots(t Term, frames []*p.Frame) string { var frame *p.Frame if len(frames) > 1 { frame, frames = frames[0], frames[1:] } else if len(frames) == 1 { frame, frames = frames[0], []*p.Frame{} } for i, arg := range t.args { if frame.GetPos() == int64(i) { t.args[i] = Term{ termType: p.Term_DATUM, data: printCarrots(arg, frames), } } } for k, arg := range t.optArgs { if frame.GetOpt() == k { t.optArgs[k] = Term{ termType: p.Term_DATUM, data: printCarrots(arg, frames), } } } b := &bytes.Buffer{} for _, c := range t.String() { if c != '^' { b.WriteString(" ") } else { b.WriteString("^") } } return b.String() } // Error constants var ErrEmptyResult = errors.New("The result does not contain any more rows") // Connection/Response errors // rqlResponseError is the base type for all errors, it formats both // for the response and query if set. type rqlServerError struct { response *Response term *Term } func (e rqlServerError) Error() string { var err = "An error occurred" if e.response != nil { json.Unmarshal(e.response.Responses[0], &err) } if e.term == nil { return fmt.Sprintf("rethinkdb: %s", err) } return fmt.Sprintf("rethinkdb: %s in:\n%s", err, e.term.String()) } func (e rqlServerError) String() string { return e.Error() } type rqlError string func (e rqlError) Error() string { return fmt.Sprintf("rethinkdb: %s", string(e)) } func (e rqlError) String() string { return e.Error() } // Exported Error "Implementations" type RQLClientError struct{ rqlServerError } type RQLCompileError struct{ rqlServerError } type RQLDriverCompileError struct{ RQLCompileError } type RQLServerCompileError struct{ RQLCompileError } type RQLAuthError struct{ RQLDriverError } type RQLRuntimeError struct{ rqlServerError } type RQLQueryLogicError struct{ RQLRuntimeError } type RQLNonExistenceError struct{ RQLQueryLogicError } type RQLResourceLimitError struct{ RQLRuntimeError } type RQLUserError struct{ RQLRuntimeError } type RQLInternalError struct{ RQLRuntimeError } type RQLTimeoutError struct{ rqlServerError } type RQLAvailabilityError struct{ RQLRuntimeError } type RQLOpFailedError struct{ RQLAvailabilityError } type RQLOpIndeterminateError struct{ RQLAvailabilityError } // RQLDriverError represents an unexpected error with the driver, if this error // persists please create an issue. type RQLDriverError struct { rqlError } // RQLConnectionError represents an error when communicating with the database // server. type RQLConnectionError struct { rqlError } func createClientError(response *Response, term *Term) error { return RQLClientError{rqlServerError{response, term}} } func createCompileError(response *Response, term *Term) error { return RQLCompileError{rqlServerError{response, term}} } func createRuntimeError(errorType p.Response_ErrorType, response *Response, term *Term) error { serverErr := rqlServerError{response, term} switch errorType { case p.Response_QUERY_LOGIC: return RQLQueryLogicError{RQLRuntimeError{serverErr}} case p.Response_NON_EXISTENCE: return RQLNonExistenceError{RQLQueryLogicError{RQLRuntimeError{serverErr}}} case p.Response_RESOURCE_LIMIT: return RQLResourceLimitError{RQLRuntimeError{serverErr}} case p.Response_USER: return RQLUserError{RQLRuntimeError{serverErr}} case p.Response_INTERNAL: return RQLInternalError{RQLRuntimeError{serverErr}} case p.Response_OP_FAILED: return RQLOpFailedError{RQLAvailabilityError{RQLRuntimeError{serverErr}}} case p.Response_OP_INDETERMINATE: return RQLOpIndeterminateError{RQLAvailabilityError{RQLRuntimeError{serverErr}}} default: return RQLRuntimeError{serverErr} } } // Error type helpers // IsConflictErr returns true if the error is non-nil and the query failed // due to a duplicate primary key. func IsConflictErr(err error) bool { if err == nil { return false } return strings.HasPrefix(err.Error(), "Duplicate primary key") } // IsTypeErr returns true if the error is non-nil and the query failed due // to a type error. func IsTypeErr(err error) bool { if err == nil { return false } return strings.HasPrefix(err.Error(), "Expected type") } rethinkdb-go-6.2.1/go.mod000066400000000000000000000020251363464422500152130ustar00rootroot00000000000000module gopkg.in/rethinkdb/rethinkdb-go.v6 require ( github.com/bitly/go-hostpool v0.1.0 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect github.com/golang/protobuf v1.3.4 github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed github.com/kr/pretty v0.1.0 // indirect github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/onsi/ginkgo v1.12.0 // indirect github.com/onsi/gomega v1.9.0 // indirect github.com/opentracing/opentracing-go v1.1.0 github.com/sirupsen/logrus v1.0.6 github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.5.1 golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect gopkg.in/cenkalti/backoff.v2 v2.2.1 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect gopkg.in/yaml.v2 v2.2.8 // indirect ) go 1.14 rethinkdb-go-6.2.1/go.sum000066400000000000000000000162021363464422500152420ustar00rootroot00000000000000github.com/bitly/go-hostpool v0.1.0 h1:XKmsF6k5el6xHG3WPJ8U0Ku/ye7njX7W81Ng7O2ioR0= github.com/bitly/go-hostpool v0.1.0/go.mod h1:4gOCgp6+NZnVqlKyZ/iBZFTAJKembaVENUpMkpg42fw= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/cenkalti/backoff/v4 v4.0.0 h1:6VeaLF9aI+MAUQ95106HwWzYZgJJpZ4stumjj6RFYAU= github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.0.6 h1:hcP1GmhGigz/O7h1WVUM5KklBp1JoNS9FggWKdj/j3s= github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII= gopkg.in/cenkalti/backoff.v2 v2.2.1/go.mod h1:S0QdOvT2AlerfSBkp0O+dk+bbIMaNbEmVk876gPCthU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= rethinkdb-go-6.2.1/host.go000066400000000000000000000005361363464422500154160ustar00rootroot00000000000000package rethinkdb import ( "fmt" ) // Host name and port of server type Host struct { Name string Port int } // NewHost create a new Host func NewHost(name string, port int) Host { return Host{ Name: name, Port: port, } } // Returns host address (name:port) func (h Host) String() string { return fmt.Sprintf("%s:%d", h.Name, h.Port) } rethinkdb-go-6.2.1/internal/000077500000000000000000000000001363464422500157225ustar00rootroot00000000000000rethinkdb-go-6.2.1/internal/compare/000077500000000000000000000000001363464422500173505ustar00rootroot00000000000000rethinkdb-go-6.2.1/internal/compare/compare.go000066400000000000000000000214251363464422500213310ustar00rootroot00000000000000package compare import ( "fmt" "math" "reflect" "regexp" "strconv" "testing" "github.com/stretchr/testify/assert" ) var AnythingIsFine = "reql_test.AnythingIsFine" func Assert(t *testing.T, expected, actual interface{}) { expectedVal := expected if e, ok := expected.(Expected); ok { expectedVal = e.Val } ok, msg := Compare(expected, actual) if !ok { assert.Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n != %#v (actual)", expectedVal, actual), msg) } } func AssertFalse(t *testing.T, expected, actual interface{}) { expectedVal := expected if e, ok := expected.(Expected); ok { expectedVal = e.Val } ok, msg := Compare(expected, actual) if ok { assert.Fail(t, fmt.Sprintf("Should not be equal: %#v (expected)\n == %#v (actual)", expectedVal, actual), msg) } } func AssertPrecision(t *testing.T, expected, actual interface{}, precision float64) { expectedVal := expected if e, ok := expected.(Expected); ok { expectedVal = e.Val } ok, msg := ComparePrecision(expected, actual, precision) if !ok { assert.Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n != %#v (actual)", expectedVal, actual), msg) } } func AssertPrecisionFalse(t *testing.T, expected, actual interface{}, precision float64) { expectedVal := expected if e, ok := expected.(Expected); ok { expectedVal = e.Val } ok, msg := ComparePrecision(expected, actual, precision) if ok { assert.Fail(t, fmt.Sprintf("Should not be equal: %#v (expected)\n == %#v (actual)", expectedVal, actual), msg) } } func Compare(expected, actual interface{}) (bool, string) { return ComparePrecision(expected, actual, 0.00000000001) } func ComparePrecision(expected, actual interface{}, precision float64) (bool, string) { return compare(expected, actual, true, false, precision) } func compare(expected, actual interface{}, ordered, partial bool, precision float64) (bool, string) { if e, ok := expected.(Expected); ok { partial = e.Partial ordered = e.Ordered expected = e.Val } // Anything if expected == AnythingIsFine { return true, "" } expectedVal := reflect.ValueOf(expected) actualVal := reflect.ValueOf(actual) // Nil if expected == nil { switch actualVal.Kind() { case reflect.Bool: expected = false case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64: expected = 0.0 case reflect.String: expected = "" } if expected == actual { return true, "" } } // Regex if expr, ok := expected.(Regex); ok { re, err := regexp.Compile(string(expr)) if err != nil { return false, fmt.Sprintf("Failed to compile regexp: %s", err) } if actualVal.Kind() != reflect.String { return false, fmt.Sprintf("Expected string, got %t (%T)", actual, actual) } if !re.MatchString(actualVal.String()) { return false, fmt.Sprintf("Value %v did not match regexp '%s'", actual, expr) } return true, "" } switch expectedVal.Kind() { // Bool case reflect.Bool: if expected == actual { return true, "" } // Number case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64: switch actualVal.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: diff := math.Abs(reflectNumber(expectedVal) - reflectNumber(actualVal)) if diff <= precision { return true, "" } if precision != 0 { return false, fmt.Sprintf("Value %v was not within %f of %v", expected, precision, actual) } return false, fmt.Sprintf("Expected %v but got %v", expected, actual) } // String case reflect.String: actualStr := fmt.Sprintf("%v", actual) if expected == actualStr { return true, "" } // Struct case reflect.Struct: // Convert expected struct to map and compare with actual value return compare(reflectMap(expectedVal), actual, ordered, partial, precision) // Map case reflect.Map: switch actualVal.Kind() { case reflect.Struct: // Convert actual struct to map and compare with expected map return compare(expected, reflectMap(actualVal), ordered, partial, precision) case reflect.Map: expectedKeys := expectedVal.MapKeys() actualKeys := actualVal.MapKeys() for _, expectedKey := range expectedKeys { keyFound := false for _, actualKey := range actualKeys { if ok, _ := Compare(expectedKey.Interface(), actualKey.Interface()); ok { keyFound = true break } } if !keyFound { return false, fmt.Sprintf("Expected field %v but not found", expectedKey) } } if !partial { expectedKeyVals := reflectMapKeys(expectedKeys) actualKeyVals := reflectMapKeys(actualKeys) if ok, _ := compare(expectedKeyVals, actualKeyVals, false, false, 0.0); !ok { return false, fmt.Sprintf( "Unmatched keys from either side: expected fields %v, got %v", expectedKeyVals, actualKeyVals, ) } } expectedMap := reflectMap(expectedVal) actualMap := reflectMap(actualVal) for k, v := range expectedMap { if ok, reason := compare(v, actualMap[k], ordered, partial, precision); !ok { return false, reason } } return true, "" default: return false, fmt.Sprintf("Expected map, got %v (%T)", actual, actual) } // Slice/Array case reflect.Slice, reflect.Array: switch actualVal.Kind() { case reflect.Slice, reflect.Array: if ordered { expectedArr := reflectSlice(expectedVal) actualArr := reflectSlice(actualVal) j := 0 for i := 0; i < len(expectedArr); i++ { expectedArrVal := expectedArr[i] for { if j >= len(actualArr) { return false, fmt.Sprintf("Ran out of results before finding %v", expectedArrVal) } actualArrVal := actualArr[j] j++ if ok, _ := compare(expectedArrVal, actualArrVal, ordered, partial, precision); ok { break } else if !partial { return false, fmt.Sprintf("Unexpected item %v while looking for %v", actualArrVal, expectedArrVal) } } } if !partial && j < len(actualArr) { return false, fmt.Sprintf("Unexpected extra results: %v", actualArr[j:]) } } else { expectedArr := reflectSlice(expectedVal) actualArr := reflectSlice(actualVal) for _, expectedArrVal := range expectedArr { found := false for j, actualArrVal := range actualArr { if ok, _ := compare(expectedArrVal, actualArrVal, ordered, partial, precision); ok { found = true actualArr = append(actualArr[:j], actualArr[j+1:]...) break } } if !found { return false, fmt.Sprintf("Missing expected item %v", expectedArrVal) } } if !partial && len(actualArr) > 0 { return false, fmt.Sprintf("Extra items returned: %v", expectedArr) } } return true, "" } // Other default: if expected == actual { return true, "" } } return false, fmt.Sprintf("Expected %v (%T) but got %v (%T)", expected, expected, actual, actual) } func reflectNumber(v reflect.Value) float64 { switch v.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return float64(v.Int()) case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return float64(v.Uint()) case reflect.Float32, reflect.Float64: return v.Float() case reflect.String: f, _ := strconv.ParseFloat(v.String(), 64) return f default: return float64(0) } } func reflectMap(v reflect.Value) map[interface{}]interface{} { switch v.Kind() { case reflect.Struct: m := map[interface{}]interface{}{} for i := 0; i < v.NumField(); i++ { sf := v.Type().Field(i) if sf.PkgPath != "" && !sf.Anonymous { continue // unexported } k := sf.Name v := v.Field(i).Interface() m[k] = v } return m case reflect.Map: m := map[interface{}]interface{}{} for _, mk := range v.MapKeys() { k := "" if mk.Interface() != nil { k = fmt.Sprintf("%v", mk.Interface()) } v := v.MapIndex(mk).Interface() m[k] = v } return m default: return nil } } func reflectSlice(v reflect.Value) []interface{} { switch v.Kind() { case reflect.Slice, reflect.Array: s := []interface{}{} for i := 0; i < v.Len(); i++ { s = append(s, v.Index(i).Interface()) } return s default: return nil } } func reflectMapKeys(keys []reflect.Value) []interface{} { s := []interface{}{} for _, key := range keys { s = append(s, key.Interface()) } return s } func reflectInterfaces(vals []reflect.Value) []interface{} { ret := []interface{}{} for _, val := range vals { ret = append(ret, val.Interface()) } return ret } rethinkdb-go-6.2.1/internal/compare/compare_test.go000066400000000000000000000207341363464422500223720ustar00rootroot00000000000000package compare import "testing" func TestCompareString(t *testing.T) { // simple Assert(t, "a", "a") Assert(t, "á", "á") Assert(t, "something longer\nwith two lines", "something longer\nwith two lines") AssertFalse(t, "a", "b") AssertFalse(t, "a", 1) AssertFalse(t, "a", []interface{}{}) AssertFalse(t, "a", nil) AssertFalse(t, "a", []interface{}{"a"}) AssertFalse(t, "a", map[string]interface{}{"a": 1}) } func TestCompareArray(t *testing.T) { // simple pass Assert(t, []interface{}{1, 2, 3}, []interface{}{1, 2, 3}) // out of order AssertFalse(t, []interface{}{1, 2, 3}, []interface{}{1, 3, 2}) // totally mistmatched lists AssertFalse(t, []interface{}{1, 2, 3}, []interface{}{3, 4, 5}) // missing items AssertFalse(t, []interface{}{1, 2, 3}, []interface{}{1, 2}) AssertFalse(t, []interface{}{1, 2, 3}, []interface{}{1, 3}) // extra items AssertFalse(t, []interface{}{1, 2, 3}, []interface{}{1, 2, 3, 4}) // empty array Assert(t, []interface{}{}, []interface{}{}) AssertFalse(t, []interface{}{1}, []interface{}{}) AssertFalse(t, []interface{}{}, []interface{}{1}) AssertFalse(t, []interface{}{}, nil) // strings Assert(t, []interface{}{"a", "b"}, []interface{}{"a", "b"}) AssertFalse(t, []interface{}{"a", "c"}, []interface{}{"a", "b"}) // multiple of a single value Assert(t, []interface{}{1, 2, 2, 3, 3, 3}, []interface{}{1, 2, 2, 3, 3, 3}) AssertFalse(t, []interface{}{1, 2, 2, 3, 3, 3}, []interface{}{1, 2, 3}) AssertFalse(t, []interface{}{1, 2, 3}, []interface{}{1, 2, 2, 3, 3, 3}) } func TestCompareArray_PartialMatch(t *testing.T) { // note that these are all in-order // simple Assert(t, PartialMatch([]interface{}{1}), []interface{}{1, 2, 3}) Assert(t, PartialMatch([]interface{}{2}), []interface{}{1, 2, 3}) Assert(t, PartialMatch([]interface{}{3}), []interface{}{1, 2, 3}) Assert(t, PartialMatch([]interface{}{1, 2}), []interface{}{1, 2, 3}) Assert(t, PartialMatch([]interface{}{1, 3}), []interface{}{1, 2, 3}) Assert(t, PartialMatch([]interface{}{1, 2, 3}), []interface{}{1, 2, 3}) AssertFalse(t, PartialMatch([]interface{}{4}), []interface{}{1, 2, 3}) // ordered AssertFalse(t, PartialMatch([]interface{}{3, 2, 1}).SetOrdered(true), []interface{}{1, 2, 3}) AssertFalse(t, PartialMatch([]interface{}{1, 3, 2}).SetOrdered(true), []interface{}{1, 2, 3}) // empty array Assert(t, PartialMatch([]interface{}{}), []interface{}{1, 2, 3}) // multiple of a single items Assert(t, PartialMatch([]interface{}{1, 2, 2}), []interface{}{1, 2, 2, 3, 3, 3}) AssertFalse(t, PartialMatch([]interface{}{1, 2, 2, 2}), []interface{}{1, 2, 2, 3, 3, 3}) } func TestCompareArray_unordered(t *testing.T) { // simple Assert(t, UnorderedMatch([]interface{}{1, 2}), []interface{}{1, 2}) Assert(t, UnorderedMatch([]interface{}{2, 1}), []interface{}{1, 2}) AssertFalse(t, UnorderedMatch([]interface{}{1, 2}), []interface{}{1, 2, 3}) AssertFalse(t, UnorderedMatch([]interface{}{1, 3}), []interface{}{1, 2, 3}) AssertFalse(t, UnorderedMatch([]interface{}{3, 1}), []interface{}{1, 2, 3}) // empty array Assert(t, UnorderedMatch([]interface{}{}), []interface{}{}) } func TestCompareMap(t *testing.T) { // simple Assert(t, map[string]interface{}{"a": 1, "b": 2, "c": 3}, map[string]interface{}{"a": 1, "b": 2, "c": 3}) Assert(t, map[string]interface{}{"a": 1, "b": 2, "c": 3}, map[string]interface{}{"c": 3, "a": 1, "b": 2}) AssertFalse(t, map[string]interface{}{"a": 1, "b": 2, "c": 3}, map[string]interface{}{"a": 1}) AssertFalse(t, map[string]interface{}{"a": 1}, map[string]interface{}{"a": 1, "b": 2, "c": 3}) // empty Assert(t, map[string]interface{}{}, map[string]interface{}{}) AssertFalse(t, map[string]interface{}{}, map[string]interface{}{"a": 1}) AssertFalse(t, map[string]interface{}{"a": 1}, map[string]interface{}{}) Assert(t, map[interface{}]interface{}{1: 1225, 2: 1250, 3: 1275, 0: 1200}, map[string]interface{}{"2": 1250, "3": 1275, "0": 1200, "1": 1225}) Assert(t, map[interface{}]interface{}{0: 22, 20: 22, 30: 23}, map[string]interface{}{"30": 23, "0": 22, "20": 22}) } func TestCompareMap_PartialMatch(t *testing.T) { // simple Assert(t, PartialMatch(map[string]interface{}{"a": 1}), map[string]interface{}{"a": 1}) Assert(t, PartialMatch(map[string]interface{}{"a": 1}), map[string]interface{}{"a": 1, "b": 2}) AssertFalse(t, PartialMatch(map[string]interface{}{"a": 2}), map[string]interface{}{"a": 1, "b": 2}) AssertFalse(t, PartialMatch(map[string]interface{}{"c": 1}), map[string]interface{}{"a": 1, "b": 2}) AssertFalse(t, PartialMatch(map[string]interface{}{"a": 1, "b": 2}), map[string]interface{}{"b": 2}) // empty Assert(t, PartialMatch(map[string]interface{}{}), map[string]interface{}{}) Assert(t, PartialMatch(map[string]interface{}{}), map[string]interface{}{"a": 1}) AssertFalse(t, PartialMatch(map[string]interface{}{"a": 1}), map[string]interface{}{}) } func TestCompareMap_inSlice(t *testing.T) { // simple Assert(t, []interface{}{map[string]interface{}{"a": 1}}, []interface{}{map[string]interface{}{"a": 1}}) Assert(t, []interface{}{map[string]interface{}{"a": 1, "b": 2}}, []interface{}{map[string]interface{}{"a": 1, "b": 2}}) Assert(t, []interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}, []interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}) AssertFalse(t, []interface{}{map[string]interface{}{"a": 1}}, []interface{}{map[string]interface{}{"a": 1, "b": 2}}) AssertFalse(t, []interface{}{map[string]interface{}{"a": 2, "b": 2}}, []interface{}{map[string]interface{}{"a": 1, "b": 2}}) AssertFalse(t, []interface{}{map[string]interface{}{"a": 2, "c": 3}}, []interface{}{map[string]interface{}{"a": 1, "b": 2}}) AssertFalse(t, []interface{}{map[string]interface{}{"a": 2, "c": 3}}, []interface{}{map[string]interface{}{"a": 1}}) AssertFalse(t, []interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}, []interface{}{map[string]interface{}{"a": 1, "b": 2}}) // order AssertFalse(t, []interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}, []interface{}{map[string]interface{}{"b": 2}, map[string]interface{}{"a": 1}}) // partial Assert(t, PartialMatch([]interface{}{map[string]interface{}{}}), []interface{}{map[string]interface{}{"a": 1, "b": 2}}) Assert(t, PartialMatch([]interface{}{map[string]interface{}{}}), []interface{}{map[string]interface{}{"a": 1, "b": 2}}) Assert(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1}}), []interface{}{map[string]interface{}{"a": 1, "b": 2}}) Assert(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1, "b": 2}}), []interface{}{map[string]interface{}{"a": 1, "b": 2}}) Assert(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}), []interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}, map[string]interface{}{"c": 3}}) AssertFalse(t, PartialMatch([]interface{}{map[string]interface{}{"a": 2}}), []interface{}{map[string]interface{}{"a": 1, "b": 2}}) AssertFalse(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1, "b": 2}}), []interface{}{map[string]interface{}{"a": 1}}) // partial order AssertFalse(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}).SetOrdered(true), []interface{}{map[string]interface{}{"b": 2}, map[string]interface{}{"a": 1}}) // partial unordered Assert(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}), []interface{}{map[string]interface{}{"b": 2}, map[string]interface{}{"a": 1}}) Assert(t, PartialMatch([]interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"b": 2}}).SetOrdered(false), []interface{}{map[string]interface{}{"b": 2}, map[string]interface{}{"a": 1}}) Assert(t, []interface{}{map[string]interface{}{"a": 1, "b": 1}, PartialMatch(map[string]interface{}{"a": 2})}, []interface{}{map[string]interface{}{"a": 1, "b": 1}, map[string]interface{}{"a": 2, "b": 2}}) } func TestCompareUUID(t *testing.T) { // simple Assert(t, IsUUID(), "4e9e5bc2-9b11-4143-9aa1-75c10e7a193a") AssertFalse(t, IsUUID(), "4") AssertFalse(t, IsUUID(), "*") AssertFalse(t, IsUUID(), nil) } func TestCompareNumbers(t *testing.T) { // simple Assert(t, 1, 1) Assert(t, 1, 1.0) Assert(t, 1.0, 1) Assert(t, 1.0, 1.0) AssertFalse(t, 1, 2) AssertFalse(t, 1, 2.0) AssertFalse(t, 1.0, 2) AssertFalse(t, 1.0, 2.0) // precision AssertPrecision(t, 1, 1.4, 0.5) AssertPrecision(t, 1.0, 1.4, 0.5) AssertPrecisionFalse(t, 1, 2, 0.5) AssertPrecisionFalse(t, 1, 1.6, 0.5) AssertPrecisionFalse(t, 1.0, 2, 0.5) AssertPrecisionFalse(t, 1.0, 1.6, 0.5) } rethinkdb-go-6.2.1/internal/compare/expected.go000066400000000000000000000014071363464422500215020ustar00rootroot00000000000000package compare type Expected struct { Fetch bool Partial bool Ordered bool FetchCount int Val interface{} } func (expected Expected) SetOrdered(ordered bool) Expected { expected.Ordered = ordered return expected } func (expected Expected) SetPartial(partial bool) Expected { expected.Partial = partial return expected } type Regex string func IsUUID() Regex { return Regex("[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}") } func MatchesRegexp(expr string) Regex { return Regex(expr) } func UnorderedMatch(v interface{}) Expected { return Expected{ Ordered: false, Partial: false, Val: v, } } func PartialMatch(v interface{}) Expected { return Expected{ Ordered: false, Partial: true, Val: v, } } rethinkdb-go-6.2.1/internal/gen_tests/000077500000000000000000000000001363464422500177155ustar00rootroot00000000000000rethinkdb-go-6.2.1/internal/gen_tests/gen_tests.py000077500000000000000000001077411363464422500222770ustar00rootroot00000000000000#!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Finds yaml tests, converts them to Go tests.''' from __future__ import print_function import sys import os import os.path import re import time import ast from re import sub, match, split, DOTALL import argparse import codecs import logging import process_polyglot import parse_polyglot from process_polyglot import Unhandled, Skip, FatalSkip, SkippedTest from mako.template import Template try: from cStringIO import StringIO except ImportError: from io import StringIO from collections import namedtuple parse_polyglot.printDebug = False logger = logging.getLogger("convert_tests") r = None TEST_EXCLUSIONS = [ # python only tests # 'regression/1133', # 'regression/767', # 'regression/1005', 'regression/', 'limits', # pending fix in issue #4965 # double run 'changefeeds/squash', 'arity', '.rb.yaml', ] GO_KEYWORDS = [ 'break', 'case', 'chan', 'const', 'continue', 'default', 'defer', 'else', 'fallthrough', 'for', 'func', 'go', 'goto', 'if', 'import', 'interface', 'map', 'package', 'range', 'return', 'select', 'struct', 'switch', 'type', 'var' ] def main(): logging.basicConfig(format="[%(name)s] %(message)s", level=logging.INFO) start = time.clock() args = parse_args() if args.debug: logger.setLevel(logging.DEBUG) logging.getLogger('process_polyglot').setLevel(logging.DEBUG) elif args.info: logger.setLevel(logging.INFO) logging.getLogger('process_polyglot').setLevel(logging.INFO) else: logger.root.setLevel(logging.WARNING) if args.e: evaluate_snippet(args.e) exit(0) global r r = import_python_driver(args.python_driver_dir) renderer = Renderer( invoking_filenames=[ __file__, process_polyglot.__file__, ]) for testfile in process_polyglot.all_yaml_tests( args.test_dir, TEST_EXCLUSIONS): logger.info("Working on %s", testfile) TestFile( test_dir=args.test_dir, filename=testfile, test_output_dir=args.test_output_dir, renderer=renderer, ).load().render() logger.info("Finished in %s seconds", time.clock() - start) def parse_args(): '''Parse command line arguments''' parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "--test-dir", help="Directory where yaml tests are", default="" ) parser.add_argument( "--test-output-dir", help="Directory to render tests to", default=".", ) parser.add_argument( "--python-driver-dir", help="Where the built python driver is located", default="" ) parser.add_argument( "--test-file", help="Only convert the specified yaml file", ) parser.add_argument( '--debug', help="Print debug output", dest='debug', action='store_true') parser.set_defaults(debug=False) parser.add_argument( '--info', help="Print info level output", dest='info', action='store_true') parser.set_defaults(info=False) parser.add_argument( '-e', help="Convert an inline python reql to go reql snippet", ) return parser.parse_args() def import_python_driver(py_driver_dir): '''Imports the test driver header''' stashed_path = sys.path sys.path.insert(0, os.path.realpath(py_driver_dir)) import rethinkdb as r sys.path = stashed_path return r GoQuery = namedtuple( 'GoQuery', ('is_value', 'line', 'expected_type', 'expected_line', 'testfile', 'line_num', 'runopts') ) GoDef = namedtuple( 'GoDef', ('line', 'varname', 'vartype', 'value', 'run_if_query', 'testfile', 'line_num', 'runopts') ) Version = namedtuple("Version", "original go") GO_DECL = re.compile(r'var (?P\w+) (?P.+) = (?P.*)') def evaluate_snippet(snippet): '''Just converts a single expression snippet into java''' try: parsed = ast.parse(snippet, mode='eval').body except Exception as e: return print("Error:", e) try: print(ReQLVisitor(smart_bracket=True).convert(parsed)) except Exception as e: return print("Error:", e) class TestFile(object): '''Represents a single test file''' def __init__(self, test_dir, filename, test_output_dir, renderer): self.filename = filename self.full_path = os.path.join(test_dir, filename) self.module_name = filename.split('.')[0].replace('/', '_') self.test_output_dir = test_output_dir self.reql_vars = {'r'} self.renderer = renderer def load(self): '''Load the test file, yaml parse it, extract file-level metadata''' with open(self.full_path, encoding='utf-8') as f: parsed_yaml = parse_polyglot.parseYAML(f) self.description = parsed_yaml.get('desc', 'No description') self.table_var_names = self.get_varnames(parsed_yaml) self.reql_vars.update(self.table_var_names) self.raw_test_data = parsed_yaml['tests'] self.test_generator = process_polyglot.tests_and_defs( self.filename, self.raw_test_data, context=process_polyglot.create_context(r, self.table_var_names), custom_field='go', ) return self def get_varnames(self, yaml_file): '''Extract table variable names from yaml variable They can be specified just space separated, or comma separated''' raw_var_names = yaml_file.get('table_variable_name', '') if not raw_var_names: return set() return set(re.split(r'[, ]+', raw_var_names)) def render(self): '''Renders the converted tests to a runnable test file''' defs_and_test = ast_to_go(self.test_generator, self.reql_vars) self.renderer.source_files = [self.full_path] self.renderer.render( 'template.go', output_dir=self.test_output_dir, output_name='reql_' + self.module_name + '_test.go', dependencies=[self.full_path], defs_and_test=defs_and_test, table_var_names=list(sorted(self.table_var_names)), module_name=camel(self.module_name), GoQuery=GoQuery, GoDef=GoDef, description=self.description, ) def py_to_go_type(py_type): '''Converts python types to their Go equivalents''' if py_type is None: return None elif isinstance(py_type, str): # This can be called on something already converted return py_type elif py_type.__name__ == 'function': return 'func()' elif (py_type.__module__ == 'datetime' and py_type.__name__ == 'datetime'): return 'time.Time' elif py_type.__module__ == 'builtins': if py_type.__name__.endswith('Error'): return 'error' return { bool: 'bool', bytes: '[]byte', int: 'int', float: 'float64', str: 'string', dict: 'map[interface{}]interface{}', list: '[]interface{}', object: 'map[interface{}]interface{}', type(None): 'interface{}', }[py_type] elif py_type.__module__ == 'rethinkdb.ast': return "r.Term" # Anomalous non-rule based capitalization in the python driver # return { # }.get(py_type.__name__, py_type.__name__) elif py_type.__module__ == 'rethinkdb.errors': return py_type.__name__ elif py_type.__module__ == '?test?': return { 'int_cmp': 'int', 'float_cmp': 'float64', 'err_regex': 'Err', 'partial': 'compare.Expected', 'bag': 'compare.Expected', 'uuid': 'compare.Regex', # clashes with ast.Uuid }.get(py_type.__name__, camel(py_type.__name__)) elif py_type.__module__ == 'rethinkdb.query': # All of the constants like minval maxval etc are defined in # query.py, but no type name is provided to `type`, so we have # to pull it out of a class variable return camel(py_type.st) else: raise Unhandled( "Don't know how to convert python type {}.{} to Go" .format(py_type.__module__, py_type.__name__)) def def_to_go(item, reql_vars): if is_reql(item.term.type): reql_vars.add(item.varname) try: if is_reql(item.term.type): visitor = ReQLVisitor else: visitor = GoVisitor go_line = visitor(reql_vars, type_=item.term.type, is_def=True, ).convert(item.term.ast) except Skip as skip: return SkippedTest(line=item.term.line, reason=str(skip)) go_decl = GO_DECL.match(go_line).groupdict() return GoDef( line=Version( original=item.term.line, go=go_line, ), varname=go_decl['var'], vartype=go_decl['type'], value=go_decl['value'], run_if_query=item.run_if_query, testfile=item.testfile, line_num=item.line_num, runopts=convert_runopts(reql_vars, go_decl['type'], item.runopts) ) def query_to_go(item, reql_vars): if item.runopts is not None: converted_runopts = convert_runopts( reql_vars, item.query.type, item.runopts) else: converted_runopts = item.runopts if converted_runopts is None: converted_runopts = {} converted_runopts['GeometryFormat'] = '\"raw\"' if 'GroupFormat' not in converted_runopts: converted_runopts['GroupFormat'] = '\"map\"' try: is_value = False if not item.query.type.__module__.startswith("rethinkdb.") or (not item.query.type.__module__.startswith("rethinkdb.") and item.query.type.__name__.endswith("Error")): is_value = True go_line = ReQLVisitor( reql_vars, type_=item.query.type).convert(item.query.ast) if is_reql(item.expected.type): visitor = ReQLVisitor else: visitor = GoVisitor go_expected_line = visitor( reql_vars, type_=item.expected.type)\ .convert(item.expected.ast) except Skip as skip: return SkippedTest(line=item.query.line, reason=str(skip)) return GoQuery( is_value=is_value, line=Version( original=item.query.line, go=go_line, ), expected_type=py_to_go_type(item.expected.type), expected_line=Version( original=item.expected.line, go=go_expected_line, ), testfile=item.testfile, line_num=item.line_num, runopts=converted_runopts, ) def ast_to_go(sequence, reql_vars): '''Converts the the parsed test data to go source lines using the visitor classes''' reql_vars = set(reql_vars) for item in sequence: if type(item) == process_polyglot.Def: yield def_to_go(item, reql_vars) elif type(item) == process_polyglot.CustomDef: yield GoDef(line=Version(item.line, item.line), testfile=item.testfile, line_num=item.line_num) elif type(item) == process_polyglot.Query: yield query_to_go(item, reql_vars) elif type(item) == SkippedTest: yield item else: assert False, "shouldn't happen, item was {}".format(item) def is_reql(t): '''Determines if a type is a reql term''' # Other options for module: builtins, ?test?, datetime if not hasattr(t, '__module__'): return True return t.__module__ == 'rethinkdb.ast' def escape_string(s, out): out.write('"') for codepoint in s: rpr = repr(codepoint)[1:-1] if rpr.startswith('\\x'): rpr = '\\u00' + rpr[2:] elif rpr == '"': rpr = r'\"' out.write(rpr) out.write('"') def attr_matches(path, node): '''Helper function. Several places need to know if they are an attribute of some root object''' root, name = path.split('.') ret = is_name(root, node.value) and node.attr == name return ret def is_name(name, node): '''Determine if the current attribute node is a Name with the given name''' return type(node) == ast.Name and node.id == name def convert_runopts(reql_vars, type_, runopts): if runopts is None: return None return { camel(key): GoVisitor( reql_vars, type_=type_).convert(val) for key, val in runopts.items() } class GoVisitor(ast.NodeVisitor): '''Converts python ast nodes into a Go string''' def __init__(self, reql_vars=frozenset("r"), out=None, type_=None, is_def=False, smart_bracket=False, ): self.out = StringIO() if out is None else out self.reql_vars = reql_vars self.type = py_to_go_type(type_) self._type = type_ self.is_def = is_def self.smart_bracket = smart_bracket super(GoVisitor, self).__init__() self.write = self.out.write def skip(self, message, *args, **kwargs): cls = Skip is_fatal = kwargs.pop('fatal', False) if self.is_def or is_fatal: cls = FatalSkip raise cls(message, *args, **kwargs) def convert(self, node): '''Convert a text line to another text line''' self.visit(node) return self.out.getvalue() def join(self, sep, items): first = True for item in items: if first: first = False else: self.write(sep) self.visit(item) def to_str(self, s): escape_string(s, self.out) def cast_null(self, arg): if (type(arg) == ast.Name and arg.id == 'null') or \ (type(arg) == ast.NameConstant and arg.value == None): self.write("nil") else: self.visit(arg) def to_args(self, args, func='', optargs=[]): optargs_first = False self.write("(") if args: self.cast_null(args[0]) for arg in args[1:]: self.write(', ') self.cast_null(arg) self.write(")") if optargs: self.to_args_optargs(func, optargs) def to_args_optargs(self, func='', optargs=[]): optarg_aliases = { 'JsOpts': 'JSOpts', 'HttpOpts': 'HTTPOpts', 'Iso8601Opts': 'ISO8601Opts', 'IndexCreateFuncOpts': 'IndexCreateOpts' } optarg_field_aliases = { 'nonvoting_replica_tags': 'NonVotingReplicaTags', } if not func: raise Unhandled("Missing function name") optarg_type = camel(func) + 'Opts' optarg_type = optarg_aliases.get(optarg_type, optarg_type) optarg_type = 'r.' + optarg_type self.write('.OptArgs(') self.write(optarg_type) self.write('{') for optarg in optargs: # Hack to skip tests that check for unknown opt args, # this is not possible in Go due to static types if optarg.arg == 'return_vals': self.skip("test not required since optargs are statically typed") return if optarg.arg == 'foo': self.skip("test not required since optargs are statically typed") return if type(optarg.value) == ast.Name and optarg.value.id == 'null': self.skip("test not required since go does not support null optargs") return field_name = optarg_field_aliases.get(optarg.arg, camel(optarg.arg)) self.write(field_name) self.write(": ") self.cast_null(optarg.value) self.write(', ') self.write('})') def generic_visit(self, node): logger.error("While translating: %s", ast.dump(node)) logger.error("Got as far as: %s", ''.join(self.out)) raise Unhandled("Don't know what this thing is: " + str(type(node))) def visit_Assign(self, node): if len(node.targets) != 1: Unhandled("We only support assigning to one variable") var = node.targets[0].id self.write("var " + var + " ") if is_reql(self._type): self.write('r.Term') else: self.write(self.type) self.write(" = ") if is_reql(self._type): ReQLVisitor(self.reql_vars, out=self.out, type_=self.type, is_def=True, ).visit(node.value) elif var == 'upper_limit': # Manually set value since value in test causes an error self.write('2<<52 - 1') elif var == 'lower_limit': # Manually set value since value in test causes an error self.write('1 - 2<<52') else: self.visit(node.value) def visit_Str(self, node): if node.s == 'ReqlServerCompileError': node.s = 'ReqlCompileError' # Hack to skip irrelevant tests if match(".*Expected .* argument", node.s): self.skip("argument checks not supported") if match(".*argument .* must", node.s): self.skip("argument checks not supported") return if node.s == 'Object keys must be strings.*': self.skip('the Go driver automatically converts object keys to strings') return if node.s.startswith('\'module\' object has no attribute '): self.skip('test not required since terms are statically typed') return self.to_str(node.s) def visit_Bytes(self, node, skip_prefix=False, skip_suffix=False): if not skip_prefix: self.write("[]byte{") for i, byte in enumerate(node.s): self.write(str(byte)) if i < len(node.s)-1: self.write(",") if not skip_suffix: self.write("}") else: self.write(", ") def visit_Name(self, node): name = node.id if name == 'frozenset': self.skip("can't convert frozensets to GroupedData yet") if name in GO_KEYWORDS: name += '_' self.write({ 'True': 'true', 'False': 'false', 'None': 'nil', 'nil': 'nil', 'null': 'nil', 'float': 'float64', 'datetime': 'Ast', # Use helper method instead 'len': 'maybeLen', 'AnythingIsFine': 'compare.AnythingIsFine', 'bag': 'compare.UnorderedMatch', 'partial': 'compare.PartialMatch', 'uuid': 'compare.IsUUID', 'regex': 'compare.MatchesRegexp', }.get(name, name)) def visit_arg(self, node): self.write(node.arg) self.write(" ") if is_reql(self._type): self.write("r.Term") else: self.write("interface{}") def visit_NameConstant(self, node): if node.value is None: self.write("nil") elif node.value is True: self.write("true") elif node.value is False: self.write("false") else: raise Unhandled( "Don't know NameConstant with value %s" % node.value) def visit_Attribute(self, node, emit_parens=True): skip_parent = False if attr_matches("r.ast", node): # The java driver doesn't have that namespace, so we skip # the `r.` prefix and create an ast class member in the # test file. So stuff like `r.ast.rqlTzinfo(...)` converts # to `ast.rqlTzinfo(...)` skip_parent = True if not skip_parent: self.visit(node.value) self.write(".") attr = ReQLVisitor.convertTermName(node.attr) self.write(attr) def visit_Num(self, node): self.write(repr(node.n)) if not isinstance(node.n, float): if node.n > 9223372036854775807 or node.n < -9223372036854775808: self.write(".0") def visit_Index(self, node): self.visit(node.value) def visit_Call(self, node): func = '' if type(node.func) == ast.Attribute and node.func.attr == 'encode': self.skip("Go tests do not currently support character encoding") return if type(node.func) == ast.Attribute and node.func.attr == 'error': # This weird special case is because sometimes the tests # use r.error and sometimes they use r.error(). The java # driver only supports r.error(). Since we're coming in # from a call here, we have to prevent visit_Attribute # from emitting the parents on an r.error for us. self.visit_Attribute(node.func, emit_parens=False) elif type(node.func) == ast.Name and node.func.id == 'err': # Throw away third argument as it is not used by the Go tests # and Go does not support function overloading node.args = node.args[:2] self.visit(node.func) elif type(node.func) == ast.Name and node.func.id == 'err_regex': # Throw away third argument as it is not used by the Go tests # and Go does not support function overloading node.args = node.args[:2] self.visit(node.func) elif type(node.func) == ast.Name and node.func.id == 'fetch': if len(node.args) == 1: node.args.append(ast.Num(0)) elif len(node.args) > 2: node.args = node.args[:2] self.visit(node.func) else: self.visit(node.func) if type(node.func) == ast.Attribute: func = node.func.attr elif type(node.func) == ast.Name: func = node.func.id self.to_args(node.args, func, node.keywords) def visit_Dict(self, node): self.write("map[interface{}]interface{}{") for k, v in zip(node.keys, node.values): self.visit(k) self.write(": ") self.visit(v) self.write(", ") self.write("}") def visit_List(self, node): self.write("[]interface{}{") self.join(", ", node.elts) self.write("}") def visit_Tuple(self, node): self.visit_List(node) def visit_Lambda(self, node): self.write("func") self.to_args(node.args.args) self.write(" interface{} { return ") self.visit(node.body) self.write("}") def visit_Subscript(self, node): if node.slice is None or type(node.slice.value) != ast.Num: logger.error("While doing: %s", ast.dump(node)) raise Unhandled("Only integers subscript can be converted." " Got %s" % node.slice.value.s) self.visit(node.value) self.write("[") self.write(str(node.slice.value.n)) self.write("]") def visit_ListComp(self, node): gen = node.generators[0] start = 0 end = 0 if type(gen.iter) == ast.Call and gen.iter.func.id.endswith('range'): # This is really a special-case hacking of [... for i in # range(i)] comprehensions that are used in the polyglot # tests sometimes. It won't handle translating arbitrary # comprehensions to Java streams. if len(gen.iter.args) == 1: end = gen.iter.args[0].n elif len(gen.iter.args) == 2: start = gen.iter.args[0].n end = gen.iter.args[1].n else: # Somebody came up with a creative new use for # comprehensions in the test suite... raise Unhandled("ListComp hack couldn't handle: ", ast.dump(node)) self.write("(func() []interface{} {\n") self.write(" res := []interface{}{}\n") self.write(" for iterator_ := %s; iterator_ < %s; iterator_++ {\n" % (start, end)) self.write(" "); self.visit(gen.target); self.write(" := iterator_\n") self.write(" res = append(res, ") self.visit(node.elt) self.write(")\n") self.write(" }\n") self.write(" return res\n") self.write("}())") def visit_UnaryOp(self, node): opMap = { ast.USub: "-", ast.Not: "!", ast.UAdd: "+", ast.Invert: "~", } self.write(opMap[type(node.op)]) self.visit(node.operand) def visit_BinOp(self, node): opMap = { ast.Add: " + ", ast.Sub: " - ", ast.Mult: " * ", ast.Div: " / ", ast.Mod: " % ", } if self.is_string_mul(node): return if self.is_array_concat(node): return if self.is_byte_array_add(node): return t = type(node.op) if t in opMap.keys(): self.visit(node.left) self.write(opMap[t]) self.visit(node.right) elif t == ast.Pow: if type(node.left) == ast.Num and node.left.n == 2: self.visit(node.left) self.write(" << ") self.visit(node.right) else: raise Unhandled("Can't do exponent with non 2 base") def is_byte_array_add(self, node): '''Some places we do stuff like b'foo' + b'bar' and byte arrays don't like that much''' if (type(node.left) == ast.Bytes and type(node.right) == ast.Bytes and type(node.op) == ast.Add): self.visit_Bytes(node.left, skip_suffix=True) self.visit_Bytes(node.right, skip_prefix=True) return True else: return False def is_string_mul(self, node): if ((type(node.left) == ast.Str and type(node.right) == ast.Num) and type(node.op) == ast.Mult): self.write("\"") self.write(node.left.s * node.right.n) self.write("\"") return True elif ((type(node.left) == ast.Num and type(node.right) == ast.Str) and type(node.op) == ast.Mult): self.write("\"") self.write(node.left.n * node.right.s) self.write("\"") return True else: return False def is_array_concat(self, node): if ((type(node.left) == ast.List or type(node.right) == ast.List) and type(node.op) == ast.Add): self.skip("Array concatenation using + operator not currently supported") return True else: return False class ReQLVisitor(GoVisitor): '''Mostly the same as the GoVisitor, but converts some reql-specific stuff. This should only be invoked on an expression if it's already known to return true from is_reql''' TOPLEVEL_CONSTANTS = { 'error' } def visit_BinOp(self, node): if self.is_string_mul(node): return if self.is_array_concat(node): return if self.is_byte_array_add(node): return opMap = { ast.Add: "Add", ast.Sub: "Sub", ast.Mult: "Mul", ast.Div: "Div", ast.Mod: "Mod", ast.BitAnd: "And", ast.BitOr: "Or", } func = opMap[type(node.op)] if self.is_not_reql(node.left): self.prefix(func, node.left, node.right) else: self.infix(func, node.left, node.right) def visit_Compare(self, node): opMap = { ast.Lt: "Lt", ast.Gt: "Gt", ast.GtE: "Ge", ast.LtE: "Le", ast.Eq: "Eq", ast.NotEq: "Ne", } if len(node.ops) != 1: # Python syntax allows chained comparisons (a < b < c) but # we don't deal with that here raise Unhandled("Compare hack bailed on: ", ast.dump(node)) left = node.left right = node.comparators[0] func_name = opMap[type(node.ops[0])] if self.is_not_reql(node.left): self.prefix(func_name, left, right) else: self.infix(func_name, left, right) def prefix(self, func_name, left, right): self.write("r.") self.write(func_name) self.write("(") self.visit(left) self.write(", ") self.visit(right) self.write(")") def infix(self, func_name, left, right): self.visit(left) self.write(".") self.write(func_name) self.write("(") self.visit(right) self.write(")") def is_not_reql(self, node): if type(node) in (ast.Name, ast.NameConstant, ast.Num, ast.Str, ast.Dict, ast.List): return True else: return False def visit_Subscript(self, node): self.visit(node.value) if type(node.slice) == ast.Index: # Syntax like a[2] or a["b"] if self.smart_bracket and type(node.slice.value) == ast.Str: self.write(".Field(") elif self.smart_bracket and type(node.slice.value) == ast.Num: self.write(".Nth(") else: self.write(".AtIndex(") self.visit(node.slice.value) self.write(")") elif type(node.slice) == ast.Slice: # Syntax like a[1:2] or a[:2] self.write(".Slice(") lower, upper, rclosed = self.get_slice_bounds(node.slice) self.write(str(lower)) self.write(", ") self.write(str(upper)) if rclosed: self.write(', r.SliceOpts{RightBound: "closed"}') self.write(")") else: raise Unhandled("No translation for ExtSlice") def get_slice_bounds(self, slc): '''Used to extract bounds when using bracket slice syntax. This is more complicated since Python3 parses -1 as UnaryOp(op=USub, operand=Num(1)) instead of Num(-1) like Python2 does''' if not slc: return 0, -1, True def get_bound(bound, default): if bound is None: return default elif type(bound) == ast.UnaryOp and type(bound.op) == ast.USub: return -bound.operand.n elif type(bound) == ast.Num: return bound.n else: raise Unhandled( "Not handling bound: %s" % ast.dump(bound)) right_closed = slc.upper is None return get_bound(slc.lower, 0), get_bound(slc.upper, -1), right_closed def convertTermName(term): python_clashes = { # These are underscored in the python driver to avoid # keywords, but they aren't java keywords so we convert # them back. 'or_': 'Or', 'and_': 'And', 'not_': 'Not', } method_aliases = { 'get_field': 'Field', 'db': 'DB', 'db_create': 'DBCreate', 'db_drop': 'DBDrop', 'db_list': 'DBList', 'uuid': 'UUID', 'geojson': 'GeoJSON', 'js': 'JS', 'json': 'JSON', 'to_json': 'ToJSON', 'to_json_string': 'ToJSON', 'minval': 'MinVal', 'maxval': 'MaxVal', 'http': 'HTTP', 'iso8601': 'ISO8601', 'to_iso8601': 'ToISO8601', } return python_clashes.get(term, method_aliases.get(term, camel(term))) def visit_Attribute(self, node, emit_parens=True): is_toplevel_constant = False # if attr_matches("r.row", node): # elif is_name("r", node.value) and node.attr in self.TOPLEVEL_CONSTANTS: if is_name("r", node.value) and node.attr in self.TOPLEVEL_CONSTANTS: # Python has r.minval, r.saturday etc. We need to emit # r.minval() and r.saturday() is_toplevel_constant = True initial = ReQLVisitor.convertTermName(node.attr) self.visit(node.value) self.write(".") self.write(initial) if initial in GO_KEYWORDS: self.write('_') if emit_parens and is_toplevel_constant: self.write('()') def visit_UnaryOp(self, node): if type(node.op) == ast.Invert: self.visit(node.operand) self.write(".Not()") else: super(ReQLVisitor, self).visit_UnaryOp(node) def visit_Call(self, node): if (attr_equals(node.func, "attr", "index_create") and len(node.args) == 2): node.func.attr = 'index_create_func' # We call the superclass first, so if it's going to fail # because of r.row or other things it fails first, rather than # hitting the checks in this method. Since everything is # written to a stringIO object not directly to a file, if we # bail out afterwards it's still ok super_result = super(ReQLVisitor, self).visit_Call(node) # r.expr(v, 1) should be skipped if (attr_equals(node.func, "attr", "expr") and len(node.args) > 1): self.skip("the go driver only accepts one parameter to expr") # r.table_create("a", "b") should be skipped if (attr_equals(node.func, "attr", "table_create") and len(node.args) > 1): self.skip("the go driver only accepts one parameter to table_create") return super_result class Renderer(object): '''Manages rendering templates''' def __init__(self, invoking_filenames, source_files=None): self.template_file = './template.go.tpl' self.invoking_filenames = invoking_filenames self.source_files = source_files or [] self.tpl = Template(filename=self.template_file) self.template_context = { 'EmptyTemplate': process_polyglot.EmptyTemplate, } def render(self, template_name, output_dir, output_name=None, **kwargs): if output_name is None: output_name = template_name output_path = output_dir + '/' + output_name results = self.template_context.copy() results.update(kwargs) try: rendered = self.tpl.render(**results) except process_polyglot.EmptyTemplate: logger.debug(" Empty template: %s", output_path) return with codecs.open(output_path, "w", "utf-8") as outfile: logger.info("Rendering %s", output_path) outfile.write(self.autogenerated_header( self.template_file, output_path, self.invoking_filenames, )) outfile.write(rendered) def autogenerated_header(self, template_path, output_path, filename): rel_tpl = os.path.relpath(template_path, start=output_path) filenames = ' and '.join(os.path.basename(f) for f in self.invoking_filenames) return ('// Code generated by {}.\n' '// Do not edit this file directly.\n' '// The template for this file is located at:\n' '// {}\n').format(filenames, rel_tpl) def camel(varname): 'CamelCase' if re.match(r'[A-Z][A-Z0-9_]*$|[a-z][a-z0-9_]*$', varname): # if snake-case (upper or lower) camelize it suffix = "_" if varname.endswith('_') else "" return ''.join(x.title() for x in varname.split('_')) + suffix else: # if already mixed case, just capitalize the first letter return varname[0].upper() + varname[1:] def dromedary(varname): 'dromedaryCase' if re.match(r'[A-Z][A-Z0-9_]*$|[a-z][a-z0-9_]*$', varname): chunks = varname.split('_') suffix = "_" if varname.endswith('_') else "" return (chunks[0].lower() + ''.join(x.title() for x in chunks[1:]) + suffix) else: return varname[0].lower() + varname[1:] def attr_equals(node, attr, value): '''Helper for digging into ast nodes''' return hasattr(node, attr) and getattr(node, attr) == value if __name__ == '__main__': main() rethinkdb-go-6.2.1/internal/gen_tests/gen_tests.sh000077500000000000000000000003241363464422500222460ustar00rootroot00000000000000#!/usr/bin/env bash set -e if [[ $REQL_TEST_DIR == "" ]] then echo "\$REQL_TEST_DIR must be specified" exit 1 fi ../gen_tests/gen_tests.py --test-dir=$REQL_TEST_DIR goimports -w . > /dev/null exit 0 rethinkdb-go-6.2.1/internal/gen_tests/parse_polyglot.py000066400000000000000000000142621363464422500233370ustar00rootroot00000000000000#!/usr/bin/env python from __future__ import print_function import os, re, sys # == globals printDebug = False try: unicode except NameError: unicode = str # == class yamlValue(unicode): linenumber = None def __new__(cls, value, linenumber=None): if isinstance(value, unicode): real = unicode.__new__(cls, value) else: real = unicode.__new__(cls, value, "utf-8") if linenumber is not None: real.linenumber = int(linenumber) return real def __repr__(self): real = super(yamlValue, self).__repr__() return real.lstrip('u') def parseYAML(source): def debug(message): if printDebug and message: message = str(message).rstrip() if message: print(message) sys.stdout.flush() commentLineRegex = re.compile('^\s*#') yamlLineRegex = re.compile('^(?P *)((?P- +)(?P.*)|((?P[\w\.]+)(?P: *))?(?P.*))\s*$') def parseYAML_inner(source, indent): returnItem = None for linenumber, line in source: if line == '': # no newline, so EOF break debug('line %d (%d):%s' % (linenumber, indent, line)) if line.strip() == '' or commentLineRegex.match(line): # empty or comment line, ignore debug('\tempty/comment line') continue # - parse line parsedLine = yamlLineRegex.match(line) if not parsedLine: raise Exception('Unparseable YAML line %d: %s' % (linenumber, line.rstrip())) lineIndent = len(parsedLine.group('indent')) lineItemMarker = parsedLine.group('itemMarker') lineKey = parsedLine.group('key') or '' lineKeyExtra = parsedLine.group('keyExtra') or '' lineContent = (parsedLine.group('content') or parsedLine.group('itemContent') or '').strip() # - handle end-of-sections if lineIndent < indent: # we have dropped out of this item, push back the line and return what we have source.send((linenumber, line)) debug('\tout one level') return returnItem # - array item if lineItemMarker: debug('\tarray item') # item in an array if returnItem is None: debug('\tnew array, indent is %d' % lineIndent) returnItem = [] indent = lineIndent elif not isinstance(returnItem, list): raise Exception('Bad YAML, got a list item while working on a %s on line %d: %s' % (returnItem.__class__.__name__, linenumber, line.rstrip())) indentLevel = lineIndent + len(lineItemMarker) source.send((linenumber, (' ' * (indentLevel) )+ lineContent)) returnItem += [parseYAML_inner(source=source, indent=indent + 1)] # - dict item elif lineKey: debug('\tdict item') if returnItem is None: debug('\tnew dict, indent is %d' % lineIndent) # new dict returnItem = {} indent = lineIndent elif not isinstance(returnItem, dict): raise Exception('Bad YAML, got a dict value while working on a %s on line %d: %s' % (returnItem.__class__.__name__, linenumber, line.rstrip())) indentLevel = lineIndent + len(lineKey) + len(lineKeyExtra) source.send((linenumber, (' ' * indentLevel) + lineContent)) returnItem[lineKey] = parseYAML_inner(source=source, indent=indent + 1) # - data - one or more lines of text else: debug('\tvalue') if returnItem is None: returnItem = yamlValue('', linenumber) if lineContent.strip() in ('|', '|-', '>'): continue # yaml multiline marker elif not isinstance(returnItem, yamlValue): raise Exception('Bad YAML, got a value while working on a %s on line %d: %s' % (returnItem.__class__.__name__, linenumber, line.rstrip())) if returnItem: returnItem = yamlValue(returnItem + "\n" + lineContent, returnItem.linenumber) # str subclasses are not fun else: returnItem = yamlValue(lineContent, linenumber) return returnItem def parseYAML_generator(source): if hasattr(source, 'capitalize'): if os.path.isfile(source): source = open(source, 'r') else: source = source.splitlines(True) elif hasattr(source, 'readlines'): pass # the for loop will already work backlines = [] for linenumber, line in enumerate(source): backline = None usedLine = False while usedLine is False or backlines: if backlines: backline = yield backlines.pop() else: usedLine = True backline = yield (linenumber + 1, line) while backline: # loops returning None for every send() assert isinstance(backline, tuple) assert isinstance(backline[0], int) backlines.append(backline) backline = yield None return parseYAML_inner(parseYAML_generator(source), indent=0) if __name__ == '__main__': import optparse, pprint parser = optparse.OptionParser() parser.add_option("-d", "--debug", dest="debug", action="store_true", default=False, help="print debug information") (options, args) = parser.parse_args() printDebug = options.debug if len(args) < 1: parser.error('%s needs files to process' % os.path.basename(__file__)) for filePath in args: if not os.path.isfile(filePath): sys.exit('target is not an existing file: %s' % os.path.basename(__file__)) for filePath in args: print('=== %s' % filePath) pprint.pprint(parseYAML(filePath)) rethinkdb-go-6.2.1/internal/gen_tests/process_polyglot.py000066400000000000000000000353571363464422500237130ustar00rootroot00000000000000'''Finds and reads polyglot yaml tests (preferring the python tests), normalizing their quirks into something that can be translated in a sane way. The idea is that this file contains nothing Go specific, so could potentially be used to convert the tests for use with other drivers. ''' import os import sys import os.path import ast import copy import logging from collections import namedtuple try: basestring except NameError: basestring = ("".__class__,) logger = logging.getLogger("process_polyglot") class EmptyTemplate(Exception): '''Raised inside templates if they have no reason to be rendered because what they're iterating over is empty''' pass class Unhandled(Exception): '''Used when a corner case is hit that probably should be handled if a test actually hits it''' pass class Skip(Exception): '''Used when skipping a test for whatever reason''' pass class FatalSkip(EmptyTemplate): '''Used when a skipped test should prevent the entire test file from rendering''' def __init__(self, msg): logger.info("Skipping rendering because %s", msg) super(FatalSkip, self).__init__(msg) Term = namedtuple("Term", 'line type ast') CustomTerm = namedtuple('CustomTerm', 'line') Query = namedtuple( 'Query', ('query', 'expected', 'testfile', 'line_num', 'runopts') ) Def = namedtuple('Def', 'varname term run_if_query testfile line_num runopts') CustomDef = namedtuple('CustomDef', 'line testfile line_num') Expect = namedtuple('Expect', 'bif term') class AnythingIsFine(object): def __init__(self): self.type = str self.ast = ast.Name("AnythingIsFine", None) self.line = "AnythingIsFine" class SkippedTest(object): __slots__ = ('line', 'reason') def __init__(self, line, reason): if reason == "No go, python or generic test": logger.debug("Skipped test because %s", reason) else: logger.info("Skipped test because %s", reason) logger.info(" - Skipped test was: %s", line) self.line = line self.reason = reason def flexiget(obj, keys, default): '''Like dict.get, but accepts an array of keys, matching the first that exists in the dict. If none do, it returns the default. If the object isn't a dict, it also returns the default''' if not isinstance(obj, dict): return default for key in keys: if key in obj: return obj[key] return default def py_str(py): '''Turns a python value into a string of python code representing that object''' def maybe_str(s): return s if isinstance(s, str) and '(' in s else repr(s) if type(py) is dict: return '{' + ', '.join( [repr(k) + ': ' + maybe_str(py[k]) for k in py]) + '}' if not isinstance(py, basestring): return repr(py) else: return py def _try_eval(node, context): '''For evaluating expressions given a context''' node_4_eval = copy.deepcopy(node) if type(node_4_eval) == ast.Expr: node_4_eval = node_4_eval.value node_4_eval = ast.Expression(node_4_eval) ast.fix_missing_locations(node_4_eval) compiled_value = compile(node_4_eval, '', mode='eval') r = context['r'] try: value = eval(compiled_value, context) except r.ReqlError: raise Skip("Java type system prevents static Reql errors") except AttributeError: raise Skip("Java type system prevents attribute errors") except Exception as err: return type(err), err else: return type(value), value def try_eval(node, context): return _try_eval(node, context)[0] def try_eval_def(parsed_define, context): '''For evaluating python definitions like x = foo''' varname = parsed_define.targets[0].id type_, value = _try_eval(parsed_define.value, context) context[varname] = value return varname, type_ def all_yaml_tests(test_dir, exclusions): '''Generator for the full paths of all non-excluded yaml tests''' for root, dirs, files in os.walk(test_dir): for f in files: path = os.path.relpath(os.path.join(root, f), test_dir) if valid_filename(exclusions, path): yield path def valid_filename(exclusions, filepath): parts = filepath.split('.') if parts[-1] != 'yaml': return False for exclusion in exclusions: if exclusion in filepath: logger.info("Skipped %s due to exclusion %r", filepath, exclusion) return False return True def fake_type(name): def __init__(self, *args, **kwargs): pass typ = type(name, (object,), {'__init__': __init__}) typ.__module__ = '?test?' return typ def create_context(r, table_var_names): '''Creates a context for evaluation of test definitions. Needs the rethinkdb driver module to use, and the variable names of predefined tables''' from datetime import datetime, tzinfo, timedelta # Both these tzinfo classes were nabbed from # test/rql_test/driver/driver.py to aid in evaluation class UTCTimeZone(tzinfo): '''UTC''' def utcoffset(self, dt): return timedelta(0) def tzname(self, dt): return "UTC" def dst(self, dt): return timedelta(0) class PacificTimeZone(tzinfo): '''Pacific timezone emulator for timestamp: 1375147296.68''' def utcoffset(self, dt): return timedelta(-1, 61200) def tzname(self, dt): return 'PDT' def dst(self, dt): return timedelta(0, 3600) # We need to keep track of the values of definitions because each # subsequent definition can depend on previous ones. context = { 'r': r, 'null': None, 'nil': None, 'sys': sys, 'false': False, 'true': True, 'datetime': datetime, 'PacificTimeZone': PacificTimeZone, 'UTCTimeZone': UTCTimeZone, # mock test helper functions 'len': lambda x: 1, 'arrlen': fake_type("arr_len"), 'uuid': fake_type("uuid"), 'fetch': lambda c, limit=None: [], 'int_cmp': fake_type("int_cmp"), 'partial': fake_type("partial"), 'float_cmp': fake_type("float_cmp"), 'wait': lambda time: None, 'err': fake_type('err'), 'err_regex': fake_type('err_regex'), 'regex': fake_type('regex'), 'bag': fake_type('bag'), # py3 compatibility 'xrange': range, } # Definitions can refer to these predefined table variables. Since # we're only evaluating definitions here to determine what the # type of the term will be, it doesn't need to include the db or # anything, it just needs to be a Table ast object. context.update({tbl: r.table(tbl) for tbl in table_var_names}) return context class TestContext(object): '''Holds file, context and test number info before "expected" data is obtained''' def __init__(self, context, testfile, runopts): self.context = context self.testfile = testfile self.runopts = runopts @staticmethod def find_python_expected(test): '''Extract the expected result of the test. We want the python specific version if it's available, so we have to poke around a bit''' if 'ot' in test: ret = flexiget(test['ot'], ['py', 'cd'], test['ot']) elif isinstance(test.get('py'), dict) and 'ot' in test['py']: ret = test['py']['ot'] else: # This is distinct from the 'ot' field having the # value None in it! return AnythingIsFine() return ret @staticmethod def find_custom_expected(test, field): '''Gets the ot field for the language if it exists. If not it returns None.''' if 'ot' in test: ret = flexiget(test['ot'], [field], None) elif field in test: ret = flexiget(test[field], ['ot'], None) else: ret = None return ret def expected_context(self, test, custom_field): custom_expected = self.find_custom_expected(test, custom_field) if custom_expected is not None: # custom version doesn't need to be evaluated, it's in the # right language already term = CustomTerm(custom_expected) else: exp = self.find_python_expected(test) if type(exp) == AnythingIsFine: return ExpectedContext(self, AnythingIsFine()) expected = py_str(exp) expected_ast = ast.parse(expected, mode="eval").body logger.debug("Evaluating: %s", expected) expected_type = try_eval(expected_ast, self.context) term = Term( ast=expected_ast, line=expected, type=expected_type, ) return ExpectedContext(self, term) def def_from_parsed(self, define_line, parsed_define, run_if_query): logger.debug("Evaluating: %s", define_line) varname, result_type = try_eval_def(parsed_define, self.context) return Def( varname=varname, term=Term( line=define_line, type=result_type, ast=parsed_define), run_if_query=run_if_query, testfile=self.testfile, line_num=define_line.linenumber, runopts=self.runopts, ) def def_from_define(self, define, run_if_query): define_line = py_str(define) parsed_define = ast.parse(define_line, mode='single').body[0] return self.def_from_parsed(define_line, parsed_define, run_if_query) def custom_def(self, line): return CustomDef( line=line, testfile=self.testfile, line_num=line.linenumber) class ExpectedContext(object): '''Holds some contextual information needed to yield queries. Used by the tests_and_defs generator''' def __init__(self, test_context, expected_term): self.testfile = test_context.testfile self.context = test_context.context self.runopts = test_context.runopts self.expected_term = expected_term def query_from_term(self, query_term, line_num=None): if type(query_term) == SkippedTest: return query_term else: return Query( query=query_term, expected=self.expected_term, testfile=self.testfile, line_num=query_term.line.linenumber, runopts=self.runopts, ) def query_from_test(self, test): return self.query_from_term( self.term_from_test(test), test.linenumber) def query_from_subtest(self, test, subline_num): return self.query_from_term( self.term_from_test(test), (test.linenumber, subline_num)) def query_from_parsed(self, testline, parsed): return self.query_from_term( self.term_from_parsed(testline, parsed)) def term_from_test(self, test): testline = py_str(test) return self.term_from_testline(testline) def term_from_testline(self, testline): parsed = ast.parse(testline, mode='eval').body return self.term_from_parsed(testline, parsed) def term_from_parsed(self, testline, parsed): try: logger.debug("Evaluating: %s", testline) result_type = try_eval(parsed, self.context) except Skip as s: return SkippedTest(line=testline, reason=str(s)) else: return Term(ast=parsed, line=testline, type=result_type) def tests_and_defs(testfile, raw_test_data, context, custom_field=None): '''Generator of parsed python tests and definitions. `testfile` is the name of the file being converted `raw_test_data` is the yaml data as python data structures `context` is the evaluation context for the values. Will be modified `custom` is the specific type of test to look for. (falls back to 'py', then 'cd') ''' for test in raw_test_data: runopts = test.get('runopts') if runopts is not None: runopts = {key: ast.parse(py_str(val), mode="eval").body for key, val in runopts.items()} test_context = TestContext(context, testfile, runopts=runopts) if 'def' in test and flexiget(test['def'], [custom_field], False): yield test_context.custom_def(test['def'][custom_field]) elif 'def' in test: # We want to yield the definition before the test itself define = flexiget(test['def'], [custom_field], None) if define is not None: yield test_context.custom_def(define) else: define = flexiget(test['def'], ['py', 'cd'], test['def']) # for some reason, sometimes def is just None if define and type(define) is not dict: # if define is a dict, it doesn't have anything # relevant since we already checked. if this # happens to be a query fragment, the test # framework should not run it, just store the # fragment in the variable. yield test_context.def_from_define( define, run_if_query=False) customtest = test.get(custom_field, None) # as a backup try getting a python or generic test pytest = flexiget(test, ['py', 'cd'], None) if customtest is None and pytest is None: line = flexiget(test, ['rb', 'js'], u'¯\_(ツ)_/¯') yield SkippedTest( line=line, reason='No {}, python or generic test'.format(custom_field)) continue expected_context = test_context.expected_context(test, custom_field) if customtest is not None: yield expected_context.query_from_term(customtest) elif isinstance(pytest, basestring): parsed = ast.parse(pytest, mode="single").body[0] if type(parsed) == ast.Expr: yield expected_context.query_from_parsed(pytest, parsed.value) elif type(parsed) == ast.Assign: # Second syntax for defines. Surprise, it wasn't a # test at all, because it has an equals sign in it. # if this happens to be a query, it will be run. yield test_context.def_from_parsed( pytest, parsed, run_if_query=True) elif type(pytest) is dict and 'cd' in pytest: yield expected_context.query_from_test(pytest['cd']) else: for i, subtest in enumerate(pytest, start=1): # unroll subtests yield expected_context.query_from_subtest(subtest, i) rethinkdb-go-6.2.1/internal/integration/000077500000000000000000000000001363464422500202455ustar00rootroot00000000000000rethinkdb-go-6.2.1/internal/integration/reql_tests/000077500000000000000000000000001363464422500224325ustar00rootroot00000000000000rethinkdb-go-6.2.1/internal/integration/reql_tests/common.go000066400000000000000000000146541363464422500242630ustar00rootroot00000000000000package reql_tests import ( "fmt" "math" "reflect" "regexp" "strings" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) func maybeRun(query interface{}, session *r.Session, opts r.RunOpts) interface{} { switch query := query.(type) { case r.Term: cursor, err := query.Run(session, opts) if err != nil { return err } switch cursor.Type() { case "Cursor": results, err := cursor.Interface() if err != nil { return err } return results default: // If this is a changefeed then return the cursor without attempting // to read any documents return cursor } default: return query } } func runAndAssert(suite suite.Suite, expected, v interface{}, session *r.Session, opts r.RunOpts) { var cursor *r.Cursor var err error switch v := v.(type) { case r.Term: cursor, err = v.Run(session, opts) case *r.Cursor: cursor = v case error: err = v } assertExpected(suite, expected, cursor, err) } func fetchAndAssert(suite suite.Suite, expected, result interface{}, count int) { switch v := expected.(type) { case compare.Expected: v.Fetch = true v.FetchCount = count expected = v default: expected = compare.Expected(compare.Expected{ Val: v, Fetch: true, FetchCount: count, }) } var cursor *r.Cursor var err error switch result := result.(type) { case *r.Cursor: cursor = result case error: err = result } assertExpected(suite, expected, cursor, err) } func maybeLen(v interface{}) interface{} { switch v := v.(type) { case *r.Cursor: results := []interface{}{} v.All(&results) return len(results) case []interface{}: return len(v) default: return v } } func assertExpected(suite suite.Suite, expected interface{}, obtainedCursor *r.Cursor, obtainedErr error) { if expected == compare.AnythingIsFine { suite.NoError(obtainedErr, "Query returned unexpected error") return } switch expected := expected.(type) { case Err: expected.assert(suite, obtainedCursor, obtainedErr) case compare.Expected: assert(suite, expected, obtainedCursor, obtainedErr) default: assert(suite, compare.Expected{Val: expected}, obtainedCursor, obtainedErr) } } func assert(suite suite.Suite, expected compare.Expected, obtainedCursor *r.Cursor, obtainedErr error) { if !suite.NoError(obtainedErr, "Query returned unexpected error") { return } expectedVal := reflect.ValueOf(expected.Val) // If expected value is nil then ensure cursor is nil (assume that an // invalid reflect value is because expected value is nil) if !expectedVal.IsValid() || (expectedVal.Kind() == reflect.Ptr && expectedVal.IsNil()) { suite.True(obtainedCursor.IsNil(), "Expected nil cursor") return } expectedType := expectedVal.Type() expectedKind := expectedType.Kind() if expectedKind == reflect.Array || expectedKind == reflect.Slice || expected.Fetch { if expectedType.Elem().Kind() == reflect.Uint8 { // Decode byte slices slightly differently var obtained = []byte{} err := obtainedCursor.One(&obtained) suite.NoError(err, "Error returned when reading query response") compare.Assert(suite.T(), expected, obtained) } else { var obtained = []interface{}{} if expected.Fetch { var v interface{} for obtainedCursor.Next(&v) { obtained = append(obtained, v) if expected.FetchCount != 0 && len(obtained) >= expected.FetchCount { break } } suite.NoError(obtainedCursor.Err(), "Error returned when reading query response") } else { err := obtainedCursor.All(&obtained) suite.NoError(err, "Error returned when reading query response") } compare.Assert(suite.T(), expected, obtained) } } else if expectedKind == reflect.Map { var obtained map[string]interface{} err := obtainedCursor.One(&obtained) suite.NoError(err, "Error returned when reading query response") compare.Assert(suite.T(), expected, obtained) } else { var obtained interface{} err := obtainedCursor.One(&obtained) suite.NoError(err, "Error returned when reading query response") compare.Assert(suite.T(), expected, obtained) } } func int_cmp(i int) int { return i } func float_cmp(i float64) float64 { return i } func arrlen(length int, vs ...interface{}) []interface{} { var v interface{} = compare.AnythingIsFine if len(vs) == 1 { v = vs[0] } arr := make([]interface{}, length) for i := 0; i < length; i++ { arr[i] = v } return arr } func str(v interface{}) string { return fmt.Sprintf("%v", v) } func wait(s int) interface{} { time.Sleep(time.Duration(s) * time.Second) return nil } type Err struct { Type string Message string Regex string } var exceptionRegex = regexp.MustCompile("^(?P[^\n]*?)((?: in:)?\n|\nFailed assertion:)(?s).*$") func (expected Err) assert(suite suite.Suite, obtainerCursor *r.Cursor, obtainedErr error) { // If the error is nil then attempt to read from the cursor and see if an // error is returned if obtainedErr == nil { var res []interface{} obtainedErr = obtainerCursor.All(&res) } if !suite.Error(obtainedErr) { return } obtainedType := reflect.TypeOf(obtainedErr).String() obtainedMessage := strings.TrimPrefix(obtainedErr.Error(), "rethinkdb: ") obtainedMessage = exceptionRegex.ReplaceAllString(obtainedMessage, "${message}") suite.Equal(expected.Type, obtainedType) if expected.Regex != "" { suite.Regexp(expected.Regex, obtainedMessage) } if expected.Message != "" { suite.Equal(expected.Message, obtainedMessage) } } func err(errType, message string) Err { return Err{ Type: "rethinkdb.RQL" + errType[4:], Message: message, } } func err_regex(errType, expr string) Err { return Err{ Type: "rethinkdb.RQL" + errType[4:], Regex: expr, } } var Ast = struct { RqlTzinfo func(tz string) *time.Location Fromtimestamp func(ts float64, loc *time.Location) time.Time Now func() time.Time }{ func(tz string) *time.Location { t, _ := time.Parse("-07:00 UTC", tz+" UTC") return t.Location() }, func(ts float64, loc *time.Location) time.Time { sec, nsec := math.Modf(ts) return time.Unix(int64(sec), int64(nsec*1000)*1000000).In(loc) }, time.Now, } func UTCTimeZone() *time.Location { return time.UTC } func PacificTimeZone() *time.Location { return Ast.RqlTzinfo("-07:00") } var FloatInfo = struct { Min, Max float64 }{math.SmallestNonzeroFloat64, math.MaxFloat64} var sys = struct { FloatInfo struct { Min, Max float64 } }{FloatInfo} rethinkdb-go-6.2.1/internal/integration/reql_tests/gorethink_test.go000066400000000000000000000006751363464422500260220ustar00rootroot00000000000000//go:generate ../gen_tests/gen_tests.sh package reql_tests import ( "flag" "os" "runtime" r "gopkg.in/rethinkdb/rethinkdb-go.v6" ) var url string func init() { // Fixing test.testlogfile parsing error on Go 1.13+. if runtime.Version() < "go1.13" { flag.Parse() } r.SetVerbose(true) // If the test is being run by wercker look for the rethink url url = os.Getenv("RETHINKDB_URL") if url == "" { url = "localhost:28015" } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_aggregation_test.go000066400000000000000000002461101363464422500273360ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests that manipulation data in tables func TestAggregationSuite(t *testing.T) { suite.Run(t, new(AggregationSuite)) } type AggregationSuite struct { suite.Suite session *r.Session } func (suite *AggregationSuite) SetupTest() { suite.T().Log("Setting up AggregationSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_agg").Exec(suite.session) err = r.DBCreate("db_agg").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_agg").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_agg").TableDrop("table_test_agg").Exec(suite.session) err = r.DB("db_agg").TableCreate("table_test_agg").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_agg").Table("table_test_agg").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_agg").TableDrop("table_test_agg2").Exec(suite.session) err = r.DB("db_agg").TableCreate("table_test_agg2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_agg").Table("table_test_agg2").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_agg").TableDrop("table_test_agg3").Exec(suite.session) err = r.DB("db_agg").TableCreate("table_test_agg3").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_agg").Table("table_test_agg3").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_agg").TableDrop("table_test_agg4").Exec(suite.session) err = r.DB("db_agg").TableCreate("table_test_agg4").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_agg").Table("table_test_agg4").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *AggregationSuite) TearDownSuite() { suite.T().Log("Tearing down AggregationSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_agg").TableDrop("table_test_agg").Exec(suite.session) r.DB("db_agg").TableDrop("table_test_agg2").Exec(suite.session) r.DB("db_agg").TableDrop("table_test_agg3").Exec(suite.session) r.DB("db_agg").TableDrop("table_test_agg4").Exec(suite.session) r.DBDrop("db_agg").Exec(suite.session) suite.session.Close() } } func (suite *AggregationSuite) TestCases() { suite.T().Log("Running AggregationSuite: Tests that manipulation data in tables") table_test_agg := r.DB("db_agg").Table("table_test_agg") _ = table_test_agg // Prevent any noused variable errors table_test_agg2 := r.DB("db_agg").Table("table_test_agg2") _ = table_test_agg2 // Prevent any noused variable errors table_test_agg3 := r.DB("db_agg").Table("table_test_agg3") _ = table_test_agg3 // Prevent any noused variable errors table_test_agg4 := r.DB("db_agg").Table("table_test_agg4") _ = table_test_agg4 // Prevent any noused variable errors { // aggregation.yaml line #6 /* {'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* r.range(100).for_each(table_test_agg.insert({'id':r.row, 'a':r.row.mod(4)})) */ suite.T().Log("About to run line #6: r.Range(100).ForEach(table_test_agg.Insert(map[interface{}]interface{}{'id': r.Row, 'a': r.Row.Mod(4), }))") runAndAssert(suite.Suite, expected_, r.Range(100).ForEach(table_test_agg.Insert(map[interface{}]interface{}{"id": r.Row, "a": r.Row.Mod(4)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // aggregation.yaml line #10 /* {'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* r.range(100).for_each(table_test_agg2.insert({'id':r.row, 'a':r.row.mod(4)})) */ suite.T().Log("About to run line #10: r.Range(100).ForEach(table_test_agg2.Insert(map[interface{}]interface{}{'id': r.Row, 'a': r.Row.Mod(4), }))") runAndAssert(suite.Suite, expected_, r.Range(100).ForEach(table_test_agg2.Insert(map[interface{}]interface{}{"id": r.Row, "a": r.Row.Mod(4)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // aggregation.yaml line #14 /* {'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* r.range(100).for_each(table_test_agg3.insert({'id':r.row, 'a':r.row.mod(4), 'b':{'c':r.row.mod(5)}})) */ suite.T().Log("About to run line #14: r.Range(100).ForEach(table_test_agg3.Insert(map[interface{}]interface{}{'id': r.Row, 'a': r.Row.Mod(4), 'b': map[interface{}]interface{}{'c': r.Row.Mod(5), }, }))") runAndAssert(suite.Suite, expected_, r.Range(100).ForEach(table_test_agg3.Insert(map[interface{}]interface{}{"id": r.Row, "a": r.Row.Mod(4), "b": map[interface{}]interface{}{"c": r.Row.Mod(5)}})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } // aggregation.yaml line #19 // time1 = 1375115782.24 suite.T().Log("Possibly executing: var time1 float64 = 1375115782.24") time1 := 1375115782.24 _ = time1 // Prevent any noused variable errors // aggregation.yaml line #23 // time2 = 1375147296.68 suite.T().Log("Possibly executing: var time2 float64 = 1375147296.68") time2 := 1375147296.68 _ = time2 // Prevent any noused variable errors { // aggregation.yaml line #27 /* {'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 1} /* table_test_agg4.insert({'id':0, 'time':r.epoch_time(time1)}) */ suite.T().Log("About to run line #27: table_test_agg4.Insert(map[interface{}]interface{}{'id': 0, 'time': r.EpochTime(time1), })") runAndAssert(suite.Suite, expected_, table_test_agg4.Insert(map[interface{}]interface{}{"id": 0, "time": r.EpochTime(time1)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // aggregation.yaml line #28 /* {'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 1} /* table_test_agg4.insert({'id':1, 'time':r.epoch_time(time2)}) */ suite.T().Log("About to run line #28: table_test_agg4.Insert(map[interface{}]interface{}{'id': 1, 'time': r.EpochTime(time2), })") runAndAssert(suite.Suite, expected_, table_test_agg4.Insert(map[interface{}]interface{}{"id": 1, "time": r.EpochTime(time2)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // aggregation.yaml line #33 /* 150 */ var expected_ int = 150 /* table_test_agg.sum('a') */ suite.T().Log("About to run line #33: table_test_agg.Sum('a')") runAndAssert(suite.Suite, expected_, table_test_agg.Sum("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // aggregation.yaml line #36 /* 150 */ var expected_ int = 150 /* table_test_agg.map(lambda row:row['a']).sum() */ suite.T().Log("About to run line #36: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Sum()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Sum(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // aggregation.yaml line #39 /* ({0:1200, 1:1225, 2:1250, 3:1275}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 1200, 1: 1225, 2: 1250, 3: 1275} /* table_test_agg.group('a').sum('id') */ suite.T().Log("About to run line #39: table_test_agg.Group('a').Sum('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Sum("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // aggregation.yaml line #43 /* 1.5 */ var expected_ float64 = 1.5 /* table_test_agg.avg('a') */ suite.T().Log("About to run line #43: table_test_agg.Avg('a')") runAndAssert(suite.Suite, expected_, table_test_agg.Avg("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // aggregation.yaml line #46 /* 1.5 */ var expected_ float64 = 1.5 /* table_test_agg.map(lambda row:row['a']).avg() */ suite.T().Log("About to run line #46: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Avg()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Avg(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // aggregation.yaml line #49 /* {0:48, 1:49, 2:50, 3:51} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 48, 1: 49, 2: 50, 3: 51} /* table_test_agg.group('a').avg('id') */ suite.T().Log("About to run line #49: table_test_agg.Group('a').Avg('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Avg("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // aggregation.yaml line #53 /* 0 */ var expected_ int = 0 /* table_test_agg.min('a')['a'] */ suite.T().Log("About to run line #53: table_test_agg.Min('a').AtIndex('a')") runAndAssert(suite.Suite, expected_, table_test_agg.Min("a").AtIndex("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // aggregation.yaml line #56 /* {'a':0, 'id':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 0} /* table_test_agg.order_by('id').min('a') */ suite.T().Log("About to run line #56: table_test_agg.OrderBy('id').Min('a')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy("id").Min("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #56") } { // aggregation.yaml line #59 /* 0 */ var expected_ int = 0 /* table_test_agg.map(lambda row:row['a']).min() */ suite.T().Log("About to run line #59: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Min()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Min(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #59") } { // aggregation.yaml line #62 /* {0:{'a':0, 'id':0}, 1:{'a':1, 'id':1}, 2:{'a':2, 'id':2}, 3:{'a':3, 'id':3}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "id": 0}, 1: map[interface{}]interface{}{"a": 1, "id": 1}, 2: map[interface{}]interface{}{"a": 2, "id": 2}, 3: map[interface{}]interface{}{"a": 3, "id": 3}} /* table_test_agg.group('a').min('id') */ suite.T().Log("About to run line #62: table_test_agg.Group('a').Min('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Min("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // aggregation.yaml line #66 /* {'a':3, 'id':3} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 3, "id": 3} /* table_test_agg.order_by('id').max('a') */ suite.T().Log("About to run line #66: table_test_agg.OrderBy('id').Max('a')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy("id").Max("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } { // aggregation.yaml line #69 /* 3 */ var expected_ int = 3 /* table_test_agg.map(lambda row:row['a']).max() */ suite.T().Log("About to run line #69: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Max()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Max(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } { // aggregation.yaml line #72 /* {0:{'a':0, 'id':96}, 1:{'a':1, 'id':97}, 2:{'a':2, 'id':98}, 3:{'a':3, 'id':99}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "id": 96}, 1: map[interface{}]interface{}{"a": 1, "id": 97}, 2: map[interface{}]interface{}{"a": 2, "id": 98}, 3: map[interface{}]interface{}{"a": 3, "id": 99}} /* table_test_agg.group('a').max('id') */ suite.T().Log("About to run line #72: table_test_agg.Group('a').Max('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Max("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #72") } { // aggregation.yaml line #77 /* {"a":0, "id":0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 0} /* table_test_agg.min() */ suite.T().Log("About to run line #77: table_test_agg.Min()") runAndAssert(suite.Suite, expected_, table_test_agg.Min(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #77") } { // aggregation.yaml line #79 /* {0:{"a":0, "id":0}, 1:{"a":1, "id":1}, 2:{"a":2, "id":2}, 3:{"a":3, "id":3}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "id": 0}, 1: map[interface{}]interface{}{"a": 1, "id": 1}, 2: map[interface{}]interface{}{"a": 2, "id": 2}, 3: map[interface{}]interface{}{"a": 3, "id": 3}} /* table_test_agg.group('a').min() */ suite.T().Log("About to run line #79: table_test_agg.Group('a').Min()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Min(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #79") } { // aggregation.yaml line #83 /* {"a":3, "id":99} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 3, "id": 99} /* table_test_agg.max() */ suite.T().Log("About to run line #83: table_test_agg.Max()") runAndAssert(suite.Suite, expected_, table_test_agg.Max(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // aggregation.yaml line #85 /* {0:{'a':0, 'id':96}, 1:{'a':1, 'id':97}, 2:{'a':2, 'id':98}, 3:{'a':3, 'id':99}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "id": 96}, 1: map[interface{}]interface{}{"a": 1, "id": 97}, 2: map[interface{}]interface{}{"a": 2, "id": 98}, 3: map[interface{}]interface{}{"a": 3, "id": 99}} /* table_test_agg.group('a').max() */ suite.T().Log("About to run line #85: table_test_agg.Group('a').Max()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Max(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #85") } { // aggregation.yaml line #92 /* 150 */ var expected_ int = 150 /* table_test_agg.sum(lambda row:row['a']) */ suite.T().Log("About to run line #92: table_test_agg.Sum(func(row r.Term) interface{} { return row.AtIndex('a')})") runAndAssert(suite.Suite, expected_, table_test_agg.Sum(func(row r.Term) interface{} { return row.AtIndex("a") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } { // aggregation.yaml line #93 /* 150 */ var expected_ int = 150 /* table_test_agg.sum(r.row['a']) */ suite.T().Log("About to run line #93: table_test_agg.Sum(r.Row.AtIndex('a'))") runAndAssert(suite.Suite, expected_, table_test_agg.Sum(r.Row.AtIndex("a")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } { // aggregation.yaml line #99 /* 150 */ var expected_ int = 150 /* table_test_agg.map(lambda row:row['a']).sum() */ suite.T().Log("About to run line #99: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Sum()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Sum(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #99") } { // aggregation.yaml line #103 /* {0:1200, 1:1225, 2:1250, 3:1275} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 1200, 1: 1225, 2: 1250, 3: 1275} /* table_test_agg.group(lambda row:row['a']).sum(lambda row:row['id']) */ suite.T().Log("About to run line #103: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Sum(func(row r.Term) interface{} { return row.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Sum(func(row r.Term) interface{} { return row.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // aggregation.yaml line #111 /* 1.5 */ var expected_ float64 = 1.5 /* table_test_agg.avg(lambda row:row['a']) */ suite.T().Log("About to run line #111: table_test_agg.Avg(func(row r.Term) interface{} { return row.AtIndex('a')})") runAndAssert(suite.Suite, expected_, table_test_agg.Avg(func(row r.Term) interface{} { return row.AtIndex("a") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // aggregation.yaml line #112 /* 1.5 */ var expected_ float64 = 1.5 /* table_test_agg.avg(r.row['a']) */ suite.T().Log("About to run line #112: table_test_agg.Avg(r.Row.AtIndex('a'))") runAndAssert(suite.Suite, expected_, table_test_agg.Avg(r.Row.AtIndex("a")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #112") } { // aggregation.yaml line #118 /* 1.5 */ var expected_ float64 = 1.5 /* table_test_agg.map(lambda row:row['a']).avg() */ suite.T().Log("About to run line #118: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Avg()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Avg(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } { // aggregation.yaml line #122 /* {0:48, 1:49, 2:50, 3:51} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 48, 1: 49, 2: 50, 3: 51} /* table_test_agg.group(lambda row:row['a']).avg(lambda row:row['id']) */ suite.T().Log("About to run line #122: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Avg(func(row r.Term) interface{} { return row.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Avg(func(row r.Term) interface{} { return row.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // aggregation.yaml line #129 /* {'a':0, 'id':96} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 96} /* table_test_agg.order_by(r.desc('id')).min(lambda row:row['a']) */ suite.T().Log("About to run line #129: table_test_agg.OrderBy(r.Desc('id')).Min(func(row r.Term) interface{} { return row.AtIndex('a')})") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy(r.Desc("id")).Min(func(row r.Term) interface{} { return row.AtIndex("a") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #129") } { // aggregation.yaml line #130 /* {'a':0, 'id':96} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 96} /* table_test_agg.order_by(r.desc('id')).min(r.row['a']) */ suite.T().Log("About to run line #130: table_test_agg.OrderBy(r.Desc('id')).Min(r.Row.AtIndex('a'))") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy(r.Desc("id")).Min(r.Row.AtIndex("a")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #130") } { // aggregation.yaml line #138 /* 0 */ var expected_ int = 0 /* table_test_agg.order_by(r.desc('id')).min(lambda row:row['a'])['a'] */ suite.T().Log("About to run line #138: table_test_agg.OrderBy(r.Desc('id')).Min(func(row r.Term) interface{} { return row.AtIndex('a')}).AtIndex('a')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy(r.Desc("id")).Min(func(row r.Term) interface{} { return row.AtIndex("a") }).AtIndex("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #138") } { // aggregation.yaml line #139 /* 0 */ var expected_ int = 0 /* table_test_agg.order_by(r.desc('id')).min(r.row['a'])['a'] */ suite.T().Log("About to run line #139: table_test_agg.OrderBy(r.Desc('id')).Min(r.Row.AtIndex('a')).AtIndex('a')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy(r.Desc("id")).Min(r.Row.AtIndex("a")).AtIndex("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #139") } { // aggregation.yaml line #145 /* 0 */ var expected_ int = 0 /* table_test_agg.map(lambda row:row['a']).min() */ suite.T().Log("About to run line #145: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Min()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Min(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #145") } { // aggregation.yaml line #149 /* {0:0, 1:1, 2:2, 3:3} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 0, 1: 1, 2: 2, 3: 3} /* table_test_agg.group(lambda row:row['a']).min(lambda row:row['id'])['id'] */ suite.T().Log("About to run line #149: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Min(func(row r.Term) interface{} { return row.AtIndex('id')}).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Min(func(row r.Term) interface{} { return row.AtIndex("id") }).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #149") } { // aggregation.yaml line #157 /* 3 */ var expected_ int = 3 /* table_test_agg.max(lambda row:row['a'])['a'] */ suite.T().Log("About to run line #157: table_test_agg.Max(func(row r.Term) interface{} { return row.AtIndex('a')}).AtIndex('a')") runAndAssert(suite.Suite, expected_, table_test_agg.Max(func(row r.Term) interface{} { return row.AtIndex("a") }).AtIndex("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #157") } { // aggregation.yaml line #158 /* 3 */ var expected_ int = 3 /* table_test_agg.max(r.row['a'])['a'] */ suite.T().Log("About to run line #158: table_test_agg.Max(r.Row.AtIndex('a')).AtIndex('a')") runAndAssert(suite.Suite, expected_, table_test_agg.Max(r.Row.AtIndex("a")).AtIndex("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #158") } { // aggregation.yaml line #164 /* 3 */ var expected_ int = 3 /* table_test_agg.map(lambda row:row['a']).max() */ suite.T().Log("About to run line #164: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Max()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Max(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #164") } { // aggregation.yaml line #168 /* {0:96, 1:97, 2:98, 3:99} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 96, 1: 97, 2: 98, 3: 99} /* table_test_agg.group(lambda row:row['a']).max(lambda row:row['id'])['id'] */ suite.T().Log("About to run line #168: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Max(func(row r.Term) interface{} { return row.AtIndex('id')}).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Max(func(row r.Term) interface{} { return row.AtIndex("id") }).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #168") } { // aggregation.yaml line #175 /* {0:1200, 1:1225, 2:1250, 3:1275} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 1200, 1: 1225, 2: 1250, 3: 1275} /* table_test_agg.group(lambda row:row['a']).map(lambda row:row['id']).reduce(lambda a,b:a+b) */ suite.T().Log("About to run line #175: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Map(func(row r.Term) interface{} { return row.AtIndex('id')}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Map(func(row r.Term) interface{} { return row.AtIndex("id") }).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #175") } { // aggregation.yaml line #185 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 1200], [1, 1225], [2, 1250], [3, 1275]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 1200}, []interface{}{1, 1225}, []interface{}{2, 1250}, []interface{}{3, 1275}}} /* table_test_agg.group(lambda row:row['a']).map(lambda row:row['id']).reduce(lambda a,b:a+b) */ suite.T().Log("About to run line #185: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Map(func(row r.Term) interface{} { return row.AtIndex('id')}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Map(func(row r.Term) interface{} { return row.AtIndex("id") }).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #185") } { // aggregation.yaml line #186 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 1200], [1, 1225], [2, 1250], [3, 1275]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 1200}, []interface{}{1, 1225}, []interface{}{2, 1250}, []interface{}{3, 1275}}} /* table_test_agg.group(r.row['a']).map(r.row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #186: table_test_agg.Group(r.Row.AtIndex('a')).Map(r.Row.AtIndex('id')).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(r.Row.AtIndex("a")).Map(r.Row.AtIndex("id")).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #186") } { // aggregation.yaml line #192 /* {'$reql_type$':'GROUPED_DATA', 'data':[[1, [{'a':1}]]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{1, []interface{}{map[interface{}]interface{}{"a": 1}}}}} /* r.expr([{'a':1}]).filter(true).limit(1).group('a') */ suite.T().Log("About to run line #192: r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, }}).Filter(true).Limit(1).Group('a')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{map[interface{}]interface{}{"a": 1}}).Filter(true).Limit(1).Group("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #192") } { // aggregation.yaml line #198 /* "GROUPED_STREAM" */ var expected_ string = "GROUPED_STREAM" /* table_test_agg.group('a').type_of() */ suite.T().Log("About to run line #198: table_test_agg.Group('a').TypeOf()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #198") } { // aggregation.yaml line #200 /* "GROUPED_DATA" */ var expected_ string = "GROUPED_DATA" /* table_test_agg.group('a').count().type_of() */ suite.T().Log("About to run line #200: table_test_agg.Group('a').Count().TypeOf()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Count().TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #200") } { // aggregation.yaml line #202 /* "GROUPED_DATA" */ var expected_ string = "GROUPED_DATA" /* table_test_agg.group('a').coerce_to('ARRAY').type_of() */ suite.T().Log("About to run line #202: table_test_agg.Group('a').CoerceTo('ARRAY').TypeOf()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").CoerceTo("ARRAY").TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #202") } { // aggregation.yaml line #206 /* {0:[0,4,8],1:[1,5,9],2:[2,6],3:[3,7]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: []interface{}{0, 4, 8}, 1: []interface{}{1, 5, 9}, 2: []interface{}{2, 6}, 3: []interface{}{3, 7}} /* table_test_agg.order_by(index='id').filter(lambda row:row['id'] < 10).group('a').map(lambda row:row['id']).coerce_to('ARRAY') */ suite.T().Log("About to run line #206: table_test_agg.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Filter(func(row r.Term) interface{} { return row.AtIndex('id').Lt(10)}).Group('a').Map(func(row r.Term) interface{} { return row.AtIndex('id')}).CoerceTo('ARRAY')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Filter(func(row r.Term) interface{} { return row.AtIndex("id").Lt(10) }).Group("a").Map(func(row r.Term) interface{} { return row.AtIndex("id") }).CoerceTo("ARRAY"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #206") } { // aggregation.yaml line #213 /* {0:9,1:9,2:4,3:4} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 9, 1: 9, 2: 4, 3: 4} /* table_test_agg.filter(lambda row:row['id'] < 10).group('a').count().do(lambda x:x*x) */ suite.T().Log("About to run line #213: table_test_agg.Filter(func(row r.Term) interface{} { return row.AtIndex('id').Lt(10)}).Group('a').Count().Do(func(x r.Term) interface{} { return r.Mul(x, x)})") runAndAssert(suite.Suite, expected_, table_test_agg.Filter(func(row r.Term) interface{} { return row.AtIndex("id").Lt(10) }).Group("a").Count().Do(func(x r.Term) interface{} { return r.Mul(x, x) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #213") } { // aggregation.yaml line #223 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 2400], [1, 2450], [2, 2500], [3, 2550]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 2400}, []interface{}{1, 2450}, []interface{}{2, 2500}, []interface{}{3, 2550}}} /* table_test_agg.union(table_test_agg).group(lambda row:row['a']).map(lambda row:row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #223: table_test_agg.Union(table_test_agg).Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Map(func(row r.Term) interface{} { return row.AtIndex('id')}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Union(table_test_agg).Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Map(func(row r.Term) interface{} { return row.AtIndex("id") }).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #223") } { // aggregation.yaml line #224 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 2400], [1, 2450], [2, 2500], [3, 2550]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 2400}, []interface{}{1, 2450}, []interface{}{2, 2500}, []interface{}{3, 2550}}} /* table_test_agg.union(table_test_agg).group(r.row['a']).map(r.row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #224: table_test_agg.Union(table_test_agg).Group(r.Row.AtIndex('a')).Map(r.Row.AtIndex('id')).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Union(table_test_agg).Group(r.Row.AtIndex("a")).Map(r.Row.AtIndex("id")).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #224") } { // aggregation.yaml line #235 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 2400], [1, 2450], [2, 2500], [3, 2550]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 2400}, []interface{}{1, 2450}, []interface{}{2, 2500}, []interface{}{3, 2550}}} /* table_test_agg.coerce_to("array").union(table_test_agg).group(lambda row:row['a']).map(lambda row:row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #235: table_test_agg.CoerceTo('array').Union(table_test_agg).Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Map(func(row r.Term) interface{} { return row.AtIndex('id')}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.CoerceTo("array").Union(table_test_agg).Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Map(func(row r.Term) interface{} { return row.AtIndex("id") }).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #235") } { // aggregation.yaml line #236 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 2400], [1, 2450], [2, 2500], [3, 2550]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 2400}, []interface{}{1, 2450}, []interface{}{2, 2500}, []interface{}{3, 2550}}} /* table_test_agg.coerce_to("array").union(table_test_agg).group(r.row['a']).map(r.row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #236: table_test_agg.CoerceTo('array').Union(table_test_agg).Group(r.Row.AtIndex('a')).Map(r.Row.AtIndex('id')).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.CoerceTo("array").Union(table_test_agg).Group(r.Row.AtIndex("a")).Map(r.Row.AtIndex("id")).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #236") } { // aggregation.yaml line #247 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 2400], [1, 2450], [2, 2500], [3, 2550]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 2400}, []interface{}{1, 2450}, []interface{}{2, 2500}, []interface{}{3, 2550}}} /* table_test_agg.union(table_test_agg.coerce_to("array")).group(lambda row:row['a']).map(lambda row:row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #247: table_test_agg.Union(table_test_agg.CoerceTo('array')).Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Map(func(row r.Term) interface{} { return row.AtIndex('id')}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Union(table_test_agg.CoerceTo("array")).Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Map(func(row r.Term) interface{} { return row.AtIndex("id") }).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #247") } { // aggregation.yaml line #248 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 2400], [1, 2450], [2, 2500], [3, 2550]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 2400}, []interface{}{1, 2450}, []interface{}{2, 2500}, []interface{}{3, 2550}}} /* table_test_agg.union(table_test_agg.coerce_to("array")).group(r.row['a']).map(r.row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #248: table_test_agg.Union(table_test_agg.CoerceTo('array')).Group(r.Row.AtIndex('a')).Map(r.Row.AtIndex('id')).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Union(table_test_agg.CoerceTo("array")).Group(r.Row.AtIndex("a")).Map(r.Row.AtIndex("id")).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #248") } { // aggregation.yaml line #255 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 1200], [1, 1225], [2, 1250], [3, 1275]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 1200}, []interface{}{1, 1225}, []interface{}{2, 1250}, []interface{}{3, 1275}}} /* table_test_agg.group(lambda row:row['a']).map(lambda row:row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #255: table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex('a')}).Map(func(row r.Term) interface{} { return row.AtIndex('id')}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(func(row r.Term) interface{} { return row.AtIndex("a") }).Map(func(row r.Term) interface{} { return row.AtIndex("id") }).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #255") } { // aggregation.yaml line #256 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 1200], [1, 1225], [2, 1250], [3, 1275]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 1200}, []interface{}{1, 1225}, []interface{}{2, 1250}, []interface{}{3, 1275}}} /* table_test_agg.group(r.row['a']).map(r.row['id']).reduce(lambda a,b:a + b) */ suite.T().Log("About to run line #256: table_test_agg.Group(r.Row.AtIndex('a')).Map(r.Row.AtIndex('id')).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)})") runAndAssert(suite.Suite, expected_, table_test_agg.Group(r.Row.AtIndex("a")).Map(r.Row.AtIndex("id")).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #256") } { // aggregation.yaml line #286 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 25], [1, 25], [2, 25], [3, 25]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 25}, []interface{}{1, 25}, []interface{}{2, 25}, []interface{}{3, 25}}} /* table_test_agg.group('a').count() */ suite.T().Log("About to run line #286: table_test_agg.Group('a').Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #286") } { // aggregation.yaml line #292 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 1200], [1, 1225], [2, 1250], [3, 1275]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 1200}, []interface{}{1, 1225}, []interface{}{2, 1250}, []interface{}{3, 1275}}} /* table_test_agg.group('a').sum('id') */ suite.T().Log("About to run line #292: table_test_agg.Group('a').Sum('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Sum("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #292") } { // aggregation.yaml line #298 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 48], [1, 49], [2, 50], [3, 51]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 48}, []interface{}{1, 49}, []interface{}{2, 50}, []interface{}{3, 51}}} /* table_test_agg.group('a').avg('id') */ suite.T().Log("About to run line #298: table_test_agg.Group('a').Avg('id')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Avg("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #298") } { // aggregation.yaml line #305 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 20], [1, 20], [2, 20], [3, 20], [4, 20]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 20}, []interface{}{1, 20}, []interface{}{2, 20}, []interface{}{3, 20}, []interface{}{4, 20}}} /* table_test_agg3.group(lambda row:row['b']['c']).count() */ suite.T().Log("About to run line #305: table_test_agg3.Group(func(row r.Term) interface{} { return row.AtIndex('b').AtIndex('c')}).Count()") runAndAssert(suite.Suite, expected_, table_test_agg3.Group(func(row r.Term) interface{} { return row.AtIndex("b").AtIndex("c") }).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #305") } { // aggregation.yaml line #313 /* {'$reql_type$':'GROUPED_DATA', 'data':[[[0, 0], 9], [[0, 1], 8], [[0, 2], 8], [[1, 0], 8], [[1, 1], 9], [[1, 2], 8], [[2, 0], 8], [[2, 1], 8], [[2, 2], 9], [[3, 0], 9], [[3, 1], 8], [[3, 2], 8]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{[]interface{}{0, 0}, 9}, []interface{}{[]interface{}{0, 1}, 8}, []interface{}{[]interface{}{0, 2}, 8}, []interface{}{[]interface{}{1, 0}, 8}, []interface{}{[]interface{}{1, 1}, 9}, []interface{}{[]interface{}{1, 2}, 8}, []interface{}{[]interface{}{2, 0}, 8}, []interface{}{[]interface{}{2, 1}, 8}, []interface{}{[]interface{}{2, 2}, 9}, []interface{}{[]interface{}{3, 0}, 9}, []interface{}{[]interface{}{3, 1}, 8}, []interface{}{[]interface{}{3, 2}, 8}}} /* table_test_agg.group('a', lambda row:row['id'].mod(3)).count() */ suite.T().Log("About to run line #313: table_test_agg.Group('a', func(row r.Term) interface{} { return row.AtIndex('id').Mod(3)}).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a", func(row r.Term) interface{} { return row.AtIndex("id").Mod(3) }).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #313") } { // aggregation.yaml line #329 /* 4 */ var expected_ int = 4 /* table_test_agg.map(lambda row:row['a']).distinct().count() */ suite.T().Log("About to run line #329: table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex('a')}).Distinct().Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Map(func(row r.Term) interface{} { return row.AtIndex("a") }).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #329") } { // aggregation.yaml line #334 /* "STREAM" */ var expected_ string = "STREAM" /* table_test_agg.distinct().type_of() */ suite.T().Log("About to run line #334: table_test_agg.Distinct().TypeOf()") runAndAssert(suite.Suite, expected_, table_test_agg.Distinct().TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #334") } { // aggregation.yaml line #337 /* 100 */ var expected_ int = 100 /* table_test_agg.distinct().count() */ suite.T().Log("About to run line #337: table_test_agg.Distinct().Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #337") } { // aggregation.yaml line #341 /* "STREAM" */ var expected_ string = "STREAM" /* table_test_agg.distinct(index='id').type_of() */ suite.T().Log("About to run line #341: table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: 'id', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: "id"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #341") } { // aggregation.yaml line #345 /* 100 */ var expected_ int = 100 /* table_test_agg.distinct(index='id').count() */ suite.T().Log("About to run line #345: table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #345") } { // aggregation.yaml line #348 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_agg.index_create('a') */ suite.T().Log("About to run line #348: table_test_agg.IndexCreate('a')") runAndAssert(suite.Suite, expected_, table_test_agg.IndexCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #348") } { // aggregation.yaml line #357 /* [{'index':'a','ready':true}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"index": "a", "ready": true}} /* table_test_agg.index_wait('a').pluck('index', 'ready') */ suite.T().Log("About to run line #357: table_test_agg.IndexWait('a').Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_agg.IndexWait("a").Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #357") } { // aggregation.yaml line #367 /* 25 */ var expected_ int = 25 /* table_test_agg.between(0, 1, index='a').distinct().count() */ suite.T().Log("About to run line #367: table_test_agg.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'a', }).Distinct().Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Between(0, 1).OptArgs(r.BetweenOpts{Index: "a"}).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #367") } { // aggregation.yaml line #371 /* 25 */ var expected_ int = 25 /* table_test_agg.between(0, 1, index='a').distinct(index='id').count() */ suite.T().Log("About to run line #371: table_test_agg.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'a', }).Distinct().OptArgs(r.DistinctOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Between(0, 1).OptArgs(r.BetweenOpts{Index: "a"}).Distinct().OptArgs(r.DistinctOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #371") } { // aggregation.yaml line #408 /* "STREAM" */ var expected_ string = "STREAM" /* table_test_agg.distinct(index='a').type_of() */ suite.T().Log("About to run line #408: table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: 'a', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: "a"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #408") } { // aggregation.yaml line #412 /* 4 */ var expected_ int = 4 /* table_test_agg.distinct(index='a').count() */ suite.T().Log("About to run line #412: table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: 'a', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Distinct().OptArgs(r.DistinctOpts{Index: "a"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #412") } { // aggregation.yaml line #415 /* err('ReqlQueryLogicError', 'Cannot group by nothing.', []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot group by nothing.") /* table_test_agg.group() */ suite.T().Log("About to run line #415: table_test_agg.Group()") runAndAssert(suite.Suite, expected_, table_test_agg.Group(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #415") } { // aggregation.yaml line #418 /* ({'$reql_type$':'GROUPED_DATA', 'data':[[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1], [21, 1], [22, 1], [23, 1], [24, 1], [25, 1], [26, 1], [27, 1], [28, 1], [29, 1], [30, 1], [31, 1], [32, 1], [33, 1], [34, 1], [35, 1], [36, 1], [37, 1], [38, 1], [39, 1], [40, 1], [41, 1], [42, 1], [43, 1], [44, 1], [45, 1], [46, 1], [47, 1], [48, 1], [49, 1], [50, 1], [51, 1], [52, 1], [53, 1], [54, 1], [55, 1], [56, 1], [57, 1], [58, 1], [59, 1], [60, 1], [61, 1], [62, 1], [63, 1], [64, 1], [65, 1], [66, 1], [67, 1], [68, 1], [69, 1], [70, 1], [71, 1], [72, 1], [73, 1], [74, 1], [75, 1], [76, 1], [77, 1], [78, 1], [79, 1], [80, 1], [81, 1], [82, 1], [83, 1], [84, 1], [85, 1], [86, 1], [87, 1], [88, 1], [89, 1], [90, 1], [91, 1], [92, 1], [93, 1], [94, 1], [95, 1], [96, 1], [97, 1], [98, 1], [99, 1]]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 1}, []interface{}{1, 1}, []interface{}{2, 1}, []interface{}{3, 1}, []interface{}{4, 1}, []interface{}{5, 1}, []interface{}{6, 1}, []interface{}{7, 1}, []interface{}{8, 1}, []interface{}{9, 1}, []interface{}{10, 1}, []interface{}{11, 1}, []interface{}{12, 1}, []interface{}{13, 1}, []interface{}{14, 1}, []interface{}{15, 1}, []interface{}{16, 1}, []interface{}{17, 1}, []interface{}{18, 1}, []interface{}{19, 1}, []interface{}{20, 1}, []interface{}{21, 1}, []interface{}{22, 1}, []interface{}{23, 1}, []interface{}{24, 1}, []interface{}{25, 1}, []interface{}{26, 1}, []interface{}{27, 1}, []interface{}{28, 1}, []interface{}{29, 1}, []interface{}{30, 1}, []interface{}{31, 1}, []interface{}{32, 1}, []interface{}{33, 1}, []interface{}{34, 1}, []interface{}{35, 1}, []interface{}{36, 1}, []interface{}{37, 1}, []interface{}{38, 1}, []interface{}{39, 1}, []interface{}{40, 1}, []interface{}{41, 1}, []interface{}{42, 1}, []interface{}{43, 1}, []interface{}{44, 1}, []interface{}{45, 1}, []interface{}{46, 1}, []interface{}{47, 1}, []interface{}{48, 1}, []interface{}{49, 1}, []interface{}{50, 1}, []interface{}{51, 1}, []interface{}{52, 1}, []interface{}{53, 1}, []interface{}{54, 1}, []interface{}{55, 1}, []interface{}{56, 1}, []interface{}{57, 1}, []interface{}{58, 1}, []interface{}{59, 1}, []interface{}{60, 1}, []interface{}{61, 1}, []interface{}{62, 1}, []interface{}{63, 1}, []interface{}{64, 1}, []interface{}{65, 1}, []interface{}{66, 1}, []interface{}{67, 1}, []interface{}{68, 1}, []interface{}{69, 1}, []interface{}{70, 1}, []interface{}{71, 1}, []interface{}{72, 1}, []interface{}{73, 1}, []interface{}{74, 1}, []interface{}{75, 1}, []interface{}{76, 1}, []interface{}{77, 1}, []interface{}{78, 1}, []interface{}{79, 1}, []interface{}{80, 1}, []interface{}{81, 1}, []interface{}{82, 1}, []interface{}{83, 1}, []interface{}{84, 1}, []interface{}{85, 1}, []interface{}{86, 1}, []interface{}{87, 1}, []interface{}{88, 1}, []interface{}{89, 1}, []interface{}{90, 1}, []interface{}{91, 1}, []interface{}{92, 1}, []interface{}{93, 1}, []interface{}{94, 1}, []interface{}{95, 1}, []interface{}{96, 1}, []interface{}{97, 1}, []interface{}{98, 1}, []interface{}{99, 1}}} /* table_test_agg.group(index='id').count() */ suite.T().Log("About to run line #418: table_test_agg.Group().OptArgs(r.GroupOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group().OptArgs(r.GroupOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #418") } { // aggregation.yaml line #425 /* {'$reql_type$':'GROUPED_DATA', 'data':[[0, 25], [1, 25], [2, 25], [3, 25]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{0, 25}, []interface{}{1, 25}, []interface{}{2, 25}, []interface{}{3, 25}}} /* table_test_agg.group(index='a').count() */ suite.T().Log("About to run line #425: table_test_agg.Group().OptArgs(r.GroupOpts{Index: 'a', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group().OptArgs(r.GroupOpts{Index: "a"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #425") } { // aggregation.yaml line #432 /* {'$reql_type$':'GROUPED_DATA', 'data':[[[0, 0], 1], [[0, 4], 1], [[0, 8], 1], [[0, 12], 1], [[0, 16], 1], [[0, 20], 1], [[0, 24], 1], [[0, 28], 1], [[0, 32], 1], [[0, 36], 1], [[0, 40], 1], [[0, 44], 1], [[0, 48], 1], [[0, 52], 1], [[0, 56], 1], [[0, 60], 1], [[0, 64], 1], [[0, 68], 1], [[0, 72], 1], [[0, 76], 1], [[0, 80], 1], [[0, 84], 1], [[0, 88], 1], [[0, 92], 1], [[0, 96], 1], [[1, 1], 1], [[1, 5], 1], [[1, 9], 1], [[1, 13], 1], [[1, 17], 1], [[1, 21], 1], [[1, 25], 1], [[1, 29], 1], [[1, 33], 1], [[1, 37], 1], [[1, 41], 1], [[1, 45], 1], [[1, 49], 1], [[1, 53], 1], [[1, 57], 1], [[1, 61], 1], [[1, 65], 1], [[1, 69], 1], [[1, 73], 1], [[1, 77], 1], [[1, 81], 1], [[1, 85], 1], [[1, 89], 1], [[1, 93], 1], [[1, 97], 1], [[2, 2], 1], [[2, 6], 1], [[2, 10], 1], [[2, 14], 1], [[2, 18], 1], [[2, 22], 1], [[2, 26], 1], [[2, 30], 1], [[2, 34], 1], [[2, 38], 1], [[2, 42], 1], [[2, 46], 1], [[2, 50], 1], [[2, 54], 1], [[2, 58], 1], [[2, 62], 1], [[2, 66], 1], [[2, 70], 1], [[2, 74], 1], [[2, 78], 1], [[2, 82], 1], [[2, 86], 1], [[2, 90], 1], [[2, 94], 1], [[2, 98], 1], [[3, 3], 1], [[3, 7], 1], [[3, 11], 1], [[3, 15], 1], [[3, 19], 1], [[3, 23], 1], [[3, 27], 1], [[3, 31], 1], [[3, 35], 1], [[3, 39], 1], [[3, 43], 1], [[3, 47], 1], [[3, 51], 1], [[3, 55], 1], [[3, 59], 1], [[3, 63], 1], [[3, 67], 1], [[3, 71], 1], [[3, 75], 1], [[3, 79], 1], [[3, 83], 1], [[3, 87], 1], [[3, 91], 1], [[3, 95], 1], [[3, 99], 1]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{[]interface{}{0, 0}, 1}, []interface{}{[]interface{}{0, 4}, 1}, []interface{}{[]interface{}{0, 8}, 1}, []interface{}{[]interface{}{0, 12}, 1}, []interface{}{[]interface{}{0, 16}, 1}, []interface{}{[]interface{}{0, 20}, 1}, []interface{}{[]interface{}{0, 24}, 1}, []interface{}{[]interface{}{0, 28}, 1}, []interface{}{[]interface{}{0, 32}, 1}, []interface{}{[]interface{}{0, 36}, 1}, []interface{}{[]interface{}{0, 40}, 1}, []interface{}{[]interface{}{0, 44}, 1}, []interface{}{[]interface{}{0, 48}, 1}, []interface{}{[]interface{}{0, 52}, 1}, []interface{}{[]interface{}{0, 56}, 1}, []interface{}{[]interface{}{0, 60}, 1}, []interface{}{[]interface{}{0, 64}, 1}, []interface{}{[]interface{}{0, 68}, 1}, []interface{}{[]interface{}{0, 72}, 1}, []interface{}{[]interface{}{0, 76}, 1}, []interface{}{[]interface{}{0, 80}, 1}, []interface{}{[]interface{}{0, 84}, 1}, []interface{}{[]interface{}{0, 88}, 1}, []interface{}{[]interface{}{0, 92}, 1}, []interface{}{[]interface{}{0, 96}, 1}, []interface{}{[]interface{}{1, 1}, 1}, []interface{}{[]interface{}{1, 5}, 1}, []interface{}{[]interface{}{1, 9}, 1}, []interface{}{[]interface{}{1, 13}, 1}, []interface{}{[]interface{}{1, 17}, 1}, []interface{}{[]interface{}{1, 21}, 1}, []interface{}{[]interface{}{1, 25}, 1}, []interface{}{[]interface{}{1, 29}, 1}, []interface{}{[]interface{}{1, 33}, 1}, []interface{}{[]interface{}{1, 37}, 1}, []interface{}{[]interface{}{1, 41}, 1}, []interface{}{[]interface{}{1, 45}, 1}, []interface{}{[]interface{}{1, 49}, 1}, []interface{}{[]interface{}{1, 53}, 1}, []interface{}{[]interface{}{1, 57}, 1}, []interface{}{[]interface{}{1, 61}, 1}, []interface{}{[]interface{}{1, 65}, 1}, []interface{}{[]interface{}{1, 69}, 1}, []interface{}{[]interface{}{1, 73}, 1}, []interface{}{[]interface{}{1, 77}, 1}, []interface{}{[]interface{}{1, 81}, 1}, []interface{}{[]interface{}{1, 85}, 1}, []interface{}{[]interface{}{1, 89}, 1}, []interface{}{[]interface{}{1, 93}, 1}, []interface{}{[]interface{}{1, 97}, 1}, []interface{}{[]interface{}{2, 2}, 1}, []interface{}{[]interface{}{2, 6}, 1}, []interface{}{[]interface{}{2, 10}, 1}, []interface{}{[]interface{}{2, 14}, 1}, []interface{}{[]interface{}{2, 18}, 1}, []interface{}{[]interface{}{2, 22}, 1}, []interface{}{[]interface{}{2, 26}, 1}, []interface{}{[]interface{}{2, 30}, 1}, []interface{}{[]interface{}{2, 34}, 1}, []interface{}{[]interface{}{2, 38}, 1}, []interface{}{[]interface{}{2, 42}, 1}, []interface{}{[]interface{}{2, 46}, 1}, []interface{}{[]interface{}{2, 50}, 1}, []interface{}{[]interface{}{2, 54}, 1}, []interface{}{[]interface{}{2, 58}, 1}, []interface{}{[]interface{}{2, 62}, 1}, []interface{}{[]interface{}{2, 66}, 1}, []interface{}{[]interface{}{2, 70}, 1}, []interface{}{[]interface{}{2, 74}, 1}, []interface{}{[]interface{}{2, 78}, 1}, []interface{}{[]interface{}{2, 82}, 1}, []interface{}{[]interface{}{2, 86}, 1}, []interface{}{[]interface{}{2, 90}, 1}, []interface{}{[]interface{}{2, 94}, 1}, []interface{}{[]interface{}{2, 98}, 1}, []interface{}{[]interface{}{3, 3}, 1}, []interface{}{[]interface{}{3, 7}, 1}, []interface{}{[]interface{}{3, 11}, 1}, []interface{}{[]interface{}{3, 15}, 1}, []interface{}{[]interface{}{3, 19}, 1}, []interface{}{[]interface{}{3, 23}, 1}, []interface{}{[]interface{}{3, 27}, 1}, []interface{}{[]interface{}{3, 31}, 1}, []interface{}{[]interface{}{3, 35}, 1}, []interface{}{[]interface{}{3, 39}, 1}, []interface{}{[]interface{}{3, 43}, 1}, []interface{}{[]interface{}{3, 47}, 1}, []interface{}{[]interface{}{3, 51}, 1}, []interface{}{[]interface{}{3, 55}, 1}, []interface{}{[]interface{}{3, 59}, 1}, []interface{}{[]interface{}{3, 63}, 1}, []interface{}{[]interface{}{3, 67}, 1}, []interface{}{[]interface{}{3, 71}, 1}, []interface{}{[]interface{}{3, 75}, 1}, []interface{}{[]interface{}{3, 79}, 1}, []interface{}{[]interface{}{3, 83}, 1}, []interface{}{[]interface{}{3, 87}, 1}, []interface{}{[]interface{}{3, 91}, 1}, []interface{}{[]interface{}{3, 95}, 1}, []interface{}{[]interface{}{3, 99}, 1}}} /* table_test_agg.group('a', index='id').count() */ suite.T().Log("About to run line #432: table_test_agg.Group('a').OptArgs(r.GroupOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").OptArgs(r.GroupOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #432") } { // aggregation.yaml line #439 /* {'$reql_type$':'GROUPED_DATA', 'data':[[[0, 0], 25], [[1, 1], 25], [[2, 2], 25], [[3, 3], 25]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{[]interface{}{0, 0}, 25}, []interface{}{[]interface{}{1, 1}, 25}, []interface{}{[]interface{}{2, 2}, 25}, []interface{}{[]interface{}{3, 3}, 25}}} /* table_test_agg.group('a', index='a').count() */ suite.T().Log("About to run line #439: table_test_agg.Group('a').OptArgs(r.GroupOpts{Index: 'a', }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").OptArgs(r.GroupOpts{Index: "a"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #439") } { // aggregation.yaml line #447 /* {'$reql_type$':'GROUPED_DATA', 'data':[[[0, "f", null, [0]], 25], [[0, "f", null, null], 25], [[0, "f", null, 0], 25], [[0, "f", null, {}], 25], [[1, "f", null, [0]], 25], [[1, "f", null, null], 25], [[1, "f", null, 0], 25], [[1, "f", null, {}], 25], [[2, "f", null, [0]], 25], [[2, "f", null, null], 25], [[2, "f", null, 0], 25], [[2, "f", null, {}], 25], [[3, "f", null, [0]], 25], [[3, "f", null, null], 25], [[3, "f", null, 0], 25], [[3, "f", null, {}], 25]]} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GROUPED_DATA", "data": []interface{}{[]interface{}{[]interface{}{0, "f", nil, []interface{}{0}}, 25}, []interface{}{[]interface{}{0, "f", nil, nil}, 25}, []interface{}{[]interface{}{0, "f", nil, 0}, 25}, []interface{}{[]interface{}{0, "f", nil, map[interface{}]interface{}{}}, 25}, []interface{}{[]interface{}{1, "f", nil, []interface{}{0}}, 25}, []interface{}{[]interface{}{1, "f", nil, nil}, 25}, []interface{}{[]interface{}{1, "f", nil, 0}, 25}, []interface{}{[]interface{}{1, "f", nil, map[interface{}]interface{}{}}, 25}, []interface{}{[]interface{}{2, "f", nil, []interface{}{0}}, 25}, []interface{}{[]interface{}{2, "f", nil, nil}, 25}, []interface{}{[]interface{}{2, "f", nil, 0}, 25}, []interface{}{[]interface{}{2, "f", nil, map[interface{}]interface{}{}}, 25}, []interface{}{[]interface{}{3, "f", nil, []interface{}{0}}, 25}, []interface{}{[]interface{}{3, "f", nil, nil}, 25}, []interface{}{[]interface{}{3, "f", nil, 0}, 25}, []interface{}{[]interface{}{3, "f", nil, map[interface{}]interface{}{}}, 25}}} /* table_test_agg.group('a', lambda row:'f', lambda row:[], lambda row:[{}, [0], null, 0], multi=True).count() */ suite.T().Log("About to run line #447: table_test_agg.Group('a', func(row r.Term) interface{} { return 'f'}, func(row r.Term) interface{} { return []interface{}{}}, func(row r.Term) interface{} { return []interface{}{map[interface{}]interface{}{}, []interface{}{0}, nil, 0}}).OptArgs(r.GroupOpts{Multi: true, }).Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a", func(row r.Term) interface{} { return "f" }, func(row r.Term) interface{} { return []interface{}{} }, func(row r.Term) interface{} { return []interface{}{map[interface{}]interface{}{}, []interface{}{0}, nil, 0} }).OptArgs(r.GroupOpts{Multi: true}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "raw", }) suite.T().Log("Finished running line #447") } { // aggregation.yaml line #453 /* [{'group':0, 'reduction':25}, {'group':1, 'reduction':25}, {'group':2, 'reduction':25}, {'group':3, 'reduction':25}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"group": 0, "reduction": 25}, map[interface{}]interface{}{"group": 1, "reduction": 25}, map[interface{}]interface{}{"group": 2, "reduction": 25}, map[interface{}]interface{}{"group": 3, "reduction": 25}} /* table_test_agg.group('a').count().ungroup() */ suite.T().Log("About to run line #453: table_test_agg.Group('a').Count().Ungroup()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Count().Ungroup(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #453") } { // aggregation.yaml line #456 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_agg.group('a').ungroup()['group'] */ suite.T().Log("About to run line #456: table_test_agg.Group('a').Ungroup().AtIndex('group')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Ungroup().AtIndex("group"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #456") } { // aggregation.yaml line #460 /* [{'group':[0,0],'reduction':24},{'group':[1,1],'reduction':28},{'group':[2,2],'reduction':32},{'group':[3,3],'reduction':36}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"group": []interface{}{0, 0}, "reduction": 24}, map[interface{}]interface{}{"group": []interface{}{1, 1}, "reduction": 28}, map[interface{}]interface{}{"group": []interface{}{2, 2}, "reduction": 32}, map[interface{}]interface{}{"group": []interface{}{3, 3}, "reduction": 36}} /* table_test_agg.order_by(index='id').limit(16).group('a','a').map(r.row['id']).sum().ungroup() */ suite.T().Log("About to run line #460: table_test_agg.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Limit(16).Group('a', 'a').Map(r.Row.AtIndex('id')).Sum().Ungroup()") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Limit(16).Group("a", "a").Map(r.Row.AtIndex("id")).Sum().Ungroup(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #460") } { // aggregation.yaml line #465 /* [{'group':[0,null],'reduction':25},{'group':[1,null],'reduction':25},{'group':[2,null],'reduction':25},{'group':[3,null],'reduction':25}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"group": []interface{}{0, nil}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{1, nil}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{2, nil}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{3, nil}, "reduction": 25}} /* table_test_agg.group('a', null).count().ungroup() */ suite.T().Log("About to run line #465: table_test_agg.Group('a', nil).Count().Ungroup()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a", nil).Count().Ungroup(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #465") } { // aggregation.yaml line #468 /* [{'group':[0,1],'reduction':25},{'group':[0,'two'],'reduction':25},{'group':[1,1],'reduction':25},{'group':[1,'two'],'reduction':25},{'group':[2,1],'reduction':25},{'group':[2,'two'],'reduction':25},{'group':[3,1],'reduction':25},{'group':[3,'two'],'reduction':25}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"group": []interface{}{0, 1}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{0, "two"}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{1, 1}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{1, "two"}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{2, 1}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{2, "two"}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{3, 1}, "reduction": 25}, map[interface{}]interface{}{"group": []interface{}{3, "two"}, "reduction": 25}} /* table_test_agg.group('a', lambda row:[1,'two'], multi=True).count().ungroup() */ suite.T().Log("About to run line #468: table_test_agg.Group('a', func(row r.Term) interface{} { return []interface{}{1, 'two'}}).OptArgs(r.GroupOpts{Multi: true, }).Count().Ungroup()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a", func(row r.Term) interface{} { return []interface{}{1, "two"} }).OptArgs(r.GroupOpts{Multi: true}).Count().Ungroup(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #468") } { // aggregation.yaml line #474 /* 100 */ var expected_ int = 100 /* table_test_agg.count() */ suite.T().Log("About to run line #474: table_test_agg.Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #474") } { // aggregation.yaml line #478 /* partial({'errors':0, 'replaced':67}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 67}) /* table_test_agg.filter(r.row['a'].ne(1).and_(r.row['id'].gt(10))).update({'b':r.row['a'] * 10}) */ suite.T().Log("About to run line #478: table_test_agg.Filter(r.Row.AtIndex('a').Ne(1).And(r.Row.AtIndex('id').Gt(10))).Update(map[interface{}]interface{}{'b': r.Row.AtIndex('a').Mul(10), })") runAndAssert(suite.Suite, expected_, table_test_agg.Filter(r.Row.AtIndex("a").Ne(1).And(r.Row.AtIndex("id").Gt(10))).Update(map[interface{}]interface{}{"b": r.Row.AtIndex("a").Mul(10)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #478") } { // aggregation.yaml line #482 /* {null:33, 0:22, 20:22, 30:23} */ //var expected_ map[interface{}]interface{} = map[interface{}]interface{}{nil: 33, 0: 22, 20: 22, 30: 23} var expected_ = compare.UnorderedMatch([]map[string]interface{}{{"group": nil, "reduction": 33}, {"group": 0, "reduction": 22}, {"group": 20, "reduction": 22}, {"group": 30, "reduction": 23}}) /* table_test_agg.group('b').count() */ suite.T().Log("About to run line #482: table_test_agg.Group('b').Count()") runAndAssert(suite.Suite, expected_, table_test_agg.Group("b").Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "native", }) suite.T().Log("Finished running line #482") } { // aggregation.yaml line #487 /* {0:0, 2:440, 3:690} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 0, 2: 440, 3: 690} /* table_test_agg.group('a').sum('b') */ suite.T().Log("About to run line #487: table_test_agg.Group('a').Sum('b')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Sum("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #487") } { // aggregation.yaml line #492 /* {0:0, 2:20, 3:30} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: 0, 2: 20, 3: 30} /* table_test_agg.group('a').avg('b') */ suite.T().Log("About to run line #492: table_test_agg.Group('a').Avg('b')") runAndAssert(suite.Suite, expected_, table_test_agg.Group("a").Avg("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #492") } { // aggregation.yaml line #497 /* {0:{"a":0, "b":0, "id":12}, 2:{"a":2, "b":20, "id":14}, 3:{"a":3, "b":30, "id":11}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "b": 0, "id": 12}, 2: map[interface{}]interface{}{"a": 2, "b": 20, "id": 14}, 3: map[interface{}]interface{}{"a": 3, "b": 30, "id": 11}} /* table_test_agg.order_by('id').group('a').min('b') */ suite.T().Log("About to run line #497: table_test_agg.OrderBy('id').Group('a').Min('b')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy("id").Group("a").Min("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #497") } { // aggregation.yaml line #502 /* {0:{"a":0, "id":0}, 1:{"a":1, "id":1}, 2:{"a":2, "id":2}, 3:{"a":3, "id":3}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "id": 0}, 1: map[interface{}]interface{}{"a": 1, "id": 1}, 2: map[interface{}]interface{}{"a": 2, "id": 2}, 3: map[interface{}]interface{}{"a": 3, "id": 3}} /* table_test_agg.order_by('id').group('a').min('id') */ suite.T().Log("About to run line #502: table_test_agg.OrderBy('id').Group('a').Min('id')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy("id").Group("a").Min("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #502") } { // aggregation.yaml line #507 /* {0:{"a":0, "b":0, "id":12}, 2:{"a":2, "b":20, "id":14}, 3:{"a":3, "b":30, "id":11}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{0: map[interface{}]interface{}{"a": 0, "b": 0, "id": 12}, 2: map[interface{}]interface{}{"a": 2, "b": 20, "id": 14}, 3: map[interface{}]interface{}{"a": 3, "b": 30, "id": 11}} /* table_test_agg.order_by('id').group('a').max('b') */ suite.T().Log("About to run line #507: table_test_agg.OrderBy('id').Group('a').Max('b')") runAndAssert(suite.Suite, expected_, table_test_agg.OrderBy("id").Group("a").Max("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #507") } { // aggregation.yaml line #512 /* {'a':0,'id':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 0} /* table_test_agg.min() */ suite.T().Log("About to run line #512: table_test_agg.Min()") runAndAssert(suite.Suite, expected_, table_test_agg.Min(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #512") } { // aggregation.yaml line #514 /* {'a':0,'id':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 0} /* table_test_agg.min(index='id') */ suite.T().Log("About to run line #514: table_test_agg.Min().OptArgs(r.MinOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_agg.Min().OptArgs(r.MinOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #514") } { // aggregation.yaml line #518 /* {'a':0,'id':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0, "id": 0} /* table_test_agg.min(index='a') */ suite.T().Log("About to run line #518: table_test_agg.Min().OptArgs(r.MinOpts{Index: 'a', })") runAndAssert(suite.Suite, expected_, table_test_agg.Min().OptArgs(r.MinOpts{Index: "a"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #518") } { // aggregation.yaml line #523 /* {'a':3,'id':99} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 3, "id": 99} /* table_test_agg.max().without('b') */ suite.T().Log("About to run line #523: table_test_agg.Max().Without('b')") runAndAssert(suite.Suite, expected_, table_test_agg.Max().Without("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #523") } { // aggregation.yaml line #525 /* {'a':3,'id':99} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 3, "id": 99} /* table_test_agg.max(index='id').without('b') */ suite.T().Log("About to run line #525: table_test_agg.Max().OptArgs(r.MaxOpts{Index: 'id', }).Without('b')") runAndAssert(suite.Suite, expected_, table_test_agg.Max().OptArgs(r.MaxOpts{Index: "id"}).Without("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #525") } { // aggregation.yaml line #529 /* {'a':3,'id':99} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 3, "id": 99} /* table_test_agg.max(index='a').without('b') */ suite.T().Log("About to run line #529: table_test_agg.Max().OptArgs(r.MaxOpts{Index: 'a', }).Without('b')") runAndAssert(suite.Suite, expected_, table_test_agg.Max().OptArgs(r.MaxOpts{Index: "a"}).Without("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #529") } { // aggregation.yaml line #537 /* [ {'group': 1, 'reduction': 2}, {'group': 2, 'reduction': 1} ] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"group": 1, "reduction": 2}, map[interface{}]interface{}{"group": 2, "reduction": 1}} /* r.group([ 1, 1, 2 ], r.row).count().ungroup() */ suite.T().Log("About to run line #537: r.Group([]interface{}{1, 1, 2}, r.Row).Count().Ungroup()") runAndAssert(suite.Suite, expected_, r.Group([]interface{}{1, 1, 2}, r.Row).Count().Ungroup(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #537") } { // aggregation.yaml line #541 /* 2 */ var expected_ int = 2 /* r.count([ 1, 2 ]) */ suite.T().Log("About to run line #541: r.Count([]interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Count([]interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #541") } { // aggregation.yaml line #542 /* 2 */ var expected_ int = 2 /* r.count([ 1, 2 ], r.row.gt(0)) */ suite.T().Log("About to run line #542: r.Count([]interface{}{1, 2}, r.Row.Gt(0))") runAndAssert(suite.Suite, expected_, r.Count([]interface{}{1, 2}, r.Row.Gt(0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #542") } { // aggregation.yaml line #548 /* 3 */ var expected_ int = 3 /* r.sum([ 1, 2 ]) */ suite.T().Log("About to run line #548: r.Sum([]interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Sum([]interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #548") } { // aggregation.yaml line #549 /* 3 */ var expected_ int = 3 /* r.sum([ 1, 2 ], r.row) */ suite.T().Log("About to run line #549: r.Sum([]interface{}{1, 2}, r.Row)") runAndAssert(suite.Suite, expected_, r.Sum([]interface{}{1, 2}, r.Row), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #549") } { // aggregation.yaml line #553 /* 1.5 */ var expected_ float64 = 1.5 /* r.avg([ 1, 2 ]) */ suite.T().Log("About to run line #553: r.Avg([]interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Avg([]interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #553") } { // aggregation.yaml line #554 /* 1.5 */ var expected_ float64 = 1.5 /* r.avg([ 1, 2 ], r.row) */ suite.T().Log("About to run line #554: r.Avg([]interface{}{1, 2}, r.Row)") runAndAssert(suite.Suite, expected_, r.Avg([]interface{}{1, 2}, r.Row), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #554") } { // aggregation.yaml line #558 /* 1 */ var expected_ int = 1 /* r.min([ 1, 2 ]) */ suite.T().Log("About to run line #558: r.Min([]interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Min([]interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #558") } { // aggregation.yaml line #559 /* 1 */ var expected_ int = 1 /* r.min([ 1, 2 ], r.row) */ suite.T().Log("About to run line #559: r.Min([]interface{}{1, 2}, r.Row)") runAndAssert(suite.Suite, expected_, r.Min([]interface{}{1, 2}, r.Row), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #559") } { // aggregation.yaml line #563 /* 2 */ var expected_ int = 2 /* r.max([ 1, 2 ]) */ suite.T().Log("About to run line #563: r.Max([]interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Max([]interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #563") } { // aggregation.yaml line #564 /* 2 */ var expected_ int = 2 /* r.max([ 1, 2 ], r.row) */ suite.T().Log("About to run line #564: r.Max([]interface{}{1, 2}, r.Row)") runAndAssert(suite.Suite, expected_, r.Max([]interface{}{1, 2}, r.Row), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #564") } { // aggregation.yaml line #567 /* [ 1 ] */ var expected_ []interface{} = []interface{}{1} /* r.distinct([ 1, 1 ]) */ suite.T().Log("About to run line #567: r.Distinct([]interface{}{1, 1})") runAndAssert(suite.Suite, expected_, r.Distinct([]interface{}{1, 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #567") } { // aggregation.yaml line #570 /* true */ var expected_ bool = true /* r.contains([ 1, 2 ]) */ suite.T().Log("About to run line #570: r.Contains([]interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Contains([]interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #570") } { // aggregation.yaml line #571 /* true */ var expected_ bool = true /* r.contains([ 1, 2 ], r.row.gt(0)) */ suite.T().Log("About to run line #571: r.Contains([]interface{}{1, 2}, r.Row.Gt(0))") runAndAssert(suite.Suite, expected_, r.Contains([]interface{}{1, 2}, r.Row.Gt(0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #571") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_bitwise_test.go000066400000000000000000000066701363464422500265220ustar00rootroot00000000000000package reql_tests import ( "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "testing" ) // Test edge cases of bitwise operations func TestBitwiseSuite(t *testing.T) { suite.Run(t, new(BitwiseSuite)) } type BitwiseSuite struct { suite.Suite session *r.Session } func (suite *BitwiseSuite) SetupTest() { suite.T().Log("Setting up BitwiseSuite") session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session } func (suite *BitwiseSuite) TearDownSuite() { suite.T().Log("Tearing down BitwiseSuite") if suite.session != nil { suite.session.Close() } } func (suite *BitwiseSuite) TestCases() { suite.T().Log("Running BitwiseSuite: Test edge cases of bitwise operations") runOpts := r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", } { var q = r.BitAnd(3, 5) var expected_ = 3 & 5 suite.T().Logf("About to run line #1: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #1") } { var q = r.Expr(3).BitAnd(5) var expected_ = 3 & 5 suite.T().Logf("About to run line #2: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #2") } { var q = r.BitOr(3, 5) var expected_ = 3 | 5 suite.T().Logf("About to run line #3: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #3") } { var q = r.Expr(3).BitOr(5) var expected_ = 3 | 5 suite.T().Logf("About to run line #4: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #4") } { var q = r.BitXor(3, 5) var expected_ = 3 ^ 5 suite.T().Logf("About to run line #5: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #5") } { var q = r.Expr(3).BitXor(5) var expected_ = 3 ^ 5 suite.T().Logf("About to run line #6: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #6") } { var q = r.BitNot(3) var expected_ = ^3 suite.T().Logf("About to run line #7: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #7") } { var q = r.Expr(3).BitNot() var expected_ = ^3 suite.T().Logf("About to run line #8: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #8") } { var q = r.BitSal(3, 5) var expected_ = 3 << 5 suite.T().Logf("About to run line #9: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #9") } { var q = r.Expr(3).BitSal(5) var expected_ = 3 << 5 suite.T().Logf("About to run line #10: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #10") } { var q = r.BitSar(3, 5) var expected_ = 3 >> 5 suite.T().Logf("About to run line #11: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #11") } { var q = r.Expr(3).BitSar(5) var expected_ = 3 >> 5 suite.T().Logf("About to run line #12: %v", q) runAndAssert(suite.Suite, expected_, q, suite.session, runOpts) suite.T().Log("Finished running line #12") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_changefeeds_edge_test.go000066400000000000000000000600061363464422500302650ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test edge cases of changefeed operations func TestChangefeedsEdgeSuite(t *testing.T) { suite.Run(t, new(ChangefeedsEdgeSuite)) } type ChangefeedsEdgeSuite struct { suite.Suite session *r.Session } func (suite *ChangefeedsEdgeSuite) SetupTest() { suite.T().Log("Setting up ChangefeedsEdgeSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_feed_edge").Exec(suite.session) err = r.DBCreate("db_feed_edge").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_edge").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_feed_edge").TableDrop("table_test_changefeed_edge").Exec(suite.session) err = r.DB("db_feed_edge").TableCreate("table_test_changefeed_edge").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_edge").Table("table_test_changefeed_edge").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *ChangefeedsEdgeSuite) TearDownSuite() { suite.T().Log("Tearing down ChangefeedsEdgeSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_feed_edge").TableDrop("table_test_changefeed_edge").Exec(suite.session) r.DBDrop("db_feed_edge").Exec(suite.session) suite.session.Close() } } func (suite *ChangefeedsEdgeSuite) TestCases() { suite.T().Log("Running ChangefeedsEdgeSuite: Test edge cases of changefeed operations") table_test_changefeed_edge := r.DB("db_feed_edge").Table("table_test_changefeed_edge") _ = table_test_changefeed_edge // Prevent any noused variable errors // changefeeds/edge.yaml line #5 // common_prefix = r.expr([0,1,2,3,4,5,6,7,8]) suite.T().Log("Possibly executing: var common_prefix r.Term = r.Expr([]interface{}{0, 1, 2, 3, 4, 5, 6, 7, 8})") common_prefix := r.Expr([]interface{}{0, 1, 2, 3, 4, 5, 6, 7, 8}) _ = common_prefix // Prevent any noused variable errors { // changefeeds/edge.yaml line #8 /* ({'created':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_changefeed_edge.index_create('sindex', lambda row:common_prefix.append(row['value'])) */ suite.T().Log("About to run line #8: table_test_changefeed_edge.IndexCreateFunc('sindex', func(row r.Term) interface{} { return common_prefix.Append(row.AtIndex('value'))})") runAndAssert(suite.Suite, expected_, table_test_changefeed_edge.IndexCreateFunc("sindex", func(row r.Term) interface{} { return common_prefix.Append(row.AtIndex("value")) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // changefeeds/edge.yaml line #11 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_edge.index_wait('sindex') */ suite.T().Log("About to run line #11: table_test_changefeed_edge.IndexWait('sindex')") runAndAssert(suite.Suite, expected_, table_test_changefeed_edge.IndexWait("sindex"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } // changefeeds/edge.yaml line #14 // pre = r.range(7).coerce_to('array').add(r.range(10,70).coerce_to('array')).append(100).map(r.row.coerce_to('string')) suite.T().Log("Possibly executing: var pre r.Term = r.Range(7).CoerceTo('array').Add(r.Range(10, 70).CoerceTo('array')).Append(100).Map(r.Row.CoerceTo('string'))") pre := maybeRun(r.Range(7).CoerceTo("array").Add(r.Range(10, 70).CoerceTo("array")).Append(100).Map(r.Row.CoerceTo("string")), suite.session, r.RunOpts{}) _ = pre // Prevent any noused variable errors // changefeeds/edge.yaml line #16 // mid = r.range(2,9).coerce_to('array').add(r.range(20,90).coerce_to('array')).map(r.row.coerce_to('string')) suite.T().Log("Possibly executing: var mid r.Term = r.Range(2, 9).CoerceTo('array').Add(r.Range(20, 90).CoerceTo('array')).Map(r.Row.CoerceTo('string'))") mid := maybeRun(r.Range(2, 9).CoerceTo("array").Add(r.Range(20, 90).CoerceTo("array")).Map(r.Row.CoerceTo("string")), suite.session, r.RunOpts{}) _ = mid // Prevent any noused variable errors // changefeeds/edge.yaml line #18 // post = r.range(3,10).coerce_to('array').add(r.range(30,100).coerce_to('array')).map(r.row.coerce_to('string')) suite.T().Log("Possibly executing: var post r.Term = r.Range(3, 10).CoerceTo('array').Add(r.Range(30, 100).CoerceTo('array')).Map(r.Row.CoerceTo('string'))") post := maybeRun(r.Range(3, 10).CoerceTo("array").Add(r.Range(30, 100).CoerceTo("array")).Map(r.Row.CoerceTo("string")), suite.session, r.RunOpts{}) _ = post // Prevent any noused variable errors // changefeeds/edge.yaml line #21 // erroredres = r.range(2).coerce_to('array').add(r.range(10, 20).coerce_to('array')).append(100).map(r.row.coerce_to('string')) suite.T().Log("Possibly executing: var erroredres r.Term = r.Range(2).CoerceTo('array').Add(r.Range(10, 20).CoerceTo('array')).Append(100).Map(r.Row.CoerceTo('string'))") erroredres := maybeRun(r.Range(2).CoerceTo("array").Add(r.Range(10, 20).CoerceTo("array")).Append(100).Map(r.Row.CoerceTo("string")), suite.session, r.RunOpts{}) _ = erroredres // Prevent any noused variable errors // changefeeds/edge.yaml line #26 // pre_changes = table_test_changefeed_edge.between(r.minval, common_prefix.append('7'), index='sindex').changes(squash=False).limit(len(pre))['new_val']['value'] suite.T().Log("Possibly executing: var pre_changes r.Term = table_test_changefeed_edge.Between(r.MinVal, common_prefix.Append('7')).OptArgs(r.BetweenOpts{Index: 'sindex', }).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(pre)).AtIndex('new_val').AtIndex('value')") pre_changes := maybeRun(table_test_changefeed_edge.Between(r.MinVal, common_prefix.Append("7")).OptArgs(r.BetweenOpts{Index: "sindex"}).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(pre)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = pre_changes // Prevent any noused variable errors // changefeeds/edge.yaml line #29 // mid_changes = table_test_changefeed_edge.between(common_prefix.append('2'), common_prefix.append('9'), index='sindex').changes(squash=False).limit(len(post))['new_val']['value'] suite.T().Log("Possibly executing: var mid_changes r.Term = table_test_changefeed_edge.Between(common_prefix.Append('2'), common_prefix.Append('9')).OptArgs(r.BetweenOpts{Index: 'sindex', }).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(post)).AtIndex('new_val').AtIndex('value')") mid_changes := maybeRun(table_test_changefeed_edge.Between(common_prefix.Append("2"), common_prefix.Append("9")).OptArgs(r.BetweenOpts{Index: "sindex"}).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(post)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = mid_changes // Prevent any noused variable errors // changefeeds/edge.yaml line #32 // post_changes = table_test_changefeed_edge.between(common_prefix.append('3'), r.maxval, index='sindex').changes(squash=False).limit(len(mid))['new_val']['value'] suite.T().Log("Possibly executing: var post_changes r.Term = table_test_changefeed_edge.Between(common_prefix.Append('3'), r.MaxVal).OptArgs(r.BetweenOpts{Index: 'sindex', }).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(mid)).AtIndex('new_val').AtIndex('value')") post_changes := maybeRun(table_test_changefeed_edge.Between(common_prefix.Append("3"), r.MaxVal).OptArgs(r.BetweenOpts{Index: "sindex"}).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(mid)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = post_changes // Prevent any noused variable errors // changefeeds/edge.yaml line #38 // premap_changes1 = table_test_changefeed_edge.map(r.branch(r.row['value'].lt('2'), r.row, r.row["dummy"])).changes(squash=False).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var premap_changes1 r.Term = table_test_changefeed_edge.Map(r.Branch(r.Row.AtIndex('value').Lt('2'), r.Row, r.Row.AtIndex('dummy'))).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") premap_changes1 := maybeRun(table_test_changefeed_edge.Map(r.Branch(r.Row.AtIndex("value").Lt("2"), r.Row, r.Row.AtIndex("dummy"))).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = premap_changes1 // Prevent any noused variable errors // changefeeds/edge.yaml line #42 // postmap_changes1 = table_test_changefeed_edge.changes(squash=False).map(r.branch(r.row['new_val']['value'].lt('2'), r.row, r.row["dummy"])).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var postmap_changes1 r.Term = table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Map(r.Branch(r.Row.AtIndex('new_val').AtIndex('value').Lt('2'), r.Row, r.Row.AtIndex('dummy'))).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") postmap_changes1 := maybeRun(table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false}).Map(r.Branch(r.Row.AtIndex("new_val").AtIndex("value").Lt("2"), r.Row, r.Row.AtIndex("dummy"))).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = postmap_changes1 // Prevent any noused variable errors // changefeeds/edge.yaml line #46 // prefilter_changes1 = table_test_changefeed_edge.filter(r.branch(r.row['value'].lt('2'), True, r.row["dummy"])).changes(squash=False).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var prefilter_changes1 r.Term = table_test_changefeed_edge.Filter(r.Branch(r.Row.AtIndex('value').Lt('2'), true, r.Row.AtIndex('dummy'))).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") prefilter_changes1 := maybeRun(table_test_changefeed_edge.Filter(r.Branch(r.Row.AtIndex("value").Lt("2"), true, r.Row.AtIndex("dummy"))).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = prefilter_changes1 // Prevent any noused variable errors // changefeeds/edge.yaml line #50 // postfilter_changes1 = table_test_changefeed_edge.changes(squash=False).filter(r.branch(r.row['new_val']['value'].lt('2'), True, r.row["dummy"])).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var postfilter_changes1 r.Term = table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Filter(r.Branch(r.Row.AtIndex('new_val').AtIndex('value').Lt('2'), true, r.Row.AtIndex('dummy'))).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") postfilter_changes1 := maybeRun(table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false}).Filter(r.Branch(r.Row.AtIndex("new_val").AtIndex("value").Lt("2"), true, r.Row.AtIndex("dummy"))).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = postfilter_changes1 // Prevent any noused variable errors // changefeeds/edge.yaml line #56 // premap_changes2 = table_test_changefeed_edge.map(r.branch(r.row['value'].lt('2'), r.row, r.expr([])[1])).changes(squash=False).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var premap_changes2 r.Term = table_test_changefeed_edge.Map(r.Branch(r.Row.AtIndex('value').Lt('2'), r.Row, r.Expr([]interface{}{}).AtIndex(1))).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") premap_changes2 := maybeRun(table_test_changefeed_edge.Map(r.Branch(r.Row.AtIndex("value").Lt("2"), r.Row, r.Expr([]interface{}{}).AtIndex(1))).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = premap_changes2 // Prevent any noused variable errors // changefeeds/edge.yaml line #60 // postmap_changes2 = table_test_changefeed_edge.changes(squash=False).map(r.branch(r.row['new_val']['value'].lt('2'), r.row, r.expr([])[1])).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var postmap_changes2 r.Term = table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Map(r.Branch(r.Row.AtIndex('new_val').AtIndex('value').Lt('2'), r.Row, r.Expr([]interface{}{}).AtIndex(1))).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") postmap_changes2 := maybeRun(table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false}).Map(r.Branch(r.Row.AtIndex("new_val").AtIndex("value").Lt("2"), r.Row, r.Expr([]interface{}{}).AtIndex(1))).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = postmap_changes2 // Prevent any noused variable errors // changefeeds/edge.yaml line #64 // prefilter_changes2 = table_test_changefeed_edge.filter(r.branch(r.row['value'].lt('2'), True, r.expr([])[1])).changes(squash=False).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var prefilter_changes2 r.Term = table_test_changefeed_edge.Filter(r.Branch(r.Row.AtIndex('value').Lt('2'), true, r.Expr([]interface{}{}).AtIndex(1))).Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") prefilter_changes2 := maybeRun(table_test_changefeed_edge.Filter(r.Branch(r.Row.AtIndex("value").Lt("2"), true, r.Expr([]interface{}{}).AtIndex(1))).Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = prefilter_changes2 // Prevent any noused variable errors // changefeeds/edge.yaml line #68 // postfilter_changes2 = table_test_changefeed_edge.changes(squash=False).filter(r.branch(r.row['new_val']['value'].lt('2'), True, r.expr([])[1])).limit(len(erroredres))['new_val']['value'] suite.T().Log("Possibly executing: var postfilter_changes2 r.Term = table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Filter(r.Branch(r.Row.AtIndex('new_val').AtIndex('value').Lt('2'), true, r.Expr([]interface{}{}).AtIndex(1))).Limit(maybeLen(erroredres)).AtIndex('new_val').AtIndex('value')") postfilter_changes2 := maybeRun(table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false}).Filter(r.Branch(r.Row.AtIndex("new_val").AtIndex("value").Lt("2"), true, r.Expr([]interface{}{}).AtIndex(1))).Limit(maybeLen(erroredres)).AtIndex("new_val").AtIndex("value"), suite.session, r.RunOpts{}) _ = postfilter_changes2 // Prevent any noused variable errors // changefeeds/edge.yaml line #73 // nondetermmap = r.branch(r.random().gt(0.5), r.row, r.error("dummy")) suite.T().Log("Possibly executing: var nondetermmap r.Term = r.Branch(r.Random().Gt(0.5), r.Row, r.Error('dummy'))") nondetermmap := r.Branch(r.Random().Gt(0.5), r.Row, r.Error("dummy")) _ = nondetermmap // Prevent any noused variable errors // changefeeds/edge.yaml line #77 // nondetermfilter = lambda row:r.random().gt(0.5) suite.T().Log("Possibly executing: var nondetermfilter func() = func(row interface{}) interface{} { return r.Random().Gt(0.5)}") nondetermfilter := func(row interface{}) interface{} { return r.Random().Gt(0.5) } _ = nondetermfilter // Prevent any noused variable errors { // changefeeds/edge.yaml line #83 /* err('ReqlQueryLogicError', 'Cannot call `changes` after a non-deterministic function.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot call `changes` after a non-deterministic function.") /* table_test_changefeed_edge.map(nondetermmap).changes(squash=False) */ suite.T().Log("About to run line #83: table_test_changefeed_edge.Map(nondetermmap).Changes().OptArgs(r.ChangesOpts{Squash: false, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_edge.Map(nondetermmap).Changes().OptArgs(r.ChangesOpts{Squash: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } // changefeeds/edge.yaml line #88 // postmap_changes3 = table_test_changefeed_edge.changes(squash=False).map(nondetermmap).limit(100) suite.T().Log("Possibly executing: var postmap_changes3 r.Term = table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Map(nondetermmap).Limit(100)") postmap_changes3 := maybeRun(table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false}).Map(nondetermmap).Limit(100), suite.session, r.RunOpts{}) _ = postmap_changes3 // Prevent any noused variable errors { // changefeeds/edge.yaml line #92 /* err('ReqlQueryLogicError', 'Cannot call `changes` after a non-deterministic function.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot call `changes` after a non-deterministic function.") /* table_test_changefeed_edge.filter(nondetermfilter).changes(squash=False) */ suite.T().Log("About to run line #92: table_test_changefeed_edge.Filter(nondetermfilter).Changes().OptArgs(r.ChangesOpts{Squash: false, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_edge.Filter(nondetermfilter).Changes().OptArgs(r.ChangesOpts{Squash: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } // changefeeds/edge.yaml line #97 // postfilter_changes3 = table_test_changefeed_edge.changes(squash=False).filter(nondetermfilter).limit(4) suite.T().Log("Possibly executing: var postfilter_changes3 r.Term = table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Filter(nondetermfilter).Limit(4)") postfilter_changes3 := maybeRun(table_test_changefeed_edge.Changes().OptArgs(r.ChangesOpts{Squash: false}).Filter(nondetermfilter).Limit(4), suite.session, r.RunOpts{}) _ = postfilter_changes3 // Prevent any noused variable errors { // changefeeds/edge.yaml line #100 /* ({'skipped':0,'deleted':0,'unchanged':0,'errors':0,'replaced':0,'inserted':101}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"skipped": 0, "deleted": 0, "unchanged": 0, "errors": 0, "replaced": 0, "inserted": 101} /* table_test_changefeed_edge.insert(r.range(101).map({'id':r.uuid().coerce_to('binary').slice(0,r.random(4,24)).coerce_to('string'),'value':r.row.coerce_to('string')})) */ suite.T().Log("About to run line #100: table_test_changefeed_edge.Insert(r.Range(101).Map(map[interface{}]interface{}{'id': r.UUID().CoerceTo('binary').Slice(0, r.Random(4, 24)).CoerceTo('string'), 'value': r.Row.CoerceTo('string'), }))") runAndAssert(suite.Suite, expected_, table_test_changefeed_edge.Insert(r.Range(101).Map(map[interface{}]interface{}{"id": r.UUID().CoerceTo("binary").Slice(0, r.Random(4, 24)).CoerceTo("string"), "value": r.Row.CoerceTo("string")})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // changefeeds/edge.yaml line #105 /* bag(pre) */ var expected_ compare.Expected = compare.UnorderedMatch(pre) /* pre_changes */ suite.T().Log("About to run line #105: pre_changes") runAndAssert(suite.Suite, expected_, pre_changes, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #105") } { // changefeeds/edge.yaml line #108 /* bag(mid) */ var expected_ compare.Expected = compare.UnorderedMatch(mid) /* mid_changes */ suite.T().Log("About to run line #108: mid_changes") runAndAssert(suite.Suite, expected_, mid_changes, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // changefeeds/edge.yaml line #111 /* bag(post) */ var expected_ compare.Expected = compare.UnorderedMatch(post) /* post_changes */ suite.T().Log("About to run line #111: post_changes") runAndAssert(suite.Suite, expected_, post_changes, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // changefeeds/edge.yaml line #114 /* bag(erroredres) */ var expected_ compare.Expected = compare.UnorderedMatch(erroredres) /* premap_changes1 */ suite.T().Log("About to run line #114: premap_changes1") runAndAssert(suite.Suite, expected_, premap_changes1, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #114") } { // changefeeds/edge.yaml line #117 /* bag(erroredres) */ var expected_ compare.Expected = compare.UnorderedMatch(erroredres) /* premap_changes2 */ suite.T().Log("About to run line #117: premap_changes2") runAndAssert(suite.Suite, expected_, premap_changes2, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #117") } { // changefeeds/edge.yaml line #120 /* err('ReqlNonExistenceError', "No attribute `dummy` in object:") */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `dummy` in object:") /* postmap_changes1 */ suite.T().Log("About to run line #120: postmap_changes1") runAndAssert(suite.Suite, expected_, postmap_changes1, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #120") } { // changefeeds/edge.yaml line #123 /* err('ReqlNonExistenceError', "Index out of bounds:" + " 1") */ var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds:"+" 1") /* postmap_changes2 */ suite.T().Log("About to run line #123: postmap_changes2") runAndAssert(suite.Suite, expected_, postmap_changes2, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } { // changefeeds/edge.yaml line #126 /* err('ReqlUserError', "dummy") */ var expected_ Err = err("ReqlUserError", "dummy") /* postmap_changes3 */ suite.T().Log("About to run line #126: postmap_changes3") runAndAssert(suite.Suite, expected_, postmap_changes3, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #126") } { // changefeeds/edge.yaml line #129 /* bag(erroredres) */ var expected_ compare.Expected = compare.UnorderedMatch(erroredres) /* prefilter_changes1 */ suite.T().Log("About to run line #129: prefilter_changes1") runAndAssert(suite.Suite, expected_, prefilter_changes1, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #129") } { // changefeeds/edge.yaml line #132 /* bag(erroredres) */ var expected_ compare.Expected = compare.UnorderedMatch(erroredres) /* prefilter_changes2 */ suite.T().Log("About to run line #132: prefilter_changes2") runAndAssert(suite.Suite, expected_, prefilter_changes2, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #132") } { // changefeeds/edge.yaml line #135 /* bag(erroredres) */ var expected_ compare.Expected = compare.UnorderedMatch(erroredres) /* postfilter_changes1 */ suite.T().Log("About to run line #135: postfilter_changes1") runAndAssert(suite.Suite, expected_, postfilter_changes1, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #135") } { // changefeeds/edge.yaml line #138 /* bag(erroredres) */ var expected_ compare.Expected = compare.UnorderedMatch(erroredres) /* postfilter_changes2 */ suite.T().Log("About to run line #138: postfilter_changes2") runAndAssert(suite.Suite, expected_, postfilter_changes2, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #138") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_changefeeds_idxcopy_test.go000066400000000000000000000155371363464422500310510ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test duplicate indexes with squashing func TestChangefeedsIdxcopySuite(t *testing.T) { suite.Run(t, new(ChangefeedsIdxcopySuite)) } type ChangefeedsIdxcopySuite struct { suite.Suite session *r.Session } func (suite *ChangefeedsIdxcopySuite) SetupTest() { suite.T().Log("Setting up ChangefeedsIdxcopySuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_feed_idxcopy").Exec(suite.session) err = r.DBCreate("db_feed_idxcopy").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_idxcopy").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_feed_idxcopy").TableDrop("table_test_changefeed_idx").Exec(suite.session) err = r.DB("db_feed_idxcopy").TableCreate("table_test_changefeed_idx").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_idxcopy").Table("table_test_changefeed_idx").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *ChangefeedsIdxcopySuite) TearDownSuite() { suite.T().Log("Tearing down ChangefeedsIdxcopySuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_feed_idxcopy").TableDrop("table_test_changefeed_idx").Exec(suite.session) r.DBDrop("db_feed_idxcopy").Exec(suite.session) suite.session.Close() } } func (suite *ChangefeedsIdxcopySuite) TestCases() { suite.T().Log("Running ChangefeedsIdxcopySuite: Test duplicate indexes with squashing") table_test_changefeed_idx := r.DB("db_feed_idxcopy").Table("table_test_changefeed_idx") _ = table_test_changefeed_idx // Prevent any noused variable errors { // changefeeds/idxcopy.yaml line #4 /* partial({'created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"created": 1}) /* table_test_changefeed_idx.index_create('a') */ suite.T().Log("About to run line #4: table_test_changefeed_idx.IndexCreate('a')") runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.IndexCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // changefeeds/idxcopy.yaml line #6 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_idx.index_wait('a') */ suite.T().Log("About to run line #6: table_test_changefeed_idx.IndexWait('a')") runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.IndexWait("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } // changefeeds/idxcopy.yaml line #8 // feed = table_test_changefeed_idx.order_by(index='a').limit(10).changes(squash=2).limit(9) suite.T().Log("Possibly executing: var feed r.Term = table_test_changefeed_idx.OrderBy().OptArgs(r.OrderByOpts{Index: 'a', }).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: 2, }).Limit(9)") feed := maybeRun(table_test_changefeed_idx.OrderBy().OptArgs(r.OrderByOpts{Index: "a"}).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: 2}).Limit(9), suite.session, r.RunOpts{ MaxBatchRows: 1, }) _ = feed // Prevent any noused variable errors { // changefeeds/idxcopy.yaml line #15 /* partial({'inserted':12, 'errors':0}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 12, "errors": 0}) /* table_test_changefeed_idx.insert(r.range(0, 12).map({'id':r.row, 'a':5})) */ suite.T().Log("About to run line #15: table_test_changefeed_idx.Insert(r.Range(0, 12).Map(map[interface{}]interface{}{'id': r.Row, 'a': 5, }))") runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.Insert(r.Range(0, 12).Map(map[interface{}]interface{}{"id": r.Row, "a": 5})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // changefeeds/idxcopy.yaml line #20 /* partial({'deleted':3, 'errors':0}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"deleted": 3, "errors": 0}) /* table_test_changefeed_idx.get_all(1, 8, 9, index='id').delete() */ suite.T().Log("About to run line #20: table_test_changefeed_idx.GetAll(1, 8, 9).OptArgs(r.GetAllOpts{Index: 'id', }).Delete()") runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.GetAll(1, 8, 9).OptArgs(r.GetAllOpts{Index: "id"}).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // changefeeds/idxcopy.yaml line #26 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* wait(2) */ suite.T().Log("About to run line #26: wait(2)") actual := wait(2) compare.Assert(suite.T(), expected_, actual) suite.T().Log("Finished running line #26") } { // changefeeds/idxcopy.yaml line #28 /* bag([ {"new_val":{"a":5, "id":0}, "old_val":nil}, {"new_val":{"a":5, "id":2}, "old_val":nil}, {"new_val":{"a":5, "id":3}, "old_val":nil}, {"new_val":{"a":5, "id":4}, "old_val":nil}, {"new_val":{"a":5, "id":5}, "old_val":nil}, {"new_val":{"a":5, "id":6}, "old_val":nil}, {"new_val":{"a":5, "id":7}, "old_val":nil}, {"new_val":{"a":5, "id":10}, "old_val":nil}, {"new_val":{"a":5, "id":11}, "old_val":nil}]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 0}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 2}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 3}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 4}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 5}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 6}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 7}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 10}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 5, "id": 11}, "old_val": nil}}) /* fetch(feed) */ suite.T().Log("About to run line #28: fetch(feed, 0)") fetchAndAssert(suite.Suite, expected_, feed, 0) suite.T().Log("Finished running line #28") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_changefeeds_include_states_test.go000066400000000000000000000323351363464422500323730ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test `include_states` func TestChangefeedsIncludeStatesSuite(t *testing.T) { suite.Run(t, new(ChangefeedsIncludeStatesSuite)) } type ChangefeedsIncludeStatesSuite struct { suite.Suite session *r.Session } func (suite *ChangefeedsIncludeStatesSuite) SetupTest() { suite.T().Log("Setting up ChangefeedsIncludeStatesSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_feed_include").Exec(suite.session) err = r.DBCreate("db_feed_include").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_include").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_feed_include").TableDrop("table_test_changefeed_include").Exec(suite.session) err = r.DB("db_feed_include").TableCreate("table_test_changefeed_include").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_include").Table("table_test_changefeed_include").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *ChangefeedsIncludeStatesSuite) TearDownSuite() { suite.T().Log("Tearing down ChangefeedsIncludeStatesSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_feed_include").TableDrop("table_test_changefeed_include").Exec(suite.session) r.DBDrop("db_feed_include").Exec(suite.session) suite.session.Close() } } func (suite *ChangefeedsIncludeStatesSuite) TestCases() { suite.T().Log("Running ChangefeedsIncludeStatesSuite: Test `include_states`") table_test_changefeed_include := r.DB("db_feed_include").Table("table_test_changefeed_include") _ = table_test_changefeed_include // Prevent any noused variable errors { // changefeeds/include_states.yaml line #4 /* [{'state':'ready'}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "ready"}} /* table_test_changefeed_include.changes(squash=true, include_states=true).limit(1) */ suite.T().Log("About to run line #4: table_test_changefeed_include.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, }).Limit(1)") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true}).Limit(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // changefeeds/include_states.yaml line #9 /* [{'state':'initializing'}, {'new_val':null}, {'state':'ready'}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": nil}, map[interface{}]interface{}{"state": "ready"}} /* table_test_changefeed_include.get(0).changes(squash=true, include_states=true, include_initial=true).limit(3) */ suite.T().Log("About to run line #9: table_test_changefeed_include.Get(0).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true, }).Limit(3)") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.Get(0).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true}).Limit(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // changefeeds/include_states.yaml line #14 /* [{'state':'initializing'}, {'state':'ready'}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"state": "ready"}} /* table_test_changefeed_include.order_by(index='id').limit(10).changes(squash=true, include_states=true, include_initial=true).limit(2) */ suite.T().Log("About to run line #14: table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true, }).Limit(2)") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true}).Limit(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // changefeeds/include_states.yaml line #19 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_include.insert({'id':1}) */ suite.T().Log("About to run line #19: table_test_changefeed_include.Insert(map[interface{}]interface{}{'id': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.Insert(map[interface{}]interface{}{"id": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // changefeeds/include_states.yaml line #21 /* [{'state':'initializing'}, {'new_val':{'id':1}}, {'state':'ready'}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"state": "ready"}} /* table_test_changefeed_include.order_by(index='id').limit(10).changes(squash=true, include_states=true, include_initial=true).limit(3) */ suite.T().Log("About to run line #21: table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true, }).Limit(3)") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Limit(10).Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, IncludeInitial: true}).Limit(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } // changefeeds/include_states.yaml line #26 // table_test_changefeed_includechanges = table_test_changefeed_include.changes(squash=true, include_states=true) suite.T().Log("Possibly executing: var table_test_changefeed_includechanges r.Term = table_test_changefeed_include.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true, })") table_test_changefeed_includechanges := maybeRun(table_test_changefeed_include.Changes().OptArgs(r.ChangesOpts{Squash: true, IncludeStates: true}), suite.session, r.RunOpts{}) _ = table_test_changefeed_includechanges // Prevent any noused variable errors { // changefeeds/include_states.yaml line #30 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_include.insert({'id':2}) */ suite.T().Log("About to run line #30: table_test_changefeed_include.Insert(map[interface{}]interface{}{'id': 2, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.Insert(map[interface{}]interface{}{"id": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // changefeeds/include_states.yaml line #32 /* [{'state':'ready'},{'new_val':{'id':2},'old_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "ready"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 2}, "old_val": nil}} /* fetch(table_test_changefeed_includechanges, 2) */ suite.T().Log("About to run line #32: fetch(table_test_changefeed_includechanges, 2)") fetchAndAssert(suite.Suite, expected_, table_test_changefeed_includechanges, 2) suite.T().Log("Finished running line #32") } // changefeeds/include_states.yaml line #35 // getchanges = table_test_changefeed_include.get(2).changes(include_states=true, include_initial=true) suite.T().Log("Possibly executing: var getchanges r.Term = table_test_changefeed_include.Get(2).Changes().OptArgs(r.ChangesOpts{IncludeStates: true, IncludeInitial: true, })") getchanges := maybeRun(table_test_changefeed_include.Get(2).Changes().OptArgs(r.ChangesOpts{IncludeStates: true, IncludeInitial: true}), suite.session, r.RunOpts{}) _ = getchanges // Prevent any noused variable errors { // changefeeds/include_states.yaml line #39 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_include.get(2).update({'a':1}) */ suite.T().Log("About to run line #39: table_test_changefeed_include.Get(2).Update(map[interface{}]interface{}{'a': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.Get(2).Update(map[interface{}]interface{}{"a": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // changefeeds/include_states.yaml line #41 /* [{'state':'initializing'}, {'new_val':{'id':2}}, {'state':'ready'}, {'old_val':{'id':2},'new_val':{'id':2,'a':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 2}}, map[interface{}]interface{}{"state": "ready"}, map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 2}, "new_val": map[interface{}]interface{}{"id": 2, "a": 1}}} /* fetch(getchanges, 4) */ suite.T().Log("About to run line #41: fetch(getchanges, 4)") fetchAndAssert(suite.Suite, expected_, getchanges, 4) suite.T().Log("Finished running line #41") } // changefeeds/include_states.yaml line #44 // limitchanges = table_test_changefeed_include.order_by(index='id').limit(10).changes(include_states=true, include_initial=true) suite.T().Log("Possibly executing: var limitchanges r.Term = table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Limit(10).Changes().OptArgs(r.ChangesOpts{IncludeStates: true, IncludeInitial: true, })") limitchanges := maybeRun(table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Limit(10).Changes().OptArgs(r.ChangesOpts{IncludeStates: true, IncludeInitial: true}), suite.session, r.RunOpts{}) _ = limitchanges // Prevent any noused variable errors // changefeeds/include_states.yaml line #48 // limitchangesdesc = table_test_changefeed_include.order_by(index=r.desc('id')).limit(10).changes(include_states=true, include_initial=true) suite.T().Log("Possibly executing: var limitchangesdesc r.Term = table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: r.Desc('id'), }).Limit(10).Changes().OptArgs(r.ChangesOpts{IncludeStates: true, IncludeInitial: true, })") limitchangesdesc := maybeRun(table_test_changefeed_include.OrderBy().OptArgs(r.OrderByOpts{Index: r.Desc("id")}).Limit(10).Changes().OptArgs(r.ChangesOpts{IncludeStates: true, IncludeInitial: true}), suite.session, r.RunOpts{}) _ = limitchangesdesc // Prevent any noused variable errors { // changefeeds/include_states.yaml line #52 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_include.insert({'id':3}) */ suite.T().Log("About to run line #52: table_test_changefeed_include.Insert(map[interface{}]interface{}{'id': 3, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_include.Insert(map[interface{}]interface{}{"id": 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // changefeeds/include_states.yaml line #54 /* [{'state':'initializing'}, {'new_val':{'id':1}}, {'new_val':{'a':1, 'id':2}}, {'state':'ready'}, {'old_val':null, 'new_val':{'id':3}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 1, "id": 2}}, map[interface{}]interface{}{"state": "ready"}, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 3}}} /* fetch(limitchanges, 5) */ suite.T().Log("About to run line #54: fetch(limitchanges, 5)") fetchAndAssert(suite.Suite, expected_, limitchanges, 5) suite.T().Log("Finished running line #54") } { // changefeeds/include_states.yaml line #57 /* [{'state':'initializing'}, {'new_val':{'a':1, 'id':2}}, {'new_val':{'id':1}}, {'state':'ready'}, {'old_val':null, 'new_val':{'id':3}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"state": "initializing"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 1, "id": 2}}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"state": "ready"}, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 3}}} /* fetch(limitchangesdesc, 5) */ suite.T().Log("About to run line #57: fetch(limitchangesdesc, 5)") fetchAndAssert(suite.Suite, expected_, limitchangesdesc, 5) suite.T().Log("Finished running line #57") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_changefeeds_point_test.go000066400000000000000000000552471363464422500305250ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test point changebasics func TestChangefeedsPointSuite(t *testing.T) { suite.Run(t, new(ChangefeedsPointSuite)) } type ChangefeedsPointSuite struct { suite.Suite session *r.Session } func (suite *ChangefeedsPointSuite) SetupTest() { suite.T().Log("Setting up ChangefeedsPointSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_feed_point").Exec(suite.session) err = r.DBCreate("db_feed_point").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_point").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_feed_point").TableDrop("table_test_changefeed_point").Exec(suite.session) err = r.DB("db_feed_point").TableCreate("table_test_changefeed_point").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_point").Table("table_test_changefeed_point").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *ChangefeedsPointSuite) TearDownSuite() { suite.T().Log("Tearing down ChangefeedsPointSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_feed_point").TableDrop("table_test_changefeed_point").Exec(suite.session) r.DBDrop("db_feed_point").Exec(suite.session) suite.session.Close() } } func (suite *ChangefeedsPointSuite) TestCases() { suite.T().Log("Running ChangefeedsPointSuite: Test point changebasics") table_test_changefeed_point := r.DB("db_feed_point").Table("table_test_changefeed_point") _ = table_test_changefeed_point // Prevent any noused variable errors // changefeeds/point.yaml line #10 // basic = table_test_changefeed_point.get(1).changes(include_initial=True) suite.T().Log("Possibly executing: var basic r.Term = table_test_changefeed_point.Get(1).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true, })") basic := maybeRun(table_test_changefeed_point.Get(1).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true}), suite.session, r.RunOpts{}) _ = basic // Prevent any noused variable errors { // changefeeds/point.yaml line #14 /* [{'new_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": nil}} /* fetch(basic, 1) */ suite.T().Log("About to run line #14: fetch(basic, 1)") fetchAndAssert(suite.Suite, expected_, basic, 1) suite.T().Log("Finished running line #14") } { // changefeeds/point.yaml line #19 /* partial({'errors':0, 'inserted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) /* table_test_changefeed_point.insert({'id':1}) */ suite.T().Log("About to run line #19: table_test_changefeed_point.Insert(map[interface{}]interface{}{'id': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Insert(map[interface{}]interface{}{"id": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // changefeeds/point.yaml line #22 /* [{'old_val':null, 'new_val':{'id':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 1}}} /* fetch(basic, 1) */ suite.T().Log("About to run line #22: fetch(basic, 1)") fetchAndAssert(suite.Suite, expected_, basic, 1) suite.T().Log("Finished running line #22") } { // changefeeds/point.yaml line #27 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* table_test_changefeed_point.get(1).update({'update':1}) */ suite.T().Log("About to run line #27: table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{'update': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{"update": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // changefeeds/point.yaml line #30 /* [{'old_val':{'id':1}, 'new_val':{'id':1,'update':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "update": 1}}} /* fetch(basic, 1) */ suite.T().Log("About to run line #30: fetch(basic, 1)") fetchAndAssert(suite.Suite, expected_, basic, 1) suite.T().Log("Finished running line #30") } { // changefeeds/point.yaml line #35 /* partial({'errors':0, 'deleted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "deleted": 1}) /* table_test_changefeed_point.get(1).delete() */ suite.T().Log("About to run line #35: table_test_changefeed_point.Get(1).Delete()") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(1).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // changefeeds/point.yaml line #38 /* [{'old_val':{'id':1,'update':1}, 'new_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1, "update": 1}, "new_val": nil}} /* fetch(basic, 1) */ suite.T().Log("About to run line #38: fetch(basic, 1)") fetchAndAssert(suite.Suite, expected_, basic, 1) suite.T().Log("Finished running line #38") } // changefeeds/point.yaml line #49 // filter = table_test_changefeed_point.get(1).changes(squash=false,include_initial=True).filter(r.row['new_val']['update'].gt(2))['new_val']['update'] suite.T().Log("Possibly executing: var filter r.Term = table_test_changefeed_point.Get(1).Changes().OptArgs(r.ChangesOpts{Squash: false, IncludeInitial: true, }).Filter(r.Row.AtIndex('new_val').AtIndex('update').Gt(2)).AtIndex('new_val').AtIndex('update')") filter := maybeRun(table_test_changefeed_point.Get(1).Changes().OptArgs(r.ChangesOpts{Squash: false, IncludeInitial: true}).Filter(r.Row.AtIndex("new_val").AtIndex("update").Gt(2)).AtIndex("new_val").AtIndex("update"), suite.session, r.RunOpts{}) _ = filter // Prevent any noused variable errors { // changefeeds/point.yaml line #53 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_point.insert({'id':1, 'update':1}) */ suite.T().Log("About to run line #53: table_test_changefeed_point.Insert(map[interface{}]interface{}{'id': 1, 'update': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Insert(map[interface{}]interface{}{"id": 1, "update": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // changefeeds/point.yaml line #54 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_point.get(1).update({'update':4}) */ suite.T().Log("About to run line #54: table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{'update': 4, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{"update": 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // changefeeds/point.yaml line #55 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_point.get(1).update({'update':1}) */ suite.T().Log("About to run line #55: table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{'update': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{"update": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // changefeeds/point.yaml line #56 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_point.get(1).update({'update':7}) */ suite.T().Log("About to run line #56: table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{'update': 7, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{"update": 7}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #56") } { // changefeeds/point.yaml line #58 /* [4,7] */ var expected_ []interface{} = []interface{}{4, 7} /* fetch(filter, 2) */ suite.T().Log("About to run line #58: fetch(filter, 2)") fetchAndAssert(suite.Suite, expected_, filter, 2) suite.T().Log("Finished running line #58") } // changefeeds/point.yaml line #63 // pluck = table_test_changefeed_point.get(3).changes(squash=false,include_initial=True).pluck({'new_val':['red', 'blue']})['new_val'] suite.T().Log("Possibly executing: var pluck r.Term = table_test_changefeed_point.Get(3).Changes().OptArgs(r.ChangesOpts{Squash: false, IncludeInitial: true, }).Pluck(map[interface{}]interface{}{'new_val': []interface{}{'red', 'blue'}, }).AtIndex('new_val')") pluck := maybeRun(table_test_changefeed_point.Get(3).Changes().OptArgs(r.ChangesOpts{Squash: false, IncludeInitial: true}).Pluck(map[interface{}]interface{}{"new_val": []interface{}{"red", "blue"}}).AtIndex("new_val"), suite.session, r.RunOpts{}) _ = pluck // Prevent any noused variable errors { // changefeeds/point.yaml line #67 /* partial({'errors':0, 'inserted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) /* table_test_changefeed_point.insert({'id':3, 'red':1, 'green':1}) */ suite.T().Log("About to run line #67: table_test_changefeed_point.Insert(map[interface{}]interface{}{'id': 3, 'red': 1, 'green': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Insert(map[interface{}]interface{}{"id": 3, "red": 1, "green": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #67") } { // changefeeds/point.yaml line #69 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* table_test_changefeed_point.get(3).update({'blue':2, 'green':3}) */ suite.T().Log("About to run line #69: table_test_changefeed_point.Get(3).Update(map[interface{}]interface{}{'blue': 2, 'green': 3, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(3).Update(map[interface{}]interface{}{"blue": 2, "green": 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } { // changefeeds/point.yaml line #71 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* table_test_changefeed_point.get(3).update({'green':4}) */ suite.T().Log("About to run line #71: table_test_changefeed_point.Get(3).Update(map[interface{}]interface{}{'green': 4, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(3).Update(map[interface{}]interface{}{"green": 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // changefeeds/point.yaml line #73 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* table_test_changefeed_point.get(3).update({'blue':4}) */ suite.T().Log("About to run line #73: table_test_changefeed_point.Get(3).Update(map[interface{}]interface{}{'blue': 4, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Get(3).Update(map[interface{}]interface{}{"blue": 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // changefeeds/point.yaml line #76 /* [{'red': 1}, {'blue': 2, 'red': 1}, {'blue': 2, 'red': 1}, {'blue': 4, 'red': 1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"red": 1}, map[interface{}]interface{}{"blue": 2, "red": 1}, map[interface{}]interface{}{"blue": 2, "red": 1}, map[interface{}]interface{}{"blue": 4, "red": 1}} /* fetch(pluck, 4) */ suite.T().Log("About to run line #76: fetch(pluck, 4)") fetchAndAssert(suite.Suite, expected_, pluck, 4) suite.T().Log("Finished running line #76") } // changefeeds/point.yaml line #83 // dtable_test_changefeed_point = r.db('rethinkdb').table('_debug_scratch') suite.T().Log("Possibly executing: var dtable_test_changefeed_point r.Term = r.DB('rethinkdb').Table('_debug_scratch')") dtable_test_changefeed_point := r.DB("rethinkdb").Table("_debug_scratch") _ = dtable_test_changefeed_point // Prevent any noused variable errors // changefeeds/point.yaml line #86 // debug = dtable_test_changefeed_point.get(1).changes(include_initial=True) suite.T().Log("Possibly executing: var debug r.Term = dtable_test_changefeed_point.Get(1).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true, })") debug := maybeRun(dtable_test_changefeed_point.Get(1).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true}), suite.session, r.RunOpts{}) _ = debug // Prevent any noused variable errors { // changefeeds/point.yaml line #88 /* [{'new_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": nil}} /* fetch(debug, 1) */ suite.T().Log("About to run line #88: fetch(debug, 1)") fetchAndAssert(suite.Suite, expected_, debug, 1) suite.T().Log("Finished running line #88") } { // changefeeds/point.yaml line #91 /* partial({'errors':0, 'inserted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) /* dtable_test_changefeed_point.insert({'id':1}) */ suite.T().Log("About to run line #91: dtable_test_changefeed_point.Insert(map[interface{}]interface{}{'id': 1, })") runAndAssert(suite.Suite, expected_, dtable_test_changefeed_point.Insert(map[interface{}]interface{}{"id": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // changefeeds/point.yaml line #93 /* [{'old_val':null, 'new_val':{'id':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 1}}} /* fetch(debug, 1) */ suite.T().Log("About to run line #93: fetch(debug, 1)") fetchAndAssert(suite.Suite, expected_, debug, 1) suite.T().Log("Finished running line #93") } { // changefeeds/point.yaml line #96 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* dtable_test_changefeed_point.get(1).update({'update':1}) */ suite.T().Log("About to run line #96: dtable_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{'update': 1, })") runAndAssert(suite.Suite, expected_, dtable_test_changefeed_point.Get(1).Update(map[interface{}]interface{}{"update": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #96") } { // changefeeds/point.yaml line #98 /* [{'old_val':{'id':1}, 'new_val':{'id':1,'update':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "update": 1}}} /* fetch(debug, 1) */ suite.T().Log("About to run line #98: fetch(debug, 1)") fetchAndAssert(suite.Suite, expected_, debug, 1) suite.T().Log("Finished running line #98") } { // changefeeds/point.yaml line #101 /* partial({'errors':0, 'deleted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "deleted": 1}) /* dtable_test_changefeed_point.get(1).delete() */ suite.T().Log("About to run line #101: dtable_test_changefeed_point.Get(1).Delete()") runAndAssert(suite.Suite, expected_, dtable_test_changefeed_point.Get(1).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } { // changefeeds/point.yaml line #103 /* [{'old_val':{'id':1,'update':1}, 'new_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1, "update": 1}, "new_val": nil}} /* fetch(debug, 1) */ suite.T().Log("About to run line #103: fetch(debug, 1)") fetchAndAssert(suite.Suite, expected_, debug, 1) suite.T().Log("Finished running line #103") } { // changefeeds/point.yaml line #106 /* {'skipped':0, 'deleted':0, 'unchanged':0, 'errors':0, 'replaced':0, 'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"skipped": 0, "deleted": 0, "unchanged": 0, "errors": 0, "replaced": 0, "inserted": 1} /* dtable_test_changefeed_point.insert({'id':5, 'red':1, 'green':1}) */ suite.T().Log("About to run line #106: dtable_test_changefeed_point.Insert(map[interface{}]interface{}{'id': 5, 'red': 1, 'green': 1, })") runAndAssert(suite.Suite, expected_, dtable_test_changefeed_point.Insert(map[interface{}]interface{}{"id": 5, "red": 1, "green": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } // changefeeds/point.yaml line #108 // dtable_test_changefeed_pointPluck = dtable_test_changefeed_point.get(5).changes(include_initial=True).pluck({'new_val':['red', 'blue']})['new_val'] suite.T().Log("Possibly executing: var dtable_test_changefeed_pointPluck r.Term = dtable_test_changefeed_point.Get(5).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true, }).Pluck(map[interface{}]interface{}{'new_val': []interface{}{'red', 'blue'}, }).AtIndex('new_val')") dtable_test_changefeed_pointPluck := maybeRun(dtable_test_changefeed_point.Get(5).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true}).Pluck(map[interface{}]interface{}{"new_val": []interface{}{"red", "blue"}}).AtIndex("new_val"), suite.session, r.RunOpts{}) _ = dtable_test_changefeed_pointPluck // Prevent any noused variable errors { // changefeeds/point.yaml line #113 /* [{'red':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"red": 1}} /* fetch(dtable_test_changefeed_pointPluck, 1) */ suite.T().Log("About to run line #113: fetch(dtable_test_changefeed_pointPluck, 1)") fetchAndAssert(suite.Suite, expected_, dtable_test_changefeed_pointPluck, 1) suite.T().Log("Finished running line #113") } { // changefeeds/point.yaml line #116 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* dtable_test_changefeed_point.get(5).update({'blue':2, 'green':3}) */ suite.T().Log("About to run line #116: dtable_test_changefeed_point.Get(5).Update(map[interface{}]interface{}{'blue': 2, 'green': 3, })") runAndAssert(suite.Suite, expected_, dtable_test_changefeed_point.Get(5).Update(map[interface{}]interface{}{"blue": 2, "green": 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #116") } { // changefeeds/point.yaml line #119 /* [{'blue':2, 'red':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"blue": 2, "red": 1}} /* fetch(dtable_test_changefeed_pointPluck, 1) */ suite.T().Log("About to run line #119: fetch(dtable_test_changefeed_pointPluck, 1)") fetchAndAssert(suite.Suite, expected_, dtable_test_changefeed_pointPluck, 1) suite.T().Log("Finished running line #119") } // changefeeds/point.yaml line #132 // tableId = table_test_changefeed_point.info()['id'] suite.T().Log("Possibly executing: var tableId r.Term = table_test_changefeed_point.Info().AtIndex('id')") tableId := maybeRun(table_test_changefeed_point.Info().AtIndex("id"), suite.session, r.RunOpts{}) _ = tableId // Prevent any noused variable errors // changefeeds/point.yaml line #136 // rtblPluck = r.db('rethinkdb').table('table_status').get(tableId).changes(include_initial=True) suite.T().Log("Possibly executing: var rtblPluck r.Term = r.DB('rethinkdb').Table('table_status').Get(tableId).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true, })") rtblPluck := maybeRun(r.DB("rethinkdb").Table("table_status").Get(tableId).Changes().OptArgs(r.ChangesOpts{IncludeInitial: true}), suite.session, r.RunOpts{}) _ = rtblPluck // Prevent any noused variable errors { // changefeeds/point.yaml line #137 /* partial([{'new_val':partial({'db':'test'})}]) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{map[interface{}]interface{}{"new_val": compare.PartialMatch(map[interface{}]interface{}{"db": "db_feed_point"})}}) /* fetch(rtblPluck, 1) */ suite.T().Log("About to run line #137: fetch(rtblPluck, 1)") fetchAndAssert(suite.Suite, expected_, rtblPluck, 1) suite.T().Log("Finished running line #137") } { // changefeeds/point.yaml line #140 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_point.reconfigure(shards=3, replicas=1) */ suite.T().Log("About to run line #140: table_test_changefeed_point.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 3, Replicas: 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_point.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 3, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #140") } { // changefeeds/point.yaml line #143 /* partial([{'old_val':partial({'db':'test'}), 'new_val':partial({'db':'test'})}]) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{map[interface{}]interface{}{"old_val": compare.PartialMatch(map[interface{}]interface{}{"db": "db_feed_point"}), "new_val": compare.PartialMatch(map[interface{}]interface{}{"db": "db_feed_point"})}}) /* fetch(rtblPluck, 1, 2) */ suite.T().Log("About to run line #143: fetch(rtblPluck, 1)") fetchAndAssert(suite.Suite, expected_, rtblPluck, 1) suite.T().Log("Finished running line #143") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_changefeeds_table_test.go000066400000000000000000000362221363464422500304530ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test changefeeds on a table func TestChangefeedsTableSuite(t *testing.T) { suite.Run(t, new(ChangefeedsTableSuite)) } type ChangefeedsTableSuite struct { suite.Suite session *r.Session } func (suite *ChangefeedsTableSuite) SetupTest() { suite.T().Log("Setting up ChangefeedsTableSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_feed_table").Exec(suite.session) err = r.DBCreate("db_feed_table").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_table").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_feed_table").TableDrop("table_test_changefeed_table").Exec(suite.session) err = r.DB("db_feed_table").TableCreate("table_test_changefeed_table").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_feed_table").Table("table_test_changefeed_table").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *ChangefeedsTableSuite) TearDownSuite() { suite.T().Log("Tearing down ChangefeedsTableSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_feed_table").TableDrop("table_test_changefeed_table").Exec(suite.session) r.DBDrop("db_feed_table").Exec(suite.session) suite.session.Close() } } func (suite *ChangefeedsTableSuite) TestCases() { suite.T().Log("Running ChangefeedsTableSuite: Test changefeeds on a table") table_test_changefeed_table := r.DB("db_feed_table").Table("table_test_changefeed_table") _ = table_test_changefeed_table // Prevent any noused variable errors // changefeeds/table.yaml line #9 // all = table_test_changefeed_table.changes() suite.T().Log("Possibly executing: var all r.Term = table_test_changefeed_table.Changes()") all := maybeRun(table_test_changefeed_table.Changes(), suite.session, r.RunOpts{}) _ = all // Prevent any noused variable errors { // changefeeds/table.yaml line #15 /* partial({'errors':0, 'inserted':2}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 2}) /* table_test_changefeed_table.insert([{'id':1}, {'id':2}]) */ suite.T().Log("About to run line #15: table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 1, }, map[interface{}]interface{}{'id': 2, }})") runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 1}, map[interface{}]interface{}{"id": 2}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // changefeeds/table.yaml line #17 /* bag([{'old_val':null, 'new_val':{'id':1}}, {'old_val':null, 'new_val':{'id':2}}]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 2}}}) /* fetch(all, 2) */ suite.T().Log("About to run line #17: fetch(all, 2)") fetchAndAssert(suite.Suite, expected_, all, 2) suite.T().Log("Finished running line #17") } { // changefeeds/table.yaml line #22 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* table_test_changefeed_table.get(1).update({'version':1}) */ suite.T().Log("About to run line #22: table_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{'version': 1, })") runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{"version": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // changefeeds/table.yaml line #24 /* [{'old_val':{'id':1}, 'new_val':{'id':1, 'version':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "version": 1}}} /* fetch(all, 1) */ suite.T().Log("About to run line #24: fetch(all, 1)") fetchAndAssert(suite.Suite, expected_, all, 1) suite.T().Log("Finished running line #24") } { // changefeeds/table.yaml line #29 /* partial({'errors':0, 'deleted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "deleted": 1}) /* table_test_changefeed_table.get(1).delete() */ suite.T().Log("About to run line #29: table_test_changefeed_table.Get(1).Delete()") runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Get(1).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // changefeeds/table.yaml line #31 /* [{'old_val':{'id':1, 'version':1}, 'new_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1, "version": 1}, "new_val": nil}} /* fetch(all, 1) */ suite.T().Log("About to run line #31: fetch(all, 1)") fetchAndAssert(suite.Suite, expected_, all, 1) suite.T().Log("Finished running line #31") } // changefeeds/table.yaml line #36 // pluck = table_test_changefeed_table.changes().pluck({'new_val':['version']}) suite.T().Log("Possibly executing: var pluck r.Term = table_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{'new_val': []interface{}{'version'}, })") pluck := maybeRun(table_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{"new_val": []interface{}{"version"}}), suite.session, r.RunOpts{}) _ = pluck // Prevent any noused variable errors { // changefeeds/table.yaml line #37 /* partial({'errors':0, 'inserted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) /* table_test_changefeed_table.insert([{'id':5, 'version':5}]) */ suite.T().Log("About to run line #37: table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 5, 'version': 5, }})") runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 5, "version": 5}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // changefeeds/table.yaml line #39 /* [{'new_val':{'version':5}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"version": 5}}} /* fetch(pluck, 1) */ suite.T().Log("About to run line #39: fetch(pluck, 1)") fetchAndAssert(suite.Suite, expected_, pluck, 1) suite.T().Log("Finished running line #39") } { // changefeeds/table.yaml line #44 /* err('ReqlQueryLogicError', "Cannot call a terminal (`reduce`, `count`, etc.) on an infinite stream (such as a changefeed).") */ var expected_ Err = err("ReqlQueryLogicError", "Cannot call a terminal (`reduce`, `count`, etc.) on an infinite stream (such as a changefeed).") /* table_test_changefeed_table.changes().order_by('id') */ suite.T().Log("About to run line #44: table_test_changefeed_table.Changes().OrderBy('id')") runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Changes().OrderBy("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } // changefeeds/table.yaml line #59 // overflow = table_test_changefeed_table.changes(changefeed_queue_size=100) suite.T().Log("Possibly executing: var overflow r.Term = table_test_changefeed_table.Changes().OptArgs(r.ChangesOpts{ChangefeedQueueSize: 100, })") overflow := maybeRun(table_test_changefeed_table.Changes().OptArgs(r.ChangesOpts{ChangefeedQueueSize: 100}), suite.session, r.RunOpts{}) _ = overflow // Prevent any noused variable errors { // changefeeds/table.yaml line #62 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_changefeed_table.insert(r.range(200).map(lambda x: {})) */ suite.T().Log("About to run line #62: table_test_changefeed_table.Insert(r.Range(200).Map(func(x r.Term) interface{} { return map[interface{}]interface{}{}}))") runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Insert(r.Range(200).Map(func(x r.Term) interface{} { return map[interface{}]interface{}{} })), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // changefeeds/table.yaml line #64 /* partial([{'error': regex('Changefeed cache over array size limit, skipped \d+ elements.')}]) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{map[interface{}]interface{}{"error": compare.MatchesRegexp("Changefeed cache over array size limit, skipped \\d+ elements.")}}) /* fetch(overflow, 90) */ suite.T().Log("About to run line #64: fetch(overflow, 90)") fetchAndAssert(suite.Suite, expected_, overflow, 90) suite.T().Log("Finished running line #64") } // changefeeds/table.yaml line #69 // vtable_test_changefeed_table = r.db('rethinkdb').table('_debug_scratch') suite.T().Log("Possibly executing: var vtable_test_changefeed_table r.Term = r.DB('rethinkdb').Table('_debug_scratch')") vtable_test_changefeed_table := r.DB("rethinkdb").Table("_debug_scratch") _ = vtable_test_changefeed_table // Prevent any noused variable errors // changefeeds/table.yaml line #70 // allVirtual = vtable_test_changefeed_table.changes() suite.T().Log("Possibly executing: var allVirtual r.Term = vtable_test_changefeed_table.Changes()") allVirtual := maybeRun(vtable_test_changefeed_table.Changes(), suite.session, r.RunOpts{}) _ = allVirtual // Prevent any noused variable errors { // changefeeds/table.yaml line #74 /* partial({'errors':0, 'inserted':2}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 2}) /* vtable_test_changefeed_table.insert([{'id':1}, {'id':2}]) */ suite.T().Log("About to run line #74: vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 1, }, map[interface{}]interface{}{'id': 2, }})") runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 1}, map[interface{}]interface{}{"id": 2}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } { // changefeeds/table.yaml line #76 /* bag([{'old_val':null, 'new_val':{'id':1}}, {'old_val':null, 'new_val':{'id':2}}]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 1}}, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 2}}}) /* fetch(allVirtual, 2) */ suite.T().Log("About to run line #76: fetch(allVirtual, 2)") fetchAndAssert(suite.Suite, expected_, allVirtual, 2) suite.T().Log("Finished running line #76") } { // changefeeds/table.yaml line #81 /* partial({'errors':0, 'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) /* vtable_test_changefeed_table.get(1).update({'version':1}) */ suite.T().Log("About to run line #81: vtable_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{'version': 1, })") runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{"version": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #81") } { // changefeeds/table.yaml line #83 /* [{'old_val':{'id':1}, 'new_val':{'id':1, 'version':1}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "version": 1}}} /* fetch(allVirtual, 1) */ suite.T().Log("About to run line #83: fetch(allVirtual, 1)") fetchAndAssert(suite.Suite, expected_, allVirtual, 1) suite.T().Log("Finished running line #83") } { // changefeeds/table.yaml line #88 /* partial({'errors':0, 'deleted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "deleted": 1}) /* vtable_test_changefeed_table.get(1).delete() */ suite.T().Log("About to run line #88: vtable_test_changefeed_table.Get(1).Delete()") runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Get(1).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // changefeeds/table.yaml line #90 /* [{'old_val':{'id':1, 'version':1}, 'new_val':null}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1, "version": 1}, "new_val": nil}} /* fetch(allVirtual, 1) */ suite.T().Log("About to run line #90: fetch(allVirtual, 1)") fetchAndAssert(suite.Suite, expected_, allVirtual, 1) suite.T().Log("Finished running line #90") } // changefeeds/table.yaml line #95 // vpluck = vtable_test_changefeed_table.changes().pluck({'new_val':['version']}) suite.T().Log("Possibly executing: var vpluck r.Term = vtable_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{'new_val': []interface{}{'version'}, })") vpluck := maybeRun(vtable_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{"new_val": []interface{}{"version"}}), suite.session, r.RunOpts{}) _ = vpluck // Prevent any noused variable errors { // changefeeds/table.yaml line #96 /* partial({'errors':0, 'inserted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) /* vtable_test_changefeed_table.insert([{'id':5, 'version':5}]) */ suite.T().Log("About to run line #96: vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 5, 'version': 5, }})") runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 5, "version": 5}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #96") } { // changefeeds/table.yaml line #98 /* [{'new_val':{'version':5}}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"version": 5}}} /* fetch(vpluck, 1) */ suite.T().Log("About to run line #98: fetch(vpluck, 1)") fetchAndAssert(suite.Suite, expected_, vpluck, 1) suite.T().Log("Finished running line #98") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_control_test.go000066400000000000000000001153421363464422500265310ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests RQL control flow structures func TestControlSuite(t *testing.T) { suite.Run(t, new(ControlSuite)) } type ControlSuite struct { suite.Suite session *r.Session } func (suite *ControlSuite) SetupTest() { suite.T().Log("Setting up ControlSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_control").Exec(suite.session) err = r.DBCreate("db_control").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_control").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_control").TableDrop("table_test_control").Exec(suite.session) err = r.DB("db_control").TableCreate("table_test_control").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_control").Table("table_test_control").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_control").TableDrop("table_test_control2").Exec(suite.session) err = r.DB("db_control").TableCreate("table_test_control2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_control").Table("table_test_control2").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *ControlSuite) TearDownSuite() { suite.T().Log("Tearing down ControlSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_control").TableDrop("table_test_control").Exec(suite.session) r.DB("db_control").TableDrop("table_test_control2").Exec(suite.session) r.DBDrop("db_control").Exec(suite.session) suite.session.Close() } } func (suite *ControlSuite) TestCases() { suite.T().Log("Running ControlSuite: Tests RQL control flow structures") table_test_control := r.DB("db_control").Table("table_test_control") _ = table_test_control // Prevent any noused variable errors table_test_control2 := r.DB("db_control").Table("table_test_control2") _ = table_test_control2 // Prevent any noused variable errors { // control.yaml line #7 /* 2 */ var expected_ int = 2 /* r.expr(1).do(lambda v: v * 2) */ suite.T().Log("About to run line #7: r.Expr(1).Do(func(v r.Term) interface{} { return r.Mul(v, 2)})") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(func(v r.Term) interface{} { return r.Mul(v, 2) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // control.yaml line #12 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* r.expr([0, 1, 2]).do(lambda v: v.append(3)) */ suite.T().Log("About to run line #12: r.Expr([]interface{}{0, 1, 2}).Do(func(v r.Term) interface{} { return v.Append(3)})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{0, 1, 2}).Do(func(v r.Term) interface{} { return v.Append(3) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // control.yaml line #17 /* 3 */ var expected_ int = 3 /* r.do(1, 2, lambda x, y: x + y) */ suite.T().Log("About to run line #17: r.Do(1, 2, func(x r.Term, y r.Term) interface{} { return r.Add(x, y)})") runAndAssert(suite.Suite, expected_, r.Do(1, 2, func(x r.Term, y r.Term) interface{} { return r.Add(x, y) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } { // control.yaml line #22 /* 1 */ var expected_ int = 1 /* r.do(lambda: 1) */ suite.T().Log("About to run line #22: r.Do(func() interface{} { return 1})") runAndAssert(suite.Suite, expected_, r.Do(func() interface{} { return 1 }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // control.yaml line #38 /* 1 */ var expected_ int = 1 /* r.do(1) */ suite.T().Log("About to run line #38: r.Do(1)") runAndAssert(suite.Suite, expected_, r.Do(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // control.yaml line #53 /* err("ReqlQueryLogicError", "Expected type ARRAY but found STRING.", [1, 0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type ARRAY but found STRING.") /* r.expr('abc').do(lambda v: v.append(3)) */ suite.T().Log("About to run line #53: r.Expr('abc').Do(func(v r.Term) interface{} { return v.Append(3)})") runAndAssert(suite.Suite, expected_, r.Expr("abc").Do(func(v r.Term) interface{} { return v.Append(3) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // control.yaml line #58 /* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", [1, 1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* r.expr('abc').do(lambda v: v + 3) */ suite.T().Log("About to run line #58: r.Expr('abc').Do(func(v r.Term) interface{} { return r.Add(v, 3)})") runAndAssert(suite.Suite, expected_, r.Expr("abc").Do(func(v r.Term) interface{} { return r.Add(v, 3) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // control.yaml line #63 /* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* r.expr('abc').do(lambda v: v + 'def') + 3 */ suite.T().Log("About to run line #63: r.Expr('abc').Do(func(v r.Term) interface{} { return r.Add(v, 'def')}).Add(3)") runAndAssert(suite.Suite, expected_, r.Expr("abc").Do(func(v r.Term) interface{} { return r.Add(v, "def") }).Add(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } { // control.yaml line #78 /* 5 */ var expected_ int = 5 /* r.expr(5).do(r.row) */ suite.T().Log("About to run line #78: r.Expr(5).Do(r.Row)") runAndAssert(suite.Suite, expected_, r.Expr(5).Do(r.Row), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #78") } { // control.yaml line #84 /* 1 */ var expected_ int = 1 /* r.branch(True, 1, 2) */ suite.T().Log("About to run line #84: r.Branch(true, 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(true, 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // control.yaml line #86 /* 2 */ var expected_ int = 2 /* r.branch(False, 1, 2) */ suite.T().Log("About to run line #86: r.Branch(false, 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(false, 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // control.yaml line #88 /* ("c") */ var expected_ string = "c" /* r.branch(1, 'c', False) */ suite.T().Log("About to run line #88: r.Branch(1, 'c', false)") runAndAssert(suite.Suite, expected_, r.Branch(1, "c", false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // control.yaml line #90 /* ([]) */ var expected_ []interface{} = []interface{}{} /* r.branch(null, {}, []) */ suite.T().Log("About to run line #90: r.Branch(nil, map[interface{}]interface{}{}, []interface{}{})") runAndAssert(suite.Suite, expected_, r.Branch(nil, map[interface{}]interface{}{}, []interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #90") } { // control.yaml line #93 /* err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:") /* r.branch(r.db('test'), 1, 2) */ suite.T().Log("About to run line #93: r.Branch(r.DB('test'), 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(r.DB("db_control"), 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } { // control.yaml line #95 /* err("ReqlQueryLogicError", "Expected type DATUM but found TABLE:", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type DATUM but found TABLE:") /* r.branch(table_test_control, 1, 2) */ suite.T().Log("About to run line #95: r.Branch(table_test_control, 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(table_test_control, 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #95") } { // control.yaml line #97 /* err("ReqlUserError", "a", []) */ var expected_ Err = err("ReqlUserError", "a") /* r.branch(r.error("a"), 1, 2) */ suite.T().Log("About to run line #97: r.Branch(r.Error('a'), 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(r.Error("a"), 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #97") } { // control.yaml line #100 /* 1 */ var expected_ int = 1 /* r.branch([], 1, 2) */ suite.T().Log("About to run line #100: r.Branch([]interface{}{}, 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch([]interface{}{}, 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // control.yaml line #102 /* 1 */ var expected_ int = 1 /* r.branch({}, 1, 2) */ suite.T().Log("About to run line #102: r.Branch(map[interface{}]interface{}{}, 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(map[interface{}]interface{}{}, 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } { // control.yaml line #104 /* 1 */ var expected_ int = 1 /* r.branch("a", 1, 2) */ suite.T().Log("About to run line #104: r.Branch('a', 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch("a", 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #104") } { // control.yaml line #106 /* 1 */ var expected_ int = 1 /* r.branch(1.2, 1, 2) */ suite.T().Log("About to run line #106: r.Branch(1.2, 1, 2)") runAndAssert(suite.Suite, expected_, r.Branch(1.2, 1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } { // control.yaml line #109 /* 1 */ var expected_ int = 1 /* r.branch(True, 1, True, 2, 3) */ suite.T().Log("About to run line #109: r.Branch(true, 1, true, 2, 3)") runAndAssert(suite.Suite, expected_, r.Branch(true, 1, true, 2, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // control.yaml line #111 /* 1 */ var expected_ int = 1 /* r.branch(True, 1, False, 2, 3) */ suite.T().Log("About to run line #111: r.Branch(true, 1, false, 2, 3)") runAndAssert(suite.Suite, expected_, r.Branch(true, 1, false, 2, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // control.yaml line #113 /* 2 */ var expected_ int = 2 /* r.branch(False, 1, True, 2, 3) */ suite.T().Log("About to run line #113: r.Branch(false, 1, true, 2, 3)") runAndAssert(suite.Suite, expected_, r.Branch(false, 1, true, 2, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #113") } { // control.yaml line #115 /* 3 */ var expected_ int = 3 /* r.branch(False, 1, False, 2, 3) */ suite.T().Log("About to run line #115: r.Branch(false, 1, false, 2, 3)") runAndAssert(suite.Suite, expected_, r.Branch(false, 1, false, 2, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #115") } { // control.yaml line #118 /* err("ReqlQueryLogicError", "Cannot call `branch` term with an even number of arguments.") */ var expected_ Err = err("ReqlQueryLogicError", "Cannot call `branch` term with an even number of arguments.") /* r.branch(True, 1, True, 2) */ suite.T().Log("About to run line #118: r.Branch(true, 1, true, 2)") runAndAssert(suite.Suite, expected_, r.Branch(true, 1, true, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } { // control.yaml line #122 /* err("ReqlUserError", "Hello World", [0]) */ var expected_ Err = err("ReqlUserError", "Hello World") /* r.error('Hello World') */ suite.T().Log("About to run line #122: r.Error('Hello World')") runAndAssert(suite.Suite, expected_, r.Error("Hello World"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // control.yaml line #125 /* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* r.error(5) */ suite.T().Log("About to run line #125: r.Error(5)") runAndAssert(suite.Suite, expected_, r.Error(5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // control.yaml line #140 /* 2 */ var expected_ int = 2 /* r.js('1 + 1') */ suite.T().Log("About to run line #140: r.JS('1 + 1')") runAndAssert(suite.Suite, expected_, r.JS("1 + 1"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #140") } { // control.yaml line #143 /* 4 */ var expected_ int = 4 /* r.js('1 + 1; 2 + 2') */ suite.T().Log("About to run line #143: r.JS('1 + 1; 2 + 2')") runAndAssert(suite.Suite, expected_, r.JS("1 + 1; 2 + 2"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #143") } { // control.yaml line #146 /* 3 */ var expected_ int = 3 /* r.do(1, 2, r.js('(function(a, b) { return a + b; })')) */ suite.T().Log("About to run line #146: r.Do(1, 2, r.JS('(function(a, b) { return a + b; })'))") runAndAssert(suite.Suite, expected_, r.Do(1, 2, r.JS("(function(a, b) { return a + b; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #146") } { // control.yaml line #149 /* 2 */ var expected_ int = 2 /* r.expr(1).do(r.js('(function(x) { return x + 1; })')) */ suite.T().Log("About to run line #149: r.Expr(1).Do(r.JS('(function(x) { return x + 1; })'))") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(r.JS("(function(x) { return x + 1; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #149") } { // control.yaml line #152 /* 'foobar' */ var expected_ string = "foobar" /* r.expr('foo').do(r.js('(function(x) { return x + "bar"; })')) */ suite.T().Log("About to run line #152: r.Expr('foo').Do(r.JS('(function(x) { return x + \\'bar\\'; })'))") runAndAssert(suite.Suite, expected_, r.Expr("foo").Do(r.JS("(function(x) { return x + \"bar\"; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #152") } { // control.yaml line #157 /* 3 */ var expected_ int = 3 /* r.js('1 + 2', timeout=1.2) */ suite.T().Log("About to run line #157: r.JS('1 + 2').OptArgs(r.JSOpts{Timeout: 1.2, })") runAndAssert(suite.Suite, expected_, r.JS("1 + 2").OptArgs(r.JSOpts{Timeout: 1.2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #157") } { // control.yaml line #161 /* err("ReqlQueryLogicError", "Query result must be of type DATUM, GROUPED_DATA, or STREAM (got FUNCTION).", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Query result must be of type DATUM, GROUPED_DATA, or STREAM (got FUNCTION).") /* r.js('(function() { return 1; })') */ suite.T().Log("About to run line #161: r.JS('(function() { return 1; })')") runAndAssert(suite.Suite, expected_, r.JS("(function() { return 1; })"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #161") } { // control.yaml line #164 /* err("ReqlQueryLogicError", "SyntaxError: Unexpected token (", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "SyntaxError: Unexpected token (") /* r.js('function() { return 1; }') */ suite.T().Log("About to run line #164: r.JS('function() { return 1; }')") runAndAssert(suite.Suite, expected_, r.JS("function() { return 1; }"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #164") } { // control.yaml line #168 /* 1 */ var expected_ int = 1 /* r.do(1, 2, r.js('(function(a) { return a; })')) */ suite.T().Log("About to run line #168: r.Do(1, 2, r.JS('(function(a) { return a; })'))") runAndAssert(suite.Suite, expected_, r.Do(1, 2, r.JS("(function(a) { return a; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #168") } { // control.yaml line #171 /* 1 */ var expected_ int = 1 /* r.do(1, 2, r.js('(function(a, b, c) { return a; })')) */ suite.T().Log("About to run line #171: r.Do(1, 2, r.JS('(function(a, b, c) { return a; })'))") runAndAssert(suite.Suite, expected_, r.Do(1, 2, r.JS("(function(a, b, c) { return a; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #171") } { // control.yaml line #174 /* err("ReqlQueryLogicError", "Cannot convert javascript `undefined` to ql::datum_t.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert javascript `undefined` to ql::datum_t.") /* r.do(1, 2, r.js('(function(a, b, c) { return c; })')) */ suite.T().Log("About to run line #174: r.Do(1, 2, r.JS('(function(a, b, c) { return c; })'))") runAndAssert(suite.Suite, expected_, r.Do(1, 2, r.JS("(function(a, b, c) { return c; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #174") } { // control.yaml line #177 /* ([2, 3]) */ var expected_ []interface{} = []interface{}{2, 3} /* r.expr([1, 2, 3]).filter(r.js('(function(a) { return a >= 2; })')) */ suite.T().Log("About to run line #177: r.Expr([]interface{}{1, 2, 3}).Filter(r.JS('(function(a) { return a >= 2; })'))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Filter(r.JS("(function(a) { return a >= 2; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #177") } { // control.yaml line #180 /* ([2, 3, 4]) */ var expected_ []interface{} = []interface{}{2, 3, 4} /* r.expr([1, 2, 3]).map(r.js('(function(a) { return a + 1; })')) */ suite.T().Log("About to run line #180: r.Expr([]interface{}{1, 2, 3}).Map(r.JS('(function(a) { return a + 1; })'))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Map(r.JS("(function(a) { return a + 1; })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #180") } { // control.yaml line #183 /* err("ReqlQueryLogicError", "Expected type FUNCTION but found DATUM:", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type FUNCTION but found DATUM:") /* r.expr([1, 2, 3]).map(r.js('1')) */ suite.T().Log("About to run line #183: r.Expr([]interface{}{1, 2, 3}).Map(r.JS('1'))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Map(r.JS("1")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #183") } { // control.yaml line #186 /* err("ReqlQueryLogicError", "Cannot convert javascript `undefined` to ql::datum_t.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert javascript `undefined` to ql::datum_t.") /* r.expr([1, 2, 3]).filter(r.js('(function(a) {})')) */ suite.T().Log("About to run line #186: r.Expr([]interface{}{1, 2, 3}).Filter(r.JS('(function(a) {})'))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Filter(r.JS("(function(a) {})")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #186") } { // control.yaml line #190 /* err("ReqlQueryLogicError", "Expected type FUNCTION but found DATUM:", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type FUNCTION but found DATUM:") /* r.expr([1, 2, 3]).map(1) */ suite.T().Log("About to run line #190: r.Expr([]interface{}{1, 2, 3}).Map(1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Map(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #190") } { // control.yaml line #193 /* ([1, 2, 3]) */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.expr([1, 2, 3]).filter('foo') */ suite.T().Log("About to run line #193: r.Expr([]interface{}{1, 2, 3}).Filter('foo')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Filter("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #193") } { // control.yaml line #195 /* ([1, 2, 4]) */ var expected_ []interface{} = []interface{}{1, 2, 4} /* r.expr([1, 2, 4]).filter([]) */ suite.T().Log("About to run line #195: r.Expr([]interface{}{1, 2, 4}).Filter([]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 4}).Filter([]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #195") } { // control.yaml line #197 /* ([]) */ var expected_ []interface{} = []interface{}{} /* r.expr([1, 2, 3]).filter(null) */ suite.T().Log("About to run line #197: r.Expr([]interface{}{1, 2, 3}).Filter(nil)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Filter(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #197") } { // control.yaml line #200 /* ([]) */ var expected_ []interface{} = []interface{}{} /* r.expr([1, 2, 4]).filter(False) */ suite.T().Log("About to run line #200: r.Expr([]interface{}{1, 2, 4}).Filter(false)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 4}).Filter(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #200") } { // control.yaml line #205 /* 0 */ var expected_ int = 0 /* table_test_control.count() */ suite.T().Log("About to run line #205: table_test_control.Count()") runAndAssert(suite.Suite, expected_, table_test_control.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #205") } { // control.yaml line #210 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':3}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 3} /* r.expr([1, 2, 3]).for_each(lambda row:table_test_control.insert({ 'id':row })) */ suite.T().Log("About to run line #210: r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return table_test_control.Insert(map[interface{}]interface{}{'id': row, })})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return table_test_control.Insert(map[interface{}]interface{}{"id": row}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #210") } { // control.yaml line #214 /* 3 */ var expected_ int = 3 /* table_test_control.count() */ suite.T().Log("About to run line #214: table_test_control.Count()") runAndAssert(suite.Suite, expected_, table_test_control.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #214") } { // control.yaml line #219 /* ({'deleted':0.0,'replaced':9,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 9, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* r.expr([1,2,3]).for_each(lambda row:table_test_control.update({'foo':row})) */ suite.T().Log("About to run line #219: r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return table_test_control.Update(map[interface{}]interface{}{'foo': row, })})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return table_test_control.Update(map[interface{}]interface{}{"foo": row}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #219") } { // control.yaml line #225 /* {'first_error':"Duplicate primary key `id`:\n{\n\t\"foo\":\t3,\n\t\"id\":\t1\n}\n{\n\t\"id\":\t1\n}",'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':3,'skipped':0.0,'inserted':3} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Duplicate primary key `id`:\n{\n\t\"foo\":\t3,\n\t\"id\":\t1\n}\n{\n\t\"id\":\t1\n}", "deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 3, "skipped": 0.0, "inserted": 3} /* r.expr([1,2,3]).for_each(lambda row:[table_test_control.insert({ 'id':row }), table_test_control.insert({ 'id':row*10 })]) */ suite.T().Log("About to run line #225: r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return []interface{}{table_test_control.Insert(map[interface{}]interface{}{'id': row, }), table_test_control.Insert(map[interface{}]interface{}{'id': r.Mul(row, 10), })}})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return []interface{}{table_test_control.Insert(map[interface{}]interface{}{"id": row}), table_test_control.Insert(map[interface{}]interface{}{"id": r.Mul(row, 10)})} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #225") } { // control.yaml line #229 /* 6 */ var expected_ int = 6 /* table_test_control.count() */ suite.T().Log("About to run line #229: table_test_control.Count()") runAndAssert(suite.Suite, expected_, table_test_control.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #229") } { // control.yaml line #232 /* ({'deleted':0.0,'replaced':0.0,'generated_keys':arrlen(3,uuid()),'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':3}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "generated_keys": arrlen(3, compare.IsUUID()), "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 3} /* r.expr([1, 2, 3]).for_each( table_test_control2.insert({}) ) */ suite.T().Log("About to run line #232: r.Expr([]interface{}{1, 2, 3}).ForEach(table_test_control2.Insert(map[interface{}]interface{}{}))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(table_test_control2.Insert(map[interface{}]interface{}{})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #232") } { // control.yaml line #235 /* 1 */ var expected_ int = 1 /* table_test_control2.count() */ suite.T().Log("About to run line #235: table_test_control2.Count()") runAndAssert(suite.Suite, expected_, table_test_control2.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #235") } { // control.yaml line #240 /* ({'deleted':0.0,'replaced':36,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 36, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* r.expr([1,2,3]).for_each(lambda row:[table_test_control.update({'foo':row}), table_test_control.update({'bar':row})]) */ suite.T().Log("About to run line #240: r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return []interface{}{table_test_control.Update(map[interface{}]interface{}{'foo': row, }), table_test_control.Update(map[interface{}]interface{}{'bar': row, })}})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return []interface{}{table_test_control.Update(map[interface{}]interface{}{"foo": row}), table_test_control.Update(map[interface{}]interface{}{"bar": row})} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #240") } { // control.yaml line #245 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':3}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 3} /* r.expr([1, 2, 3]).for_each( table_test_control2.insert({ 'id':r.row }) ) */ suite.T().Log("About to run line #245: r.Expr([]interface{}{1, 2, 3}).ForEach(table_test_control2.Insert(map[interface{}]interface{}{'id': r.Row, }))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(table_test_control2.Insert(map[interface{}]interface{}{"id": r.Row})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #245") } { // control.yaml line #249 /* err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries. Expected type ARRAY but found NUMBER.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries. Expected type ARRAY but found NUMBER.") /* r.expr([1, 2, 3]).for_each(1) */ suite.T().Log("About to run line #249: r.Expr([]interface{}{1, 2, 3}).ForEach(1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #249") } { // control.yaml line #252 /* err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries. Expected type ARRAY but found NUMBER.", [1, 1]) */ var expected_ Err = err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries. Expected type ARRAY but found NUMBER.") /* r.expr([1, 2, 3]).for_each(lambda x:x) */ suite.T().Log("About to run line #252: r.Expr([]interface{}{1, 2, 3}).ForEach(func(x r.Term) interface{} { return x})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(func(x r.Term) interface{} { return x }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #252") } { // control.yaml line #257 /* err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries. Expected type ARRAY but found NUMBER.", [1, 1]) */ var expected_ Err = err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries. Expected type ARRAY but found NUMBER.") /* r.expr([1, 2, 3]).for_each(r.row) */ suite.T().Log("About to run line #257: r.Expr([]interface{}{1, 2, 3}).ForEach(r.Row)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(r.Row), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #257") } { // control.yaml line #262 /* err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries.", [1, 1]) */ var expected_ Err = err("ReqlQueryLogicError", "FOR_EACH expects one or more basic write queries.") /* r.expr([1, 2, 3]).for_each(lambda row:table_test_control) */ suite.T().Log("About to run line #262: r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return table_test_control})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(func(row r.Term) interface{} { return table_test_control }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #262") } { // control.yaml line #271 /* ({'deleted':0.0,'replaced':0.0,'generated_keys':arrlen(1,uuid()),'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 1} /* r.expr(1).do(table_test_control.insert({'foo':r.row})) */ suite.T().Log("About to run line #271: r.Expr(1).Do(table_test_control.Insert(map[interface{}]interface{}{'foo': r.Row, }))") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(table_test_control.Insert(map[interface{}]interface{}{"foo": r.Row})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #271") } { // control.yaml line #275 /* ({'deleted':0.0,'replaced':0.0,'generated_keys':arrlen(1,uuid()),'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 1} /* r.expr([1, 2])[0].do(table_test_control.insert({'foo':r.row})) */ suite.T().Log("About to run line #275: r.Expr([]interface{}{1, 2}).AtIndex(0).Do(table_test_control.Insert(map[interface{}]interface{}{'foo': r.Row, }))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).AtIndex(0).Do(table_test_control.Insert(map[interface{}]interface{}{"foo": r.Row})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #275") } { // control.yaml line #280 /* err('ReqlCompileError', 'Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.', [0]) */ var expected_ Err = err("ReqlCompileError", "Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.") /* r.expr([1, 2]).map(table_test_control.insert({'foo':r.row})) */ suite.T().Log("About to run line #280: r.Expr([]interface{}{1, 2}).Map(table_test_control.Insert(map[interface{}]interface{}{'foo': r.Row, }))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Map(table_test_control.Insert(map[interface{}]interface{}{"foo": r.Row})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #280") } { // control.yaml line #284 /* err('ReqlCompileError', 'Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.', [0]) */ var expected_ Err = err("ReqlCompileError", "Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.") /* r.expr([1, 2]).map(r.db('test').table_create('table_create_failure')) */ suite.T().Log("About to run line #284: r.Expr([]interface{}{1, 2}).Map(r.DB('test').TableCreate('table_create_failure'))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Map(r.DB("db_control").TableCreate("table_create_failure")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #284") } { // control.yaml line #287 /* err('ReqlCompileError', 'Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.', [0]) */ var expected_ Err = err("ReqlCompileError", "Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.") /* r.expr([1, 2]).map(table_test_control.insert({'foo':r.row}).get_field('inserted')) */ suite.T().Log("About to run line #287: r.Expr([]interface{}{1, 2}).Map(table_test_control.Insert(map[interface{}]interface{}{'foo': r.Row, }).Field('inserted'))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Map(table_test_control.Insert(map[interface{}]interface{}{"foo": r.Row}).Field("inserted")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #287") } { // control.yaml line #291 /* err('ReqlCompileError', 'Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.', [0]) */ var expected_ Err = err("ReqlCompileError", "Cannot nest writes or meta ops in stream operations. Use FOR_EACH instead.") /* r.expr([1, 2]).map(table_test_control.insert({'foo':r.row}).get_field('inserted').add(5)) */ suite.T().Log("About to run line #291: r.Expr([]interface{}{1, 2}).Map(table_test_control.Insert(map[interface{}]interface{}{'foo': r.Row, }).Field('inserted').Add(5))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Map(table_test_control.Insert(map[interface{}]interface{}{"foo": r.Row}).Field("inserted").Add(5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #291") } { // control.yaml line #295 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.expr(1).do(r.db('test').table_create('table_create_success')) */ suite.T().Log("About to run line #295: r.Expr(1).Do(r.DB('test').TableCreate('table_create_success'))") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(r.DB("db_control").TableCreate("table_create_success")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #295") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_array_test.go000066400000000000000000000643571363464422500273720ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests conversion to and from the RQL array type func TestDatumArraySuite(t *testing.T) { suite.Run(t, new(DatumArraySuite)) } type DatumArraySuite struct { suite.Suite session *r.Session } func (suite *DatumArraySuite) SetupTest() { suite.T().Log("Setting up DatumArraySuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_darray").Exec(suite.session) err = r.DBCreate("db_darray").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_darray").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumArraySuite) TearDownSuite() { suite.T().Log("Tearing down DatumArraySuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_darray").Exec(suite.session) suite.session.Close() } } func (suite *DatumArraySuite) TestCases() { suite.T().Log("Running DatumArraySuite: Tests conversion to and from the RQL array type") { // datum/array.yaml line #6 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr([]) */ suite.T().Log("About to run line #6: r.Expr([]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // datum/array.yaml line #9 /* [1] */ var expected_ []interface{} = []interface{}{1} /* r.expr([1]) */ suite.T().Log("About to run line #9: r.Expr([]interface{}{1})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // datum/array.yaml line #14 /* [1,2,3,4,5] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4, 5} /* r.expr([1,2,3,4,5]) */ suite.T().Log("About to run line #14: r.Expr([]interface{}{1, 2, 3, 4, 5})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4, 5}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // datum/array.yaml line #19 /* 'ARRAY' */ var expected_ string = "ARRAY" /* r.expr([]).type_of() */ suite.T().Log("About to run line #19: r.Expr([]interface{}{}).TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // datum/array.yaml line #24 /* '[1,2]' */ var expected_ string = "[1,2]" /* r.expr([1, 2]).coerce_to('string') */ suite.T().Log("About to run line #24: r.Expr([]interface{}{1, 2}).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // datum/array.yaml line #25 /* '[1,2]' */ var expected_ string = "[1,2]" /* r.expr([1, 2]).coerce_to('STRING') */ suite.T().Log("About to run line #25: r.Expr([]interface{}{1, 2}).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // datum/array.yaml line #28 /* [1, 2] */ var expected_ []interface{} = []interface{}{1, 2} /* r.expr([1, 2]).coerce_to('array') */ suite.T().Log("About to run line #28: r.Expr([]interface{}{1, 2}).CoerceTo('array')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("array"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // datum/array.yaml line #31 /* err('ReqlQueryLogicError', 'Cannot coerce ARRAY to NUMBER.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot coerce ARRAY to NUMBER.") /* r.expr([1, 2]).coerce_to('number') */ suite.T().Log("About to run line #31: r.Expr([]interface{}{1, 2}).CoerceTo('number')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).CoerceTo("number"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // datum/array.yaml line #34 /* {'a':1,'b':2} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1, "b": 2} /* r.expr([['a', 1], ['b', 2]]).coerce_to('object') */ suite.T().Log("About to run line #34: r.Expr([]interface{}{[]interface{}{'a', 1}, []interface{}{'b', 2}}).CoerceTo('object')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{"a", 1}, []interface{}{"b", 2}}).CoerceTo("object"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // datum/array.yaml line #37 /* err('ReqlQueryLogicError', 'Expected array of size 2, but got size 0.') */ var expected_ Err = err("ReqlQueryLogicError", "Expected array of size 2, but got size 0.") /* r.expr([[]]).coerce_to('object') */ suite.T().Log("About to run line #37: r.Expr([]interface{}{[]interface{}{}}).CoerceTo('object')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{}}).CoerceTo("object"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // datum/array.yaml line #40 /* err('ReqlQueryLogicError', 'Expected array of size 2, but got size 3.') */ var expected_ Err = err("ReqlQueryLogicError", "Expected array of size 2, but got size 3.") /* r.expr([['1',2,3]]).coerce_to('object') */ suite.T().Log("About to run line #40: r.Expr([]interface{}{[]interface{}{'1', 2, 3}}).CoerceTo('object')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{"1", 2, 3}}).CoerceTo("object"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // datum/array.yaml line #44 /* [1] */ var expected_ []interface{} = []interface{}{1} /* r.expr([r.expr(1)]) */ suite.T().Log("About to run line #44: r.Expr([]interface{}{r.Expr(1)})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Expr(1)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // datum/array.yaml line #47 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,3,4]).insert_at(1, 2) */ suite.T().Log("About to run line #47: r.Expr([]interface{}{1, 3, 4}).InsertAt(1, 2)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 3, 4}).InsertAt(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // datum/array.yaml line #49 /* [1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.expr([2,3]).insert_at(0, 1) */ suite.T().Log("About to run line #49: r.Expr([]interface{}{2, 3}).InsertAt(0, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{2, 3}).InsertAt(0, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // datum/array.yaml line #51 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,2,3]).insert_at(-1, 4) */ suite.T().Log("About to run line #51: r.Expr([]interface{}{1, 2, 3}).InsertAt(-1, 4)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(-1, 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // datum/array.yaml line #53 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,2,3]).insert_at(3, 4) */ suite.T().Log("About to run line #53: r.Expr([]interface{}{1, 2, 3}).InsertAt(3, 4)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(3, 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // datum/array.yaml line #55 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* r.expr(3).do(lambda x: r.expr([1,2,3]).insert_at(x, 4)) */ suite.T().Log("About to run line #55: r.Expr(3).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).InsertAt(x, 4)})") runAndAssert(suite.Suite, expected_, r.Expr(3).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).InsertAt(x, 4) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // datum/array.yaml line #59 /* err('ReqlNonExistenceError', 'Index `4` out of bounds for array of size: `3`.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index `4` out of bounds for array of size: `3`.") /* r.expr([1,2,3]).insert_at(4, 5) */ suite.T().Log("About to run line #59: r.Expr([]interface{}{1, 2, 3}).InsertAt(4, 5)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(4, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #59") } { // datum/array.yaml line #61 /* err('ReqlNonExistenceError', 'Index out of bounds: -5', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -5") /* r.expr([1,2,3]).insert_at(-5, -1) */ suite.T().Log("About to run line #61: r.Expr([]interface{}{1, 2, 3}).InsertAt(-5, -1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(-5, -1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #61") } { // datum/array.yaml line #63 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") /* r.expr([1,2,3]).insert_at(1.5, 1) */ suite.T().Log("About to run line #63: r.Expr([]interface{}{1, 2, 3}).InsertAt(1.5, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(1.5, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } { // datum/array.yaml line #65 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* r.expr([1,2,3]).insert_at(null, 1) */ suite.T().Log("About to run line #65: r.Expr([]interface{}{1, 2, 3}).InsertAt(nil, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).InsertAt(nil, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // datum/array.yaml line #68 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,4]).splice_at(1, [2,3]) */ suite.T().Log("About to run line #68: r.Expr([]interface{}{1, 4}).SpliceAt(1, []interface{}{2, 3})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 4}).SpliceAt(1, []interface{}{2, 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #68") } { // datum/array.yaml line #70 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([3,4]).splice_at(0, [1,2]) */ suite.T().Log("About to run line #70: r.Expr([]interface{}{3, 4}).SpliceAt(0, []interface{}{1, 2})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{3, 4}).SpliceAt(0, []interface{}{1, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // datum/array.yaml line #72 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,2]).splice_at(2, [3,4]) */ suite.T().Log("About to run line #72: r.Expr([]interface{}{1, 2}).SpliceAt(2, []interface{}{3, 4})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(2, []interface{}{3, 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #72") } { // datum/array.yaml line #74 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,2]).splice_at(-1, [3,4]) */ suite.T().Log("About to run line #74: r.Expr([]interface{}{1, 2}).SpliceAt(-1, []interface{}{3, 4})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(-1, []interface{}{3, 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } { // datum/array.yaml line #76 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* r.expr(2).do(lambda x: r.expr([1,2]).splice_at(x, [3,4])) */ suite.T().Log("About to run line #76: r.Expr(2).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2}).SpliceAt(x, []interface{}{3, 4})})") runAndAssert(suite.Suite, expected_, r.Expr(2).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2}).SpliceAt(x, []interface{}{3, 4}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #76") } { // datum/array.yaml line #80 /* err('ReqlNonExistenceError', 'Index `3` out of bounds for array of size: `2`.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index `3` out of bounds for array of size: `2`.") /* r.expr([1,2]).splice_at(3, [3,4]) */ suite.T().Log("About to run line #80: r.Expr([]interface{}{1, 2}).SpliceAt(3, []interface{}{3, 4})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(3, []interface{}{3, 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #80") } { // datum/array.yaml line #82 /* err('ReqlNonExistenceError', 'Index out of bounds: -4', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -4") /* r.expr([1,2]).splice_at(-4, [3,4]) */ suite.T().Log("About to run line #82: r.Expr([]interface{}{1, 2}).SpliceAt(-4, []interface{}{3, 4})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).SpliceAt(-4, []interface{}{3, 4}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // datum/array.yaml line #84 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") /* r.expr([1,2,3]).splice_at(1.5, [1]) */ suite.T().Log("About to run line #84: r.Expr([]interface{}{1, 2, 3}).SpliceAt(1.5, []interface{}{1})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).SpliceAt(1.5, []interface{}{1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // datum/array.yaml line #86 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* r.expr([1,2,3]).splice_at(null, [1]) */ suite.T().Log("About to run line #86: r.Expr([]interface{}{1, 2, 3}).SpliceAt(nil, []interface{}{1})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).SpliceAt(nil, []interface{}{1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // datum/array.yaml line #88 /* err('ReqlQueryLogicError', 'Expected type ARRAY but found NUMBER.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.") /* r.expr([1,4]).splice_at(1, 2) */ suite.T().Log("About to run line #88: r.Expr([]interface{}{1, 4}).SpliceAt(1, 2)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 4}).SpliceAt(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // datum/array.yaml line #91 /* [2,3,4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* r.expr([1,2,3,4]).delete_at(0) */ suite.T().Log("About to run line #91: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(0)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // datum/array.yaml line #93 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* r.expr(0).do(lambda x: r.expr([1,2,3,4]).delete_at(x)) */ suite.T().Log("About to run line #93: r.Expr(0).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(x)})") runAndAssert(suite.Suite, expected_, r.Expr(0).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(x) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } { // datum/array.yaml line #97 /* [1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.expr([1,2,3,4]).delete_at(-1) */ suite.T().Log("About to run line #97: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #97") } { // datum/array.yaml line #99 /* [1,4] */ var expected_ []interface{} = []interface{}{1, 4} /* r.expr([1,2,3,4]).delete_at(1,3) */ suite.T().Log("About to run line #99: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, 3)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #99") } { // datum/array.yaml line #101 /* [1,2,3,4] */ var expected_ []interface{} = []interface{}{1, 2, 3, 4} /* r.expr([1,2,3,4]).delete_at(4,4) */ suite.T().Log("About to run line #101: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4, 4)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4, 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } { // datum/array.yaml line #103 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr([]).delete_at(0,0) */ suite.T().Log("About to run line #103: r.Expr([]interface{}{}).DeleteAt(0, 0)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).DeleteAt(0, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // datum/array.yaml line #105 /* [1,4] */ var expected_ []interface{} = []interface{}{1, 4} /* r.expr([1,2,3,4]).delete_at(1,-1) */ suite.T().Log("About to run line #105: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, -1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(1, -1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #105") } { // datum/array.yaml line #107 /* err('ReqlNonExistenceError', 'Index `4` out of bounds for array of size: `4`.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index `4` out of bounds for array of size: `4`.") /* r.expr([1,2,3,4]).delete_at(4) */ suite.T().Log("About to run line #107: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #107") } { // datum/array.yaml line #109 /* err('ReqlNonExistenceError', 'Index out of bounds: -5', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -5") /* r.expr([1,2,3,4]).delete_at(-5) */ suite.T().Log("About to run line #109: r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-5)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).DeleteAt(-5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // datum/array.yaml line #111 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") /* r.expr([1,2,3]).delete_at(1.5) */ suite.T().Log("About to run line #111: r.Expr([]interface{}{1, 2, 3}).DeleteAt(1.5)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).DeleteAt(1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // datum/array.yaml line #113 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* r.expr([1,2,3]).delete_at(null) */ suite.T().Log("About to run line #113: r.Expr([]interface{}{1, 2, 3}).DeleteAt(nil)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).DeleteAt(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #113") } { // datum/array.yaml line #116 /* [1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.expr([0,2,3]).change_at(0, 1) */ suite.T().Log("About to run line #116: r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #116") } { // datum/array.yaml line #118 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* r.expr(1).do(lambda x: r.expr([0,2,3]).change_at(0,x)) */ suite.T().Log("About to run line #118: r.Expr(1).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, x)})") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(func(x r.Term) interface{} { return r.Expr([]interface{}{0, 2, 3}).ChangeAt(0, x) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } { // datum/array.yaml line #122 /* [1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.expr([1,0,3]).change_at(1, 2) */ suite.T().Log("About to run line #122: r.Expr([]interface{}{1, 0, 3}).ChangeAt(1, 2)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 0, 3}).ChangeAt(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // datum/array.yaml line #124 /* [1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.expr([1,2,0]).change_at(2, 3) */ suite.T().Log("About to run line #124: r.Expr([]interface{}{1, 2, 0}).ChangeAt(2, 3)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 0}).ChangeAt(2, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #124") } { // datum/array.yaml line #126 /* err('ReqlNonExistenceError', 'Index `3` out of bounds for array of size: `3`.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index `3` out of bounds for array of size: `3`.") /* r.expr([1,2,3]).change_at(3, 4) */ suite.T().Log("About to run line #126: r.Expr([]interface{}{1, 2, 3}).ChangeAt(3, 4)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ChangeAt(3, 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #126") } { // datum/array.yaml line #128 /* err('ReqlNonExistenceError', 'Index out of bounds: -5', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Index out of bounds: -5") /* r.expr([1,2,3,4]).change_at(-5, 1) */ suite.T().Log("About to run line #128: r.Expr([]interface{}{1, 2, 3, 4}).ChangeAt(-5, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4}).ChangeAt(-5, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #128") } { // datum/array.yaml line #130 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") /* r.expr([1,2,3]).change_at(1.5, 1) */ suite.T().Log("About to run line #130: r.Expr([]interface{}{1, 2, 3}).ChangeAt(1.5, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ChangeAt(1.5, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #130") } { // datum/array.yaml line #132 /* err('ReqlNonExistenceError', 'Expected type NUMBER but found NULL.', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* r.expr([1,2,3]).change_at(null, 1) */ suite.T().Log("About to run line #132: r.Expr([]interface{}{1, 2, 3}).ChangeAt(nil, 1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ChangeAt(nil, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #132") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_binary_test.go000066400000000000000000001250201363464422500275210ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of converstion to and from the RQL binary type func TestDatumBinarySuite(t *testing.T) { suite.Run(t, new(DatumBinarySuite)) } type DatumBinarySuite struct { suite.Suite session *r.Session } func (suite *DatumBinarySuite) SetupTest() { suite.T().Log("Setting up DatumBinarySuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dbin").Exec(suite.session) err = r.DBCreate("db_dbin").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dbin").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumBinarySuite) TearDownSuite() { suite.T().Log("Tearing down DatumBinarySuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dbin").Exec(suite.session) suite.session.Close() } } func (suite *DatumBinarySuite) TestCases() { suite.T().Log("Running DatumBinarySuite: Tests of converstion to and from the RQL binary type") // datum/binary.yaml line #8 // s = b'' suite.T().Log("Possibly executing: var s []byte = []byte{}") s := []byte{} _ = s // Prevent any noused variable errors { // datum/binary.yaml line #10 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #10: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // datum/binary.yaml line #12 /* 0 */ var expected_ int = 0 /* r.binary(s).count() */ suite.T().Log("About to run line #12: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } // datum/binary.yaml line #17 // s = b'\x00' suite.T().Log("Possibly executing: var s []byte = []byte{0}") s = []byte{0} { // datum/binary.yaml line #19 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #19: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // datum/binary.yaml line #21 /* 1 */ var expected_ int = 1 /* r.binary(s).count() */ suite.T().Log("About to run line #21: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } // datum/binary.yaml line #26 // s = b'\x00\x42' suite.T().Log("Possibly executing: var s []byte = []byte{0,66}") s = []byte{0, 66} { // datum/binary.yaml line #28 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #28: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // datum/binary.yaml line #30 /* 2 */ var expected_ int = 2 /* r.binary(s).count() */ suite.T().Log("About to run line #30: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } // datum/binary.yaml line #35 // s = b'\x00\xfe\x7a' suite.T().Log("Possibly executing: var s []byte = []byte{0,254,122}") s = []byte{0, 254, 122} { // datum/binary.yaml line #37 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #37: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // datum/binary.yaml line #39 /* 3 */ var expected_ int = 3 /* r.binary(s).count() */ suite.T().Log("About to run line #39: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } // datum/binary.yaml line #44 // s = b'\xed\xfe\x00\xba' suite.T().Log("Possibly executing: var s []byte = []byte{237,254,0,186}") s = []byte{237, 254, 0, 186} { // datum/binary.yaml line #46 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #46: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // datum/binary.yaml line #48 /* 4 */ var expected_ int = 4 /* r.binary(s).count() */ suite.T().Log("About to run line #48: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #48") } // datum/binary.yaml line #53 // s = b'\x50\xf9\x00\x77\xf9' suite.T().Log("Possibly executing: var s []byte = []byte{80,249,0,119,249}") s = []byte{80, 249, 0, 119, 249} { // datum/binary.yaml line #55 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #55: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // datum/binary.yaml line #57 /* 5 */ var expected_ int = 5 /* r.binary(s).count() */ suite.T().Log("About to run line #57: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } // datum/binary.yaml line #62 // s = b'\x2f\xe3\xb5\x57\x00\x92' suite.T().Log("Possibly executing: var s []byte = []byte{47,227,181,87,0,146}") s = []byte{47, 227, 181, 87, 0, 146} { // datum/binary.yaml line #64 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #64: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #64") } { // datum/binary.yaml line #66 /* 6 */ var expected_ int = 6 /* r.binary(s).count() */ suite.T().Log("About to run line #66: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } // datum/binary.yaml line #71 // s = b'\xa9\x43\x54\xe9\x00\xf8\xfb' suite.T().Log("Possibly executing: var s []byte = []byte{169,67,84,233,0,248,251}") s = []byte{169, 67, 84, 233, 0, 248, 251} { // datum/binary.yaml line #73 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #73: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // datum/binary.yaml line #75 /* 7 */ var expected_ int = 7 /* r.binary(s).count() */ suite.T().Log("About to run line #75: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } // datum/binary.yaml line #80 // s = b'\x57\xbb\xe5\x82\x8b\xd3\x00\xf9' suite.T().Log("Possibly executing: var s []byte = []byte{87,187,229,130,139,211,0,249}") s = []byte{87, 187, 229, 130, 139, 211, 0, 249} { // datum/binary.yaml line #82 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #82: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // datum/binary.yaml line #84 /* 8 */ var expected_ int = 8 /* r.binary(s).count() */ suite.T().Log("About to run line #84: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } // datum/binary.yaml line #89 // s = b'\x44\x1b\x3e\x00\x13\x19\x29\x2a\xbf' suite.T().Log("Possibly executing: var s []byte = []byte{68,27,62,0,19,25,41,42,191}") s = []byte{68, 27, 62, 0, 19, 25, 41, 42, 191} { // datum/binary.yaml line #91 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #91: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // datum/binary.yaml line #93 /* 9 */ var expected_ int = 9 /* r.binary(s).count() */ suite.T().Log("About to run line #93: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } // datum/binary.yaml line #98 // s = b'\x8a\x1d\x09\x00\x5d\x60\x6b\x2e\x70\xd9' suite.T().Log("Possibly executing: var s []byte = []byte{138,29,9,0,93,96,107,46,112,217}") s = []byte{138, 29, 9, 0, 93, 96, 107, 46, 112, 217} { // datum/binary.yaml line #100 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #100: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // datum/binary.yaml line #102 /* 10 */ var expected_ int = 10 /* r.binary(s).count() */ suite.T().Log("About to run line #102: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } // datum/binary.yaml line #107 // s = b'\x00\xaf\x47\x4b\x38\x99\x14\x8d\x8f\x10\x51' suite.T().Log("Possibly executing: var s []byte = []byte{0,175,71,75,56,153,20,141,143,16,81}") s = []byte{0, 175, 71, 75, 56, 153, 20, 141, 143, 16, 81} { // datum/binary.yaml line #109 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #109: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // datum/binary.yaml line #111 /* 11 */ var expected_ int = 11 /* r.binary(s).count() */ suite.T().Log("About to run line #111: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } // datum/binary.yaml line #116 // s = b'\x45\x39\x00\xf7\xc2\x37\xfd\xe0\x38\x82\x40\xa9' suite.T().Log("Possibly executing: var s []byte = []byte{69,57,0,247,194,55,253,224,56,130,64,169}") s = []byte{69, 57, 0, 247, 194, 55, 253, 224, 56, 130, 64, 169} { // datum/binary.yaml line #118 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #118: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } { // datum/binary.yaml line #120 /* 12 */ var expected_ int = 12 /* r.binary(s).count() */ suite.T().Log("About to run line #120: r.Binary(s).Count()") runAndAssert(suite.Suite, expected_, r.Binary(s).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #120") } // datum/binary.yaml line #128 // a = b'\x00' suite.T().Log("Possibly executing: var a []byte = []byte{0}") a := []byte{0} _ = a // Prevent any noused variable errors // datum/binary.yaml line #132 // b = b'\x00\x01' suite.T().Log("Possibly executing: var b []byte = []byte{0,1}") b := []byte{0, 1} _ = b // Prevent any noused variable errors // datum/binary.yaml line #136 // c = b'\x01' suite.T().Log("Possibly executing: var c []byte = []byte{1}") c := []byte{1} _ = c // Prevent any noused variable errors // datum/binary.yaml line #140 // d = b'\x70\x22' suite.T().Log("Possibly executing: var d []byte = []byte{112,34}") d := []byte{112, 34} _ = d // Prevent any noused variable errors // datum/binary.yaml line #144 // e = b'\x80' suite.T().Log("Possibly executing: var e []byte = []byte{128}") e := []byte{128} _ = e // Prevent any noused variable errors // datum/binary.yaml line #148 // f = b'\xFE' suite.T().Log("Possibly executing: var f []byte = []byte{254}") f := []byte{254} _ = f // Prevent any noused variable errors { // datum/binary.yaml line #151 /* true */ var expected_ bool = true /* r.binary(a).eq(r.binary(a)) */ suite.T().Log("About to run line #151: r.Binary(a).Eq(r.Binary(a))") runAndAssert(suite.Suite, expected_, r.Binary(a).Eq(r.Binary(a)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #151") } { // datum/binary.yaml line #153 /* true */ var expected_ bool = true /* r.binary(a).le(r.binary(a)) */ suite.T().Log("About to run line #153: r.Binary(a).Le(r.Binary(a))") runAndAssert(suite.Suite, expected_, r.Binary(a).Le(r.Binary(a)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #153") } { // datum/binary.yaml line #155 /* true */ var expected_ bool = true /* r.binary(a).ge(r.binary(a)) */ suite.T().Log("About to run line #155: r.Binary(a).Ge(r.Binary(a))") runAndAssert(suite.Suite, expected_, r.Binary(a).Ge(r.Binary(a)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #155") } { // datum/binary.yaml line #157 /* false */ var expected_ bool = false /* r.binary(a).ne(r.binary(a)) */ suite.T().Log("About to run line #157: r.Binary(a).Ne(r.Binary(a))") runAndAssert(suite.Suite, expected_, r.Binary(a).Ne(r.Binary(a)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #157") } { // datum/binary.yaml line #159 /* false */ var expected_ bool = false /* r.binary(a).lt(r.binary(a)) */ suite.T().Log("About to run line #159: r.Binary(a).Lt(r.Binary(a))") runAndAssert(suite.Suite, expected_, r.Binary(a).Lt(r.Binary(a)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // datum/binary.yaml line #161 /* false */ var expected_ bool = false /* r.binary(a).gt(r.binary(a)) */ suite.T().Log("About to run line #161: r.Binary(a).Gt(r.Binary(a))") runAndAssert(suite.Suite, expected_, r.Binary(a).Gt(r.Binary(a)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #161") } { // datum/binary.yaml line #165 /* true */ var expected_ bool = true /* r.binary(a).ne(r.binary(b)) */ suite.T().Log("About to run line #165: r.Binary(a).Ne(r.Binary(b))") runAndAssert(suite.Suite, expected_, r.Binary(a).Ne(r.Binary(b)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #165") } { // datum/binary.yaml line #167 /* true */ var expected_ bool = true /* r.binary(a).lt(r.binary(b)) */ suite.T().Log("About to run line #167: r.Binary(a).Lt(r.Binary(b))") runAndAssert(suite.Suite, expected_, r.Binary(a).Lt(r.Binary(b)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #167") } { // datum/binary.yaml line #169 /* true */ var expected_ bool = true /* r.binary(a).le(r.binary(b)) */ suite.T().Log("About to run line #169: r.Binary(a).Le(r.Binary(b))") runAndAssert(suite.Suite, expected_, r.Binary(a).Le(r.Binary(b)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #169") } { // datum/binary.yaml line #171 /* false */ var expected_ bool = false /* r.binary(a).ge(r.binary(b)) */ suite.T().Log("About to run line #171: r.Binary(a).Ge(r.Binary(b))") runAndAssert(suite.Suite, expected_, r.Binary(a).Ge(r.Binary(b)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #171") } { // datum/binary.yaml line #173 /* false */ var expected_ bool = false /* r.binary(a).gt(r.binary(b)) */ suite.T().Log("About to run line #173: r.Binary(a).Gt(r.Binary(b))") runAndAssert(suite.Suite, expected_, r.Binary(a).Gt(r.Binary(b)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #173") } { // datum/binary.yaml line #175 /* false */ var expected_ bool = false /* r.binary(a).eq(r.binary(b)) */ suite.T().Log("About to run line #175: r.Binary(a).Eq(r.Binary(b))") runAndAssert(suite.Suite, expected_, r.Binary(a).Eq(r.Binary(b)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #175") } { // datum/binary.yaml line #179 /* true */ var expected_ bool = true /* r.binary(b).ne(r.binary(c)) */ suite.T().Log("About to run line #179: r.Binary(b).Ne(r.Binary(c))") runAndAssert(suite.Suite, expected_, r.Binary(b).Ne(r.Binary(c)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #179") } { // datum/binary.yaml line #181 /* true */ var expected_ bool = true /* r.binary(b).lt(r.binary(c)) */ suite.T().Log("About to run line #181: r.Binary(b).Lt(r.Binary(c))") runAndAssert(suite.Suite, expected_, r.Binary(b).Lt(r.Binary(c)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #181") } { // datum/binary.yaml line #183 /* true */ var expected_ bool = true /* r.binary(b).le(r.binary(c)) */ suite.T().Log("About to run line #183: r.Binary(b).Le(r.Binary(c))") runAndAssert(suite.Suite, expected_, r.Binary(b).Le(r.Binary(c)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #183") } { // datum/binary.yaml line #185 /* false */ var expected_ bool = false /* r.binary(b).ge(r.binary(c)) */ suite.T().Log("About to run line #185: r.Binary(b).Ge(r.Binary(c))") runAndAssert(suite.Suite, expected_, r.Binary(b).Ge(r.Binary(c)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #185") } { // datum/binary.yaml line #187 /* false */ var expected_ bool = false /* r.binary(b).gt(r.binary(c)) */ suite.T().Log("About to run line #187: r.Binary(b).Gt(r.Binary(c))") runAndAssert(suite.Suite, expected_, r.Binary(b).Gt(r.Binary(c)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #187") } { // datum/binary.yaml line #189 /* false */ var expected_ bool = false /* r.binary(b).eq(r.binary(c)) */ suite.T().Log("About to run line #189: r.Binary(b).Eq(r.Binary(c))") runAndAssert(suite.Suite, expected_, r.Binary(b).Eq(r.Binary(c)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #189") } { // datum/binary.yaml line #193 /* true */ var expected_ bool = true /* r.binary(c).ne(r.binary(d)) */ suite.T().Log("About to run line #193: r.Binary(c).Ne(r.Binary(d))") runAndAssert(suite.Suite, expected_, r.Binary(c).Ne(r.Binary(d)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #193") } { // datum/binary.yaml line #195 /* true */ var expected_ bool = true /* r.binary(c).lt(r.binary(d)) */ suite.T().Log("About to run line #195: r.Binary(c).Lt(r.Binary(d))") runAndAssert(suite.Suite, expected_, r.Binary(c).Lt(r.Binary(d)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #195") } { // datum/binary.yaml line #197 /* true */ var expected_ bool = true /* r.binary(c).le(r.binary(d)) */ suite.T().Log("About to run line #197: r.Binary(c).Le(r.Binary(d))") runAndAssert(suite.Suite, expected_, r.Binary(c).Le(r.Binary(d)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #197") } { // datum/binary.yaml line #199 /* false */ var expected_ bool = false /* r.binary(c).ge(r.binary(d)) */ suite.T().Log("About to run line #199: r.Binary(c).Ge(r.Binary(d))") runAndAssert(suite.Suite, expected_, r.Binary(c).Ge(r.Binary(d)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #199") } { // datum/binary.yaml line #201 /* false */ var expected_ bool = false /* r.binary(c).gt(r.binary(d)) */ suite.T().Log("About to run line #201: r.Binary(c).Gt(r.Binary(d))") runAndAssert(suite.Suite, expected_, r.Binary(c).Gt(r.Binary(d)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #201") } { // datum/binary.yaml line #203 /* false */ var expected_ bool = false /* r.binary(c).eq(r.binary(d)) */ suite.T().Log("About to run line #203: r.Binary(c).Eq(r.Binary(d))") runAndAssert(suite.Suite, expected_, r.Binary(c).Eq(r.Binary(d)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #203") } { // datum/binary.yaml line #207 /* true */ var expected_ bool = true /* r.binary(d).ne(r.binary(e)) */ suite.T().Log("About to run line #207: r.Binary(d).Ne(r.Binary(e))") runAndAssert(suite.Suite, expected_, r.Binary(d).Ne(r.Binary(e)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #207") } { // datum/binary.yaml line #209 /* true */ var expected_ bool = true /* r.binary(d).lt(r.binary(e)) */ suite.T().Log("About to run line #209: r.Binary(d).Lt(r.Binary(e))") runAndAssert(suite.Suite, expected_, r.Binary(d).Lt(r.Binary(e)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #209") } { // datum/binary.yaml line #211 /* true */ var expected_ bool = true /* r.binary(d).le(r.binary(e)) */ suite.T().Log("About to run line #211: r.Binary(d).Le(r.Binary(e))") runAndAssert(suite.Suite, expected_, r.Binary(d).Le(r.Binary(e)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #211") } { // datum/binary.yaml line #213 /* false */ var expected_ bool = false /* r.binary(d).ge(r.binary(e)) */ suite.T().Log("About to run line #213: r.Binary(d).Ge(r.Binary(e))") runAndAssert(suite.Suite, expected_, r.Binary(d).Ge(r.Binary(e)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #213") } { // datum/binary.yaml line #215 /* false */ var expected_ bool = false /* r.binary(d).gt(r.binary(e)) */ suite.T().Log("About to run line #215: r.Binary(d).Gt(r.Binary(e))") runAndAssert(suite.Suite, expected_, r.Binary(d).Gt(r.Binary(e)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #215") } { // datum/binary.yaml line #217 /* false */ var expected_ bool = false /* r.binary(d).eq(r.binary(e)) */ suite.T().Log("About to run line #217: r.Binary(d).Eq(r.Binary(e))") runAndAssert(suite.Suite, expected_, r.Binary(d).Eq(r.Binary(e)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #217") } { // datum/binary.yaml line #221 /* true */ var expected_ bool = true /* r.binary(e).ne(r.binary(f)) */ suite.T().Log("About to run line #221: r.Binary(e).Ne(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(e).Ne(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #221") } { // datum/binary.yaml line #223 /* true */ var expected_ bool = true /* r.binary(e).lt(r.binary(f)) */ suite.T().Log("About to run line #223: r.Binary(e).Lt(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(e).Lt(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #223") } { // datum/binary.yaml line #225 /* true */ var expected_ bool = true /* r.binary(e).le(r.binary(f)) */ suite.T().Log("About to run line #225: r.Binary(e).Le(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(e).Le(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #225") } { // datum/binary.yaml line #227 /* false */ var expected_ bool = false /* r.binary(e).ge(r.binary(f)) */ suite.T().Log("About to run line #227: r.Binary(e).Ge(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(e).Ge(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #227") } { // datum/binary.yaml line #229 /* false */ var expected_ bool = false /* r.binary(e).gt(r.binary(f)) */ suite.T().Log("About to run line #229: r.Binary(e).Gt(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(e).Gt(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #229") } { // datum/binary.yaml line #231 /* false */ var expected_ bool = false /* r.binary(e).eq(r.binary(f)) */ suite.T().Log("About to run line #231: r.Binary(e).Eq(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(e).Eq(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #231") } { // datum/binary.yaml line #235 /* true */ var expected_ bool = true /* r.binary(f).eq(r.binary(f)) */ suite.T().Log("About to run line #235: r.Binary(f).Eq(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(f).Eq(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #235") } { // datum/binary.yaml line #237 /* true */ var expected_ bool = true /* r.binary(f).le(r.binary(f)) */ suite.T().Log("About to run line #237: r.Binary(f).Le(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(f).Le(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #237") } { // datum/binary.yaml line #239 /* true */ var expected_ bool = true /* r.binary(f).ge(r.binary(f)) */ suite.T().Log("About to run line #239: r.Binary(f).Ge(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(f).Ge(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #239") } { // datum/binary.yaml line #241 /* false */ var expected_ bool = false /* r.binary(f).ne(r.binary(f)) */ suite.T().Log("About to run line #241: r.Binary(f).Ne(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(f).Ne(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #241") } { // datum/binary.yaml line #243 /* false */ var expected_ bool = false /* r.binary(f).lt(r.binary(f)) */ suite.T().Log("About to run line #243: r.Binary(f).Lt(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(f).Lt(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #243") } { // datum/binary.yaml line #245 /* false */ var expected_ bool = false /* r.binary(f).gt(r.binary(f)) */ suite.T().Log("About to run line #245: r.Binary(f).Gt(r.Binary(f))") runAndAssert(suite.Suite, expected_, r.Binary(f).Gt(r.Binary(f)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #245") } { // datum/binary.yaml line #269 /* 'foo' */ var expected_ string = "foo" /* r.binary(b'foo').coerce_to('string') */ suite.T().Log("About to run line #269: r.Binary([]byte{102,111,111}).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Binary([]byte{102, 111, 111}).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #269") } { // datum/binary.yaml line #284 /* b'foo' */ var expected_ []byte = []byte{102, 111, 111} /* r.expr('foo').coerce_to('binary') */ suite.T().Log("About to run line #284: r.Expr('foo').CoerceTo('binary')") runAndAssert(suite.Suite, expected_, r.Expr("foo").CoerceTo("binary"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #284") } { // datum/binary.yaml line #287 /* True */ var expected_ bool = true /* r.binary(a).coerce_to('bool') */ suite.T().Log("About to run line #287: r.Binary(a).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Binary(a).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #287") } { // datum/binary.yaml line #290 /* b'foo' */ var expected_ []byte = []byte{102, 111, 111} /* r.binary(b'foo').coerce_to('binary') */ suite.T().Log("About to run line #290: r.Binary([]byte{102,111,111}).CoerceTo('binary')") runAndAssert(suite.Suite, expected_, r.Binary([]byte{102, 111, 111}).CoerceTo("binary"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #290") } { // datum/binary.yaml line #294 /* b'ef' */ var expected_ []byte = []byte{101, 102} /* r.binary(b'abcdefg').slice(-3,-1) */ suite.T().Log("About to run line #294: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(-3, -1)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(-3, -1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #294") } { // datum/binary.yaml line #296 /* b'ab' */ var expected_ []byte = []byte{97, 98} /* r.binary(b'abcdefg').slice(0, 2) */ suite.T().Log("About to run line #296: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(0, 2)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(0, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #296") } { // datum/binary.yaml line #298 /* b'def' */ var expected_ []byte = []byte{100, 101, 102} /* r.binary(b'abcdefg').slice(3, -1) */ suite.T().Log("About to run line #298: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(3, -1)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(3, -1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #298") } { // datum/binary.yaml line #300 /* b'cde' */ var expected_ []byte = []byte{99, 100, 101} /* r.binary(b'abcdefg').slice(-5, 5) */ suite.T().Log("About to run line #300: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(-5, 5)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(-5, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #300") } { // datum/binary.yaml line #302 /* b'ab' */ var expected_ []byte = []byte{97, 98} /* r.binary(b'abcdefg').slice(-8, 2) */ suite.T().Log("About to run line #302: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(-8, 2)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(-8, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #302") } { // datum/binary.yaml line #304 /* b'fg' */ var expected_ []byte = []byte{102, 103} /* r.binary(b'abcdefg').slice(5, 7) */ suite.T().Log("About to run line #304: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(5, 7)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(5, 7), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #304") } { // datum/binary.yaml line #308 /* b'ab' */ var expected_ []byte = []byte{97, 98} /* r.binary(b'abcdefg').slice(-9, 2) */ suite.T().Log("About to run line #308: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(-9, 2)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(-9, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #308") } { // datum/binary.yaml line #312 /* b'fg' */ var expected_ []byte = []byte{102, 103} /* r.binary(b'abcdefg').slice(5, 9) */ suite.T().Log("About to run line #312: r.Binary([]byte{97,98,99,100,101,102,103}).Slice(5, 9)") runAndAssert(suite.Suite, expected_, r.Binary([]byte{97, 98, 99, 100, 101, 102, 103}).Slice(5, 9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #312") } { // datum/binary.yaml line #316 /* b */ var expected_ []byte = b /* r.binary(b) */ suite.T().Log("About to run line #316: r.Binary(b)") runAndAssert(suite.Suite, expected_, r.Binary(b), suite.session, r.RunOpts{ BinaryFormat: "native", GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #316") } { // datum/binary.yaml line #320 /* {'$reql_type$':'BINARY','data':'AAE='} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "BINARY", "data": "AAE="} /* r.binary(b) */ suite.T().Log("About to run line #320: r.Binary(b)") runAndAssert(suite.Suite, expected_, r.Binary(b), suite.session, r.RunOpts{ BinaryFormat: "raw", GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #320") } { // datum/binary.yaml line #326 /* b"data" */ var expected_ []byte = []byte{100, 97, 116, 97} /* r.binary(r.expr("data")) */ suite.T().Log("About to run line #326: r.Binary(r.Expr('data'))") runAndAssert(suite.Suite, expected_, r.Binary(r.Expr("data")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #326") } { // datum/binary.yaml line #332 /* err('ReqlQueryLogicError', 'Expected type STRING but found OBJECT.', []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found OBJECT.") /* r.binary(r.expr({})) */ suite.T().Log("About to run line #332: r.Binary(r.Expr(map[interface{}]interface{}{}))") runAndAssert(suite.Suite, expected_, r.Binary(r.Expr(map[interface{}]interface{}{})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #332") } { // datum/binary.yaml line #335 /* err('ReqlQueryLogicError', 'Expected type STRING but found ARRAY.', []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found ARRAY.") /* r.binary(r.expr([])) */ suite.T().Log("About to run line #335: r.Binary(r.Expr([]interface{}{}))") runAndAssert(suite.Suite, expected_, r.Binary(r.Expr([]interface{}{})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #335") } { // datum/binary.yaml line #341 /* err('ReqlQueryLogicError','Invalid binary pseudotype:'+' lacking `data` key.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid binary pseudotype:"+" lacking `data` key.") /* r.expr({'$reql_type$':'BINARY'}) */ suite.T().Log("About to run line #341: r.Expr(map[interface{}]interface{}{'$reql_type$': 'BINARY', })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"$reql_type$": "BINARY"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #341") } { // datum/binary.yaml line #346 /* err('ReqlQueryLogicError','Invalid base64 format, data found after padding character \'=\'.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid base64 format, data found after padding character '='.") /* r.expr({'$reql_type$':'BINARY','data':'ABCDEFGH==AA'}) */ suite.T().Log("About to run line #346: r.Expr(map[interface{}]interface{}{'$reql_type$': 'BINARY', 'data': 'ABCDEFGH==AA', })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"$reql_type$": "BINARY", "data": "ABCDEFGH==AA"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #346") } { // datum/binary.yaml line #348 /* err('ReqlQueryLogicError','Invalid base64 format, data found after padding character \'=\'.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid base64 format, data found after padding character '='.") /* r.expr({'$reql_type$':'BINARY','data':'ABCDEF==$'}) */ suite.T().Log("About to run line #348: r.Expr(map[interface{}]interface{}{'$reql_type$': 'BINARY', 'data': 'ABCDEF==$', })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"$reql_type$": "BINARY", "data": "ABCDEF==$"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #348") } { // datum/binary.yaml line #350 /* err('ReqlQueryLogicError','Invalid base64 character found:'+' \'^\'.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid base64 character found:"+" '^'.") /* r.expr({'$reql_type$':'BINARY','data':'A^CDEFGH'}) */ suite.T().Log("About to run line #350: r.Expr(map[interface{}]interface{}{'$reql_type$': 'BINARY', 'data': 'A^CDEFGH', })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"$reql_type$": "BINARY", "data": "A^CDEFGH"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #350") } { // datum/binary.yaml line #352 /* err('ReqlQueryLogicError','Invalid base64 length:'+' 1 character remaining, cannot decode a full byte.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid base64 length:"+" 1 character remaining, cannot decode a full byte.") /* r.expr({'$reql_type$':'BINARY','data':'ABCDE'}) */ suite.T().Log("About to run line #352: r.Expr(map[interface{}]interface{}{'$reql_type$': 'BINARY', 'data': 'ABCDE', })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"$reql_type$": "BINARY", "data": "ABCDE"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #352") } { // datum/binary.yaml line #356 /* err('ReqlQueryLogicError','Cannot coerce BINARY to ARRAY.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot coerce BINARY to ARRAY.") /* r.binary(a).coerce_to('array') */ suite.T().Log("About to run line #356: r.Binary(a).CoerceTo('array')") runAndAssert(suite.Suite, expected_, r.Binary(a).CoerceTo("array"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #356") } { // datum/binary.yaml line #358 /* err('ReqlQueryLogicError','Cannot coerce BINARY to OBJECT.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot coerce BINARY to OBJECT.") /* r.binary(a).coerce_to('object') */ suite.T().Log("About to run line #358: r.Binary(a).CoerceTo('object')") runAndAssert(suite.Suite, expected_, r.Binary(a).CoerceTo("object"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #358") } { // datum/binary.yaml line #360 /* err('ReqlQueryLogicError','Cannot coerce BINARY to NUMBER.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot coerce BINARY to NUMBER.") /* r.binary(a).coerce_to('number') */ suite.T().Log("About to run line #360: r.Binary(a).CoerceTo('number')") runAndAssert(suite.Suite, expected_, r.Binary(a).CoerceTo("number"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #360") } { // datum/binary.yaml line #362 /* err('ReqlQueryLogicError','Cannot coerce BINARY to NULL.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot coerce BINARY to NULL.") /* r.binary(a).coerce_to('nu'+'ll') */ suite.T().Log("About to run line #362: r.Binary(a).CoerceTo(r.Add('nu', 'll'))") runAndAssert(suite.Suite, expected_, r.Binary(a).CoerceTo(r.Add("nu", "ll")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #362") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_bool_test.go000066400000000000000000000137521363464422500272000ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of conversion to and from the RQL bool type func TestDatumBoolSuite(t *testing.T) { suite.Run(t, new(DatumBoolSuite)) } type DatumBoolSuite struct { suite.Suite session *r.Session } func (suite *DatumBoolSuite) SetupTest() { suite.T().Log("Setting up DatumBoolSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dbool").Exec(suite.session) err = r.DBCreate("db_dbool").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dbool").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumBoolSuite) TearDownSuite() { suite.T().Log("Tearing down DatumBoolSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dbool").Exec(suite.session) suite.session.Close() } } func (suite *DatumBoolSuite) TestCases() { suite.T().Log("Running DatumBoolSuite: Tests of conversion to and from the RQL bool type") { // datum/bool.yaml line #3 /* true */ var expected_ bool = true /* r.expr(True) */ suite.T().Log("About to run line #3: r.Expr(true)") runAndAssert(suite.Suite, expected_, r.Expr(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #3") } { // datum/bool.yaml line #10 /* false */ var expected_ bool = false /* r.expr(False) */ suite.T().Log("About to run line #10: r.Expr(false)") runAndAssert(suite.Suite, expected_, r.Expr(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // datum/bool.yaml line #17 /* 'BOOL' */ var expected_ string = "BOOL" /* r.expr(False).type_of() */ suite.T().Log("About to run line #17: r.Expr(false).TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr(false).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } { // datum/bool.yaml line #21 /* 'true' */ var expected_ string = "true" /* r.expr(True).coerce_to('string') */ suite.T().Log("About to run line #21: r.Expr(true).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr(true).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // datum/bool.yaml line #24 /* True */ var expected_ bool = true /* r.expr(True).coerce_to('bool') */ suite.T().Log("About to run line #24: r.Expr(true).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr(true).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // datum/bool.yaml line #27 /* False */ var expected_ bool = false /* r.expr(False).coerce_to('bool') */ suite.T().Log("About to run line #27: r.Expr(false).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr(false).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // datum/bool.yaml line #30 /* False */ var expected_ bool = false /* r.expr(null).coerce_to('bool') */ suite.T().Log("About to run line #30: r.Expr(nil).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // datum/bool.yaml line #33 /* True */ var expected_ bool = true /* r.expr(0).coerce_to('bool') */ suite.T().Log("About to run line #33: r.Expr(0).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr(0).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // datum/bool.yaml line #36 /* True */ var expected_ bool = true /* r.expr('false').coerce_to('bool') */ suite.T().Log("About to run line #36: r.Expr('false').CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr("false").CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // datum/bool.yaml line #39 /* True */ var expected_ bool = true /* r.expr('foo').coerce_to('bool') */ suite.T().Log("About to run line #39: r.Expr('foo').CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr("foo").CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // datum/bool.yaml line #42 /* True */ var expected_ bool = true /* r.expr([]).coerce_to('bool') */ suite.T().Log("About to run line #42: r.Expr([]interface{}{}).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // datum/bool.yaml line #45 /* True */ var expected_ bool = true /* r.expr({}).coerce_to('bool') */ suite.T().Log("About to run line #45: r.Expr(map[interface{}]interface{}{}).CoerceTo('bool')") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}).CoerceTo("bool"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #45") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_null_test.go000066400000000000000000000056451363464422500272210ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of conversion to and from the RQL null type func TestDatumNullSuite(t *testing.T) { suite.Run(t, new(DatumNullSuite)) } type DatumNullSuite struct { suite.Suite session *r.Session } func (suite *DatumNullSuite) SetupTest() { suite.T().Log("Setting up DatumNullSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dnull").Exec(suite.session) err = r.DBCreate("db_dnull").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dnull").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumNullSuite) TearDownSuite() { suite.T().Log("Tearing down DatumNullSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dnull").Exec(suite.session) suite.session.Close() } } func (suite *DatumNullSuite) TestCases() { suite.T().Log("Running DatumNullSuite: Tests of conversion to and from the RQL null type") { // datum/null.yaml line #6 /* (null) */ var expected_ interface{} = nil /* r.expr(null) */ suite.T().Log("About to run line #6: r.Expr(nil)") runAndAssert(suite.Suite, expected_, r.Expr(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // datum/null.yaml line #9 /* 'NULL' */ var expected_ string = "NULL" /* r.expr(null).type_of() */ suite.T().Log("About to run line #9: r.Expr(nil).TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr(nil).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // datum/null.yaml line #14 /* 'null' */ var expected_ string = "null" /* r.expr(null).coerce_to('string') */ suite.T().Log("About to run line #14: r.Expr(nil).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // datum/null.yaml line #17 /* null */ var expected_ interface{} = nil /* r.expr(null).coerce_to('null') */ suite.T().Log("About to run line #17: r.Expr(nil).CoerceTo('null')") runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("null"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_number_test.go000066400000000000000000000172361363464422500275360ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of conversion to and from the RQL number type func TestDatumNumberSuite(t *testing.T) { suite.Run(t, new(DatumNumberSuite)) } type DatumNumberSuite struct { suite.Suite session *r.Session } func (suite *DatumNumberSuite) SetupTest() { suite.T().Log("Setting up DatumNumberSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dnum").Exec(suite.session) err = r.DBCreate("db_dnum").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dnum").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumNumberSuite) TearDownSuite() { suite.T().Log("Tearing down DatumNumberSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dnum").Exec(suite.session) suite.session.Close() } } func (suite *DatumNumberSuite) TestCases() { suite.T().Log("Running DatumNumberSuite: Tests of conversion to and from the RQL number type") { // datum/number.yaml line #6 /* 1 */ var expected_ int = 1 /* r.expr(1) */ suite.T().Log("About to run line #6: r.Expr(1)") runAndAssert(suite.Suite, expected_, r.Expr(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // datum/number.yaml line #15 /* -1 */ var expected_ int = -1 /* r.expr(-1) */ suite.T().Log("About to run line #15: r.Expr(-1)") runAndAssert(suite.Suite, expected_, r.Expr(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // datum/number.yaml line #24 /* 0 */ var expected_ int = 0 /* r.expr(0) */ suite.T().Log("About to run line #24: r.Expr(0)") runAndAssert(suite.Suite, expected_, r.Expr(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // datum/number.yaml line #35 /* 1.0 */ var expected_ float64 = 1.0 /* r.expr(1.0) */ suite.T().Log("About to run line #35: r.Expr(1.0)") runAndAssert(suite.Suite, expected_, r.Expr(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // datum/number.yaml line #44 /* 1.5 */ var expected_ float64 = 1.5 /* r.expr(1.5) */ suite.T().Log("About to run line #44: r.Expr(1.5)") runAndAssert(suite.Suite, expected_, r.Expr(1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // datum/number.yaml line #53 /* -0.5 */ var expected_ float64 = -0.5 /* r.expr(-0.5) */ suite.T().Log("About to run line #53: r.Expr(-0.5)") runAndAssert(suite.Suite, expected_, r.Expr(-0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // datum/number.yaml line #62 /* 67498.89278 */ var expected_ float64 = 67498.89278 /* r.expr(67498.89278) */ suite.T().Log("About to run line #62: r.Expr(67498.89278)") runAndAssert(suite.Suite, expected_, r.Expr(67498.89278), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // datum/number.yaml line #73 /* 1234567890 */ var expected_ int = 1234567890 /* r.expr(1234567890) */ suite.T().Log("About to run line #73: r.Expr(1234567890)") runAndAssert(suite.Suite, expected_, r.Expr(1234567890), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // datum/number.yaml line #83 /* -73850380122423 */ var expected_ int = -73850380122423 /* r.expr(-73850380122423) */ suite.T().Log("About to run line #83: r.Expr(-73850380122423)") runAndAssert(suite.Suite, expected_, r.Expr(-73850380122423), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // datum/number.yaml line #95 /* float(1234567890123456789012345678901234567890) */ var expected_ float64 = float64(1234567890123456789012345678901234567890.0) /* r.expr(1234567890123456789012345678901234567890) */ suite.T().Log("About to run line #95: r.Expr(1234567890123456789012345678901234567890.0)") runAndAssert(suite.Suite, expected_, r.Expr(1234567890123456789012345678901234567890.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #95") } { // datum/number.yaml line #100 /* 123.4567890123456789012345678901234567890 */ var expected_ float64 = 123.45678901234568 /* r.expr(123.4567890123456789012345678901234567890) */ suite.T().Log("About to run line #100: r.Expr(123.45678901234568)") runAndAssert(suite.Suite, expected_, r.Expr(123.45678901234568), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // datum/number.yaml line #103 /* 'NUMBER' */ var expected_ string = "NUMBER" /* r.expr(1).type_of() */ suite.T().Log("About to run line #103: r.Expr(1).TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr(1).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // datum/number.yaml line #107 /* '1' */ var expected_ string = "1" /* r.expr(1).coerce_to('string') */ suite.T().Log("About to run line #107: r.Expr(1).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr(1).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #107") } { // datum/number.yaml line #110 /* 1 */ var expected_ int = 1 /* r.expr(1).coerce_to('number') */ suite.T().Log("About to run line #110: r.Expr(1).CoerceTo('number')") runAndAssert(suite.Suite, expected_, r.Expr(1).CoerceTo("number"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // datum/number.yaml line #115 /* int_cmp(1) */ var expected_ int = int_cmp(1) /* r.expr(1.0) */ suite.T().Log("About to run line #115: r.Expr(1.0)") runAndAssert(suite.Suite, expected_, r.Expr(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #115") } { // datum/number.yaml line #119 /* int_cmp(45) */ var expected_ int = int_cmp(45) /* r.expr(45) */ suite.T().Log("About to run line #119: r.Expr(45)") runAndAssert(suite.Suite, expected_, r.Expr(45), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #119") } { // datum/number.yaml line #123 /* float_cmp(1.2) */ var expected_ float64 = float_cmp(1.2) /* r.expr(1.2) */ suite.T().Log("About to run line #123: r.Expr(1.2)") runAndAssert(suite.Suite, expected_, r.Expr(1.2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_object_test.go000066400000000000000000000224531363464422500275110ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests conversion to and from the RQL object type func TestDatumObjectSuite(t *testing.T) { suite.Run(t, new(DatumObjectSuite)) } type DatumObjectSuite struct { suite.Suite session *r.Session } func (suite *DatumObjectSuite) SetupTest() { suite.T().Log("Setting up DatumObjectSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dobj").Exec(suite.session) err = r.DBCreate("db_dobj").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dobj").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumObjectSuite) TearDownSuite() { suite.T().Log("Tearing down DatumObjectSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dobj").Exec(suite.session) suite.session.Close() } } func (suite *DatumObjectSuite) TestCases() { suite.T().Log("Running DatumObjectSuite: Tests conversion to and from the RQL object type") { // datum/object.yaml line #6 /* {} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{} /* r.expr({}) */ suite.T().Log("About to run line #6: r.Expr(map[interface{}]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // datum/object.yaml line #11 /* {'a':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1} /* r.expr({'a':1}) */ suite.T().Log("About to run line #11: r.Expr(map[interface{}]interface{}{'a': 1, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // datum/object.yaml line #16 /* {'a':1, 'b':'two', 'c':True} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1, "b": "two", "c": true} /* r.expr({'a':1, 'b':'two', 'c':True}) */ suite.T().Log("About to run line #16: r.Expr(map[interface{}]interface{}{'a': 1, 'b': 'two', 'c': true, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1, "b": "two", "c": true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // datum/object.yaml line #20 /* {'a':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1} /* r.expr({'a':r.expr(1)}) */ suite.T().Log("About to run line #20: r.Expr(map[interface{}]interface{}{'a': r.Expr(1), })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": r.Expr(1)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // datum/object.yaml line #23 /* {'a':{'b':[{'c':2}, 'a', 4]}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": map[interface{}]interface{}{"b": []interface{}{map[interface{}]interface{}{"c": 2}, "a", 4}}} /* r.expr({'a':{'b':[{'c':2}, 'a', 4]}}) */ suite.T().Log("About to run line #23: r.Expr(map[interface{}]interface{}{'a': map[interface{}]interface{}{'b': []interface{}{map[interface{}]interface{}{'c': 2, }, 'a', 4}, }, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": map[interface{}]interface{}{"b": []interface{}{map[interface{}]interface{}{"c": 2}, "a", 4}}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // datum/object.yaml line #26 /* 'OBJECT' */ var expected_ string = "OBJECT" /* r.expr({'a':1}).type_of() */ suite.T().Log("About to run line #26: r.Expr(map[interface{}]interface{}{'a': 1, }).TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // datum/object.yaml line #30 /* '{"a":1}' */ var expected_ string = "{\"a\":1}" /* r.expr({'a':1}).coerce_to('string') */ suite.T().Log("About to run line #30: r.Expr(map[interface{}]interface{}{'a': 1, }).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // datum/object.yaml line #34 /* {'a':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1} /* r.expr({'a':1}).coerce_to('object') */ suite.T().Log("About to run line #34: r.Expr(map[interface{}]interface{}{'a': 1, }).CoerceTo('object')") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}).CoerceTo("object"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // datum/object.yaml line #37 /* [['a',1]] */ var expected_ []interface{} = []interface{}{[]interface{}{"a", 1}} /* r.expr({'a':1}).coerce_to('array') */ suite.T().Log("About to run line #37: r.Expr(map[interface{}]interface{}{'a': 1, }).CoerceTo('array')") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}).CoerceTo("array"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // datum/object.yaml line #66 /* {} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{} /* r.object() */ suite.T().Log("About to run line #66: r.Object()") runAndAssert(suite.Suite, expected_, r.Object(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } { // datum/object.yaml line #69 /* {'a':1,'b':2} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 1, "b": 2} /* r.object('a', 1, 'b', 2) */ suite.T().Log("About to run line #69: r.Object('a', 1, 'b', 2)") runAndAssert(suite.Suite, expected_, r.Object("a", 1, "b", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } { // datum/object.yaml line #72 /* {'cd':3} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"cd": 3} /* r.object('c'+'d', 3) */ suite.T().Log("About to run line #72: r.Object(r.Add('c', 'd'), 3)") runAndAssert(suite.Suite, expected_, r.Object(r.Add("c", "d"), 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #72") } { // datum/object.yaml line #75 /* err("ReqlQueryLogicError", "OBJECT expects an even number of arguments (but found 3).", []) */ var expected_ Err = err("ReqlQueryLogicError", "OBJECT expects an even number of arguments (but found 3).") /* r.object('o','d','d') */ suite.T().Log("About to run line #75: r.Object('o', 'd', 'd')") runAndAssert(suite.Suite, expected_, r.Object("o", "d", "d"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } { // datum/object.yaml line #78 /* err("ReqlQueryLogicError","Expected type STRING but found NUMBER.",[]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* r.object(1, 1) */ suite.T().Log("About to run line #78: r.Object(1, 1)") runAndAssert(suite.Suite, expected_, r.Object(1, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #78") } { // datum/object.yaml line #81 /* err("ReqlQueryLogicError","Duplicate key \"e\" in object. (got 4 and 5 as values)",[]) */ var expected_ Err = err("ReqlQueryLogicError", "Duplicate key \"e\" in object. (got 4 and 5 as values)") /* r.object('e', 4, 'e', 5) */ suite.T().Log("About to run line #81: r.Object('e', 4, 'e', 5)") runAndAssert(suite.Suite, expected_, r.Object("e", 4, "e", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #81") } { // datum/object.yaml line #84 /* err("ReqlQueryLogicError","Expected type DATUM but found DATABASE:",[]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type DATUM but found DATABASE:") /* r.object('g', r.db('test')) */ suite.T().Log("About to run line #84: r.Object('g', r.DB('test'))") runAndAssert(suite.Suite, expected_, r.Object("g", r.DB("db_dobj")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_string_test.go000066400000000000000000001546411363464422500275560ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of converstion to and from the RQL string type func TestDatumStringSuite(t *testing.T) { suite.Run(t, new(DatumStringSuite)) } type DatumStringSuite struct { suite.Suite session *r.Session } func (suite *DatumStringSuite) SetupTest() { suite.T().Log("Setting up DatumStringSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dstr").Exec(suite.session) err = r.DBCreate("db_dstr").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dstr").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumStringSuite) TearDownSuite() { suite.T().Log("Tearing down DatumStringSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dstr").Exec(suite.session) suite.session.Close() } } func (suite *DatumStringSuite) TestCases() { suite.T().Log("Running DatumStringSuite: Tests of converstion to and from the RQL string type") // datum/string.yaml line #7 // japanese_hello = u'こんにちは' suite.T().Log("Possibly executing: var japanese_hello string = 'こんにちは'") japanese_hello := "こんにちは" _ = japanese_hello // Prevent any noused variable errors { // datum/string.yaml line #16 /* "str" */ var expected_ string = "str" /* r.expr('str') */ suite.T().Log("About to run line #16: r.Expr('str')") runAndAssert(suite.Suite, expected_, r.Expr("str"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // datum/string.yaml line #21 /* "str" */ var expected_ string = "str" /* r.expr("str") */ suite.T().Log("About to run line #21: r.Expr('str')") runAndAssert(suite.Suite, expected_, r.Expr("str"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // datum/string.yaml line #28 /* 'str' */ var expected_ string = "str" /* r.expr(u'str') */ suite.T().Log("About to run line #28: r.Expr('str')") runAndAssert(suite.Suite, expected_, r.Expr("str"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // datum/string.yaml line #35 /* u'こんにちは' */ var expected_ string = "こんにちは" /* r.expr(japanese_hello) */ suite.T().Log("About to run line #35: r.Expr(japanese_hello)") runAndAssert(suite.Suite, expected_, r.Expr(japanese_hello), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // datum/string.yaml line #43 /* 'STRING' */ var expected_ string = "STRING" /* r.expr('foo').type_of() */ suite.T().Log("About to run line #43: r.Expr('foo').TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr("foo").TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // datum/string.yaml line #47 /* 'foo' */ var expected_ string = "foo" /* r.expr('foo').coerce_to('string') */ suite.T().Log("About to run line #47: r.Expr('foo').CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr("foo").CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // datum/string.yaml line #49 /* -1.2 */ var expected_ float64 = -1.2 /* r.expr('-1.2').coerce_to('NUMBER') */ suite.T().Log("About to run line #49: r.Expr('-1.2').CoerceTo('NUMBER')") runAndAssert(suite.Suite, expected_, r.Expr("-1.2").CoerceTo("NUMBER"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // datum/string.yaml line #51 /* err("ReqlQueryLogicError", "Could not coerce `--1.2` to NUMBER.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Could not coerce `--1.2` to NUMBER.") /* r.expr('--1.2').coerce_to('NUMBER') */ suite.T().Log("About to run line #51: r.Expr('--1.2').CoerceTo('NUMBER')") runAndAssert(suite.Suite, expected_, r.Expr("--1.2").CoerceTo("NUMBER"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // datum/string.yaml line #53 /* err("ReqlQueryLogicError", "Could not coerce `-1.2-` to NUMBER.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Could not coerce `-1.2-` to NUMBER.") /* r.expr('-1.2-').coerce_to('NUMBER') */ suite.T().Log("About to run line #53: r.Expr('-1.2-').CoerceTo('NUMBER')") runAndAssert(suite.Suite, expected_, r.Expr("-1.2-").CoerceTo("NUMBER"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // datum/string.yaml line #55 /* 10 */ var expected_ int = 10 /* r.expr('0xa').coerce_to('NUMBER') */ suite.T().Log("About to run line #55: r.Expr('0xa').CoerceTo('NUMBER')") runAndAssert(suite.Suite, expected_, r.Expr("0xa").CoerceTo("NUMBER"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // datum/string.yaml line #57 /* err("ReqlQueryLogicError", "Non-finite number: inf", []) */ var expected_ Err = err("ReqlQueryLogicError", "Non-finite number: inf") /* r.expr('inf').coerce_to('NUMBER') */ suite.T().Log("About to run line #57: r.Expr('inf').CoerceTo('NUMBER')") runAndAssert(suite.Suite, expected_, r.Expr("inf").CoerceTo("NUMBER"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // datum/string.yaml line #61 /* 13 */ var expected_ int = 13 /* r.expr('hello, world!').count() */ suite.T().Log("About to run line #61: r.Expr('hello, world!').Count()") runAndAssert(suite.Suite, expected_, r.Expr("hello, world!").Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #61") } { // datum/string.yaml line #63 /* 5 */ var expected_ int = 5 /* r.expr(japanese_hello).count() */ suite.T().Log("About to run line #63: r.Expr(japanese_hello).Count()") runAndAssert(suite.Suite, expected_, r.Expr(japanese_hello).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } { // datum/string.yaml line #67 /* 'ello' */ var expected_ string = "ello" /* r.expr('hello').slice(1) */ suite.T().Log("About to run line #67: r.Expr('hello').Slice(1)") runAndAssert(suite.Suite, expected_, r.Expr("hello").Slice(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #67") } { // datum/string.yaml line #69 /* 'o' */ var expected_ string = "o" /* r.expr('hello').slice(-1) */ suite.T().Log("About to run line #69: r.Expr('hello').Slice(-1)") runAndAssert(suite.Suite, expected_, r.Expr("hello").Slice(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } { // datum/string.yaml line #71 /* 'el' */ var expected_ string = "el" /* r.expr('hello').slice(-4,3) */ suite.T().Log("About to run line #71: r.Expr('hello').Slice(-4, 3)") runAndAssert(suite.Suite, expected_, r.Expr("hello").Slice(-4, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // datum/string.yaml line #73 /* 'hello' */ var expected_ string = "hello" /* r.expr('hello').slice(-99) */ suite.T().Log("About to run line #73: r.Expr('hello').Slice(-99)") runAndAssert(suite.Suite, expected_, r.Expr("hello").Slice(-99), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // datum/string.yaml line #75 /* 'hello' */ var expected_ string = "hello" /* r.expr('hello').slice(0) */ suite.T().Log("About to run line #75: r.Expr('hello').Slice(0)") runAndAssert(suite.Suite, expected_, r.Expr("hello").Slice(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } { // datum/string.yaml line #77 /* u'んにちは' */ var expected_ string = "んにちは" /* r.expr(japanese_hello).slice(1) */ suite.T().Log("About to run line #77: r.Expr(japanese_hello).Slice(1)") runAndAssert(suite.Suite, expected_, r.Expr(japanese_hello).Slice(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #77") } { // datum/string.yaml line #84 /* u'ん' */ var expected_ string = "ん" /* r.expr(japanese_hello).slice(1,2) */ suite.T().Log("About to run line #84: r.Expr(japanese_hello).Slice(1, 2)") runAndAssert(suite.Suite, expected_, r.Expr(japanese_hello).Slice(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // datum/string.yaml line #91 /* u'にちは' */ var expected_ string = "にちは" /* r.expr(japanese_hello).slice(-3) */ suite.T().Log("About to run line #91: r.Expr(japanese_hello).Slice(-3)") runAndAssert(suite.Suite, expected_, r.Expr(japanese_hello).Slice(-3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // datum/string.yaml line #100 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr('').split() */ suite.T().Log("About to run line #100: r.Expr('').Split()") runAndAssert(suite.Suite, expected_, r.Expr("").Split(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // datum/string.yaml line #102 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr('').split(null) */ suite.T().Log("About to run line #102: r.Expr('').Split(nil)") runAndAssert(suite.Suite, expected_, r.Expr("").Split(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } { // datum/string.yaml line #104 /* [''] */ var expected_ []interface{} = []interface{}{""} /* r.expr('').split(' ') */ suite.T().Log("About to run line #104: r.Expr('').Split(' ')") runAndAssert(suite.Suite, expected_, r.Expr("").Split(" "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #104") } { // datum/string.yaml line #106 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr('').split('') */ suite.T().Log("About to run line #106: r.Expr('').Split('')") runAndAssert(suite.Suite, expected_, r.Expr("").Split(""), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } { // datum/string.yaml line #108 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr('').split(null, 5) */ suite.T().Log("About to run line #108: r.Expr('').Split(nil, 5)") runAndAssert(suite.Suite, expected_, r.Expr("").Split(nil, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // datum/string.yaml line #110 /* [''] */ var expected_ []interface{} = []interface{}{""} /* r.expr('').split(' ', 5) */ suite.T().Log("About to run line #110: r.Expr('').Split(' ', 5)") runAndAssert(suite.Suite, expected_, r.Expr("").Split(" ", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // datum/string.yaml line #112 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr('').split('', 5) */ suite.T().Log("About to run line #112: r.Expr('').Split('', 5)") runAndAssert(suite.Suite, expected_, r.Expr("").Split("", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #112") } { // datum/string.yaml line #115 /* ['aaaa', 'bbbb', 'cccc'] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc"} /* r.expr('aaaa bbbb cccc ').split() */ suite.T().Log("About to run line #115: r.Expr('aaaa bbbb cccc ').Split()") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #115") } { // datum/string.yaml line #117 /* ['aaaa', 'bbbb', 'cccc'] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc"} /* r.expr('aaaa bbbb cccc ').split(null) */ suite.T().Log("About to run line #117: r.Expr('aaaa bbbb cccc ').Split(nil)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #117") } { // datum/string.yaml line #119 /* ['aaaa', 'bbbb', '', 'cccc', ''] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "", "cccc", ""} /* r.expr('aaaa bbbb cccc ').split(' ') */ suite.T().Log("About to run line #119: r.Expr('aaaa bbbb cccc ').Split(' ')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #119") } { // datum/string.yaml line #121 /* ['a', 'a', 'a', 'a', ' ', 'b', 'b', 'b', 'b', ' ', ' ', 'c', 'c', 'c', 'c', ' '] */ var expected_ []interface{} = []interface{}{"a", "a", "a", "a", " ", "b", "b", "b", "b", " ", " ", "c", "c", "c", "c", " "} /* r.expr('aaaa bbbb cccc ').split('') */ suite.T().Log("About to run line #121: r.Expr('aaaa bbbb cccc ').Split('')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(""), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #121") } { // datum/string.yaml line #123 /* ['aaaa ', '', '', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", "", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('b') */ suite.T().Log("About to run line #123: r.Expr('aaaa bbbb cccc ').Split('b')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } { // datum/string.yaml line #125 /* ['aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('bb') */ suite.T().Log("About to run line #125: r.Expr('aaaa bbbb cccc ').Split('bb')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("bb"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // datum/string.yaml line #127 /* ['aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc "} /* r.expr('aaaa bbbb cccc ').split(' bbbb ') */ suite.T().Log("About to run line #127: r.Expr('aaaa bbbb cccc ').Split(' bbbb ')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" bbbb "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #127") } { // datum/string.yaml line #129 /* ['aaaa ', '', ' cccc b d ', ' e ', '', ' f'] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc b d ", " e ", "", " f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split('bb') */ suite.T().Log("About to run line #129: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split('bb')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split("bb"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #129") } { // datum/string.yaml line #131 /* ['aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e bbbb f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ') */ suite.T().Log("About to run line #131: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #131") } { // datum/string.yaml line #133 /* ['aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e", "f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ') */ suite.T().Log("About to run line #133: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ')") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #133") } { // datum/string.yaml line #136 /* ['aaaa', 'bbbb', 'cccc'] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc"} /* r.expr('aaaa bbbb cccc ').split(null, 3) */ suite.T().Log("About to run line #136: r.Expr('aaaa bbbb cccc ').Split(nil, 3)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(nil, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #136") } { // datum/string.yaml line #138 /* ['aaaa', 'bbbb', '', 'cccc', ''] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "", "cccc", ""} /* r.expr('aaaa bbbb cccc ').split(' ', 5) */ suite.T().Log("About to run line #138: r.Expr('aaaa bbbb cccc ').Split(' ', 5)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" ", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #138") } { // datum/string.yaml line #140 /* ['a', 'a', 'a', 'a', ' ', 'bbbb cccc '] */ var expected_ []interface{} = []interface{}{"a", "a", "a", "a", " ", "bbbb cccc "} /* r.expr('aaaa bbbb cccc ').split('', 5) */ suite.T().Log("About to run line #140: r.Expr('aaaa bbbb cccc ').Split('', 5)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #140") } { // datum/string.yaml line #142 /* ['aaaa ', '', '', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", "", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('b', 5) */ suite.T().Log("About to run line #142: r.Expr('aaaa bbbb cccc ').Split('b', 5)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("b", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #142") } { // datum/string.yaml line #144 /* ['aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('bb', 3) */ suite.T().Log("About to run line #144: r.Expr('aaaa bbbb cccc ').Split('bb', 3)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("bb", 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #144") } { // datum/string.yaml line #146 /* ['aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc "} /* r.expr('aaaa bbbb cccc ').split(' bbbb ', 2) */ suite.T().Log("About to run line #146: r.Expr('aaaa bbbb cccc ').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #146") } { // datum/string.yaml line #148 /* ['aaaa ', '', ' cccc b d ', ' e ', '', ' f'] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc b d ", " e ", "", " f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split('bb', 6) */ suite.T().Log("About to run line #148: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split('bb', 6)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split("bb", 6), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #148") } { // datum/string.yaml line #150 /* ['aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e bbbb f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #150: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #150") } { // datum/string.yaml line #152 /* ['aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e", "f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 3) */ suite.T().Log("About to run line #152: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 3)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #152") } { // datum/string.yaml line #155 /* ['aaaa', 'bbbb', 'cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc "} /* r.expr('aaaa bbbb cccc ').split(null, 2) */ suite.T().Log("About to run line #155: r.Expr('aaaa bbbb cccc ').Split(nil, 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(nil, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #155") } { // datum/string.yaml line #157 /* ["a", "b"] */ var expected_ []interface{} = []interface{}{"a", "b"} /* r.expr("a b ").split(null, 2) */ suite.T().Log("About to run line #157: r.Expr('a b ').Split(nil, 2)") runAndAssert(suite.Suite, expected_, r.Expr("a b ").Split(nil, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #157") } { // datum/string.yaml line #159 /* ['aaaa', 'bbbb', '', 'cccc', ''] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "", "cccc", ""} /* r.expr('aaaa bbbb cccc ').split(' ', 4) */ suite.T().Log("About to run line #159: r.Expr('aaaa bbbb cccc ').Split(' ', 4)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" ", 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // datum/string.yaml line #161 /* ['a', 'a', 'a', 'a', ' bbbb cccc '] */ var expected_ []interface{} = []interface{}{"a", "a", "a", "a", " bbbb cccc "} /* r.expr('aaaa bbbb cccc ').split('', 4) */ suite.T().Log("About to run line #161: r.Expr('aaaa bbbb cccc ').Split('', 4)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("", 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #161") } { // datum/string.yaml line #163 /* ['aaaa ', '', '', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", "", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('b', 4) */ suite.T().Log("About to run line #163: r.Expr('aaaa bbbb cccc ').Split('b', 4)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("b", 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #163") } { // datum/string.yaml line #165 /* ['aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('bb', 2) */ suite.T().Log("About to run line #165: r.Expr('aaaa bbbb cccc ').Split('bb', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("bb", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #165") } { // datum/string.yaml line #167 /* ['aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc "} /* r.expr('aaaa bbbb cccc ').split(' bbbb ', 1) */ suite.T().Log("About to run line #167: r.Expr('aaaa bbbb cccc ').Split(' bbbb ', 1)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" bbbb ", 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #167") } { // datum/string.yaml line #169 /* ['aaaa ', '', ' cccc b d ', ' e ', '', ' f'] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc b d ", " e ", "", " f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split('bb', 5) */ suite.T().Log("About to run line #169: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split('bb', 5)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split("bb", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #169") } { // datum/string.yaml line #171 /* ['aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e bbbb f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 1) */ suite.T().Log("About to run line #171: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 1)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #171") } { // datum/string.yaml line #173 /* ['aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e", "f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #173: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #173") } { // datum/string.yaml line #176 /* ['aaaa', 'bbbb cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb cccc "} /* r.expr('aaaa bbbb cccc ').split(null, 1) */ suite.T().Log("About to run line #176: r.Expr('aaaa bbbb cccc ').Split(nil, 1)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(nil, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #176") } { // datum/string.yaml line #178 /* ['aaaa', 'bbbb', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", " cccc "} /* r.expr('aaaa bbbb cccc ').split(' ', 2) */ suite.T().Log("About to run line #178: r.Expr('aaaa bbbb cccc ').Split(' ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #178") } { // datum/string.yaml line #180 /* ['a', 'a', 'aa bbbb cccc '] */ var expected_ []interface{} = []interface{}{"a", "a", "aa bbbb cccc "} /* r.expr('aaaa bbbb cccc ').split('', 2) */ suite.T().Log("About to run line #180: r.Expr('aaaa bbbb cccc ').Split('', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #180") } { // datum/string.yaml line #182 /* ['aaaa ', '', 'bb cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", "bb cccc "} /* r.expr('aaaa bbbb cccc ').split('b', 2) */ suite.T().Log("About to run line #182: r.Expr('aaaa bbbb cccc ').Split('b', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("b", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #182") } { // datum/string.yaml line #184 /* ['aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc "} /* r.expr('aaaa bbbb cccc ').split('bb', 2) */ suite.T().Log("About to run line #184: r.Expr('aaaa bbbb cccc ').Split('bb', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split("bb", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #184") } { // datum/string.yaml line #186 /* ['aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc "} /* r.expr('aaaa bbbb cccc ').split(' bbbb ', 2) */ suite.T().Log("About to run line #186: r.Expr('aaaa bbbb cccc ').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc ").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #186") } { // datum/string.yaml line #188 /* ['aaaa ', '', ' cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{"aaaa ", "", " cccc b d bb e bbbb f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split('bb', 2) */ suite.T().Log("About to run line #188: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split('bb', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split("bb", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #188") } { // datum/string.yaml line #190 /* ['aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e bbbb f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #190: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #190") } { // datum/string.yaml line #192 /* ['aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{"aaaa", "cccc b d bb e", "f"} /* r.expr('aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #192: r.Expr('aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr("aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #192") } { // datum/string.yaml line #195 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr(' ').split() */ suite.T().Log("About to run line #195: r.Expr(' ').Split()") runAndAssert(suite.Suite, expected_, r.Expr(" ").Split(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #195") } { // datum/string.yaml line #197 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr(' ').split(null) */ suite.T().Log("About to run line #197: r.Expr(' ').Split(nil)") runAndAssert(suite.Suite, expected_, r.Expr(" ").Split(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #197") } { // datum/string.yaml line #199 /* ['', '', ''] */ var expected_ []interface{} = []interface{}{"", "", ""} /* r.expr(' ').split(' ') */ suite.T().Log("About to run line #199: r.Expr(' ').Split(' ')") runAndAssert(suite.Suite, expected_, r.Expr(" ").Split(" "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #199") } { // datum/string.yaml line #201 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr(' ').split(null, 5) */ suite.T().Log("About to run line #201: r.Expr(' ').Split(nil, 5)") runAndAssert(suite.Suite, expected_, r.Expr(" ").Split(nil, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #201") } { // datum/string.yaml line #203 /* ['', '', ''] */ var expected_ []interface{} = []interface{}{"", "", ""} /* r.expr(' ').split(' ', 5) */ suite.T().Log("About to run line #203: r.Expr(' ').Split(' ', 5)") runAndAssert(suite.Suite, expected_, r.Expr(" ").Split(" ", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #203") } { // datum/string.yaml line #206 /* ['aaaa', 'bbbb', 'cccc'] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc"} /* r.expr(' aaaa bbbb cccc ').split() */ suite.T().Log("About to run line #206: r.Expr(' aaaa bbbb cccc ').Split()") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #206") } { // datum/string.yaml line #208 /* ['aaaa', 'bbbb', 'cccc'] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc"} /* r.expr(' aaaa bbbb cccc ').split(null) */ suite.T().Log("About to run line #208: r.Expr(' aaaa bbbb cccc ').Split(nil)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #208") } { // datum/string.yaml line #210 /* ['', '', 'aaaa', 'bbbb', '', 'cccc', ''] */ var expected_ []interface{} = []interface{}{"", "", "aaaa", "bbbb", "", "cccc", ""} /* r.expr(' aaaa bbbb cccc ').split(' ') */ suite.T().Log("About to run line #210: r.Expr(' aaaa bbbb cccc ').Split(' ')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #210") } { // datum/string.yaml line #212 /* [' aaaa ', '', '', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", "", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('b') */ suite.T().Log("About to run line #212: r.Expr(' aaaa bbbb cccc ').Split('b')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #212") } { // datum/string.yaml line #214 /* [' aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('bb') */ suite.T().Log("About to run line #214: r.Expr(' aaaa bbbb cccc ').Split('bb')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("bb"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #214") } { // datum/string.yaml line #216 /* [' aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc "} /* r.expr(' aaaa bbbb cccc ').split(' bbbb ') */ suite.T().Log("About to run line #216: r.Expr(' aaaa bbbb cccc ').Split(' bbbb ')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" bbbb "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #216") } { // datum/string.yaml line #218 /* [' aaaa ', '', ' cccc b d ', ' e ', '', ' f'] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc b d ", " e ", "", " f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split('bb') */ suite.T().Log("About to run line #218: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split('bb')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split("bb"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #218") } { // datum/string.yaml line #220 /* [' aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e bbbb f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ') */ suite.T().Log("About to run line #220: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #220") } { // datum/string.yaml line #222 /* [' aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e", "f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ') */ suite.T().Log("About to run line #222: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ')") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb "), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #222") } { // datum/string.yaml line #225 /* ['aaaa', 'bbbb', 'cccc'] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc"} /* r.expr(' aaaa bbbb cccc ').split(null, 3) */ suite.T().Log("About to run line #225: r.Expr(' aaaa bbbb cccc ').Split(nil, 3)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(nil, 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #225") } { // datum/string.yaml line #227 /* ['', '', 'aaaa', 'bbbb', '', 'cccc '] */ var expected_ []interface{} = []interface{}{"", "", "aaaa", "bbbb", "", "cccc "} /* r.expr(' aaaa bbbb cccc ').split(' ', 5) */ suite.T().Log("About to run line #227: r.Expr(' aaaa bbbb cccc ').Split(' ', 5)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" ", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #227") } { // datum/string.yaml line #229 /* [' aaaa ', '', '', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", "", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('b', 5) */ suite.T().Log("About to run line #229: r.Expr(' aaaa bbbb cccc ').Split('b', 5)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("b", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #229") } { // datum/string.yaml line #231 /* [' aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('bb', 3) */ suite.T().Log("About to run line #231: r.Expr(' aaaa bbbb cccc ').Split('bb', 3)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("bb", 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #231") } { // datum/string.yaml line #233 /* [' aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc "} /* r.expr(' aaaa bbbb cccc ').split(' bbbb ', 2) */ suite.T().Log("About to run line #233: r.Expr(' aaaa bbbb cccc ').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #233") } { // datum/string.yaml line #235 /* [' aaaa ', '', ' cccc b d ', ' e ', '', ' f'] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc b d ", " e ", "", " f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split('bb', 6) */ suite.T().Log("About to run line #235: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split('bb', 6)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split("bb", 6), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #235") } { // datum/string.yaml line #237 /* [' aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e bbbb f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #237: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #237") } { // datum/string.yaml line #239 /* [' aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e", "f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 3) */ suite.T().Log("About to run line #239: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 3)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #239") } { // datum/string.yaml line #242 /* ['aaaa', 'bbbb', 'cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb", "cccc "} /* r.expr(' aaaa bbbb cccc ').split(null, 2) */ suite.T().Log("About to run line #242: r.Expr(' aaaa bbbb cccc ').Split(nil, 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(nil, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #242") } { // datum/string.yaml line #244 /* ["a", "b"] */ var expected_ []interface{} = []interface{}{"a", "b"} /* r.expr("a b ").split(null, 2) */ suite.T().Log("About to run line #244: r.Expr('a b ').Split(nil, 2)") runAndAssert(suite.Suite, expected_, r.Expr("a b ").Split(nil, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #244") } { // datum/string.yaml line #246 /* ['', '', 'aaaa', 'bbbb', ' cccc '] */ var expected_ []interface{} = []interface{}{"", "", "aaaa", "bbbb", " cccc "} /* r.expr(' aaaa bbbb cccc ').split(' ', 4) */ suite.T().Log("About to run line #246: r.Expr(' aaaa bbbb cccc ').Split(' ', 4)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" ", 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #246") } { // datum/string.yaml line #248 /* [' aaaa ', '', '', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", "", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('b', 4) */ suite.T().Log("About to run line #248: r.Expr(' aaaa bbbb cccc ').Split('b', 4)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("b", 4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #248") } { // datum/string.yaml line #250 /* [' aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('bb', 2) */ suite.T().Log("About to run line #250: r.Expr(' aaaa bbbb cccc ').Split('bb', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("bb", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #250") } { // datum/string.yaml line #252 /* [' aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc "} /* r.expr(' aaaa bbbb cccc ').split(' bbbb ', 1) */ suite.T().Log("About to run line #252: r.Expr(' aaaa bbbb cccc ').Split(' bbbb ', 1)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" bbbb ", 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #252") } { // datum/string.yaml line #254 /* [' aaaa ', '', ' cccc b d ', ' e ', '', ' f'] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc b d ", " e ", "", " f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split('bb', 5) */ suite.T().Log("About to run line #254: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split('bb', 5)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split("bb", 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #254") } { // datum/string.yaml line #256 /* [' aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e bbbb f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 1) */ suite.T().Log("About to run line #256: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 1)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #256") } { // datum/string.yaml line #258 /* [' aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e", "f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #258: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #258") } { // datum/string.yaml line #261 /* ['aaaa', 'bbbb cccc '] */ var expected_ []interface{} = []interface{}{"aaaa", "bbbb cccc "} /* r.expr(' aaaa bbbb cccc ').split(null, 1) */ suite.T().Log("About to run line #261: r.Expr(' aaaa bbbb cccc ').Split(nil, 1)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(nil, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #261") } { // datum/string.yaml line #263 /* ['', '', 'aaaa bbbb cccc '] */ var expected_ []interface{} = []interface{}{"", "", "aaaa bbbb cccc "} /* r.expr(' aaaa bbbb cccc ').split(' ', 2) */ suite.T().Log("About to run line #263: r.Expr(' aaaa bbbb cccc ').Split(' ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #263") } { // datum/string.yaml line #265 /* [' aaaa ', '', 'bb cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", "bb cccc "} /* r.expr(' aaaa bbbb cccc ').split('b', 2) */ suite.T().Log("About to run line #265: r.Expr(' aaaa bbbb cccc ').Split('b', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("b", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #265") } { // datum/string.yaml line #267 /* [' aaaa ', '', ' cccc '] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc "} /* r.expr(' aaaa bbbb cccc ').split('bb', 2) */ suite.T().Log("About to run line #267: r.Expr(' aaaa bbbb cccc ').Split('bb', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split("bb", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #267") } { // datum/string.yaml line #269 /* [' aaaa', 'cccc '] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc "} /* r.expr(' aaaa bbbb cccc ').split(' bbbb ', 2) */ suite.T().Log("About to run line #269: r.Expr(' aaaa bbbb cccc ').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc ").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #269") } { // datum/string.yaml line #271 /* [' aaaa ', '', ' cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{" aaaa ", "", " cccc b d bb e bbbb f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split('bb', 2) */ suite.T().Log("About to run line #271: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split('bb', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split("bb", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #271") } { // datum/string.yaml line #273 /* [' aaaa', 'cccc b d bb e bbbb f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e bbbb f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #273: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #273") } { // datum/string.yaml line #275 /* [' aaaa', 'cccc b d bb e', 'f'] */ var expected_ []interface{} = []interface{}{" aaaa", "cccc b d bb e", "f"} /* r.expr(' aaaa bbbb cccc b d bb e bbbb f').split(' bbbb ', 2) */ suite.T().Log("About to run line #275: r.Expr(' aaaa bbbb cccc b d bb e bbbb f').Split(' bbbb ', 2)") runAndAssert(suite.Suite, expected_, r.Expr(" aaaa bbbb cccc b d bb e bbbb f").Split(" bbbb ", 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #275") } { // datum/string.yaml line #278 /* "ABC-DEF-GHJ" */ var expected_ string = "ABC-DEF-GHJ" /* r.expr("abc-dEf-GHJ").upcase() */ suite.T().Log("About to run line #278: r.Expr('abc-dEf-GHJ').Upcase()") runAndAssert(suite.Suite, expected_, r.Expr("abc-dEf-GHJ").Upcase(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #278") } { // datum/string.yaml line #280 /* "abc-def-ghj" */ var expected_ string = "abc-def-ghj" /* r.expr("abc-dEf-GHJ").downcase() */ suite.T().Log("About to run line #280: r.Expr('abc-dEf-GHJ').Downcase()") runAndAssert(suite.Suite, expected_, r.Expr("abc-dEf-GHJ").Downcase(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #280") } { // datum/string.yaml line #285 /* ["f", "\u00e9", "o", "o"] */ var expected_ []interface{} = []interface{}{"f", "é", "o", "o"} /* r.expr(u"f\u00e9oo").split("") */ suite.T().Log("About to run line #285: r.Expr('féoo').Split('')") runAndAssert(suite.Suite, expected_, r.Expr("féoo").Split(""), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #285") } { // datum/string.yaml line #294 /* ["f", "e\u0301", "o", "o"] */ var expected_ []interface{} = []interface{}{"f", "é", "o", "o"} /* r.expr(u"fe\u0301oo").split("") */ suite.T().Log("About to run line #294: r.Expr('féoo').Split('')") runAndAssert(suite.Suite, expected_, r.Expr("féoo").Split(""), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #294") } { // datum/string.yaml line #307 /* ["foo", "bar", "baz", "quux", "fred", "barney", "wilma"] */ var expected_ []interface{} = []interface{}{"foo", "bar", "baz", "quux", "fred", "barney", "wilma"} /* r.expr(u"foo bar\tbaz\nquux\rfred\u000bbarney\u000cwilma").split() */ suite.T().Log("About to run line #307: r.Expr('foo bar\\tbaz\\nquux\\rfred\\u000bbarney\\u000cwilma').Split()") runAndAssert(suite.Suite, expected_, r.Expr("foo bar\tbaz\nquux\rfred\u000bbarney\u000cwilma").Split(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #307") } { // datum/string.yaml line #323 /* ["foo", "bar", "baz\u2060quux", "fred", "barney", "wilma", "betty\u200b"] */ var expected_ []interface{} = []interface{}{"foo", "bar", "baz\u2060quux", "fred", "barney", "wilma", "betty\u200b"} /* r.expr(u"foo\u00a0bar\u2001baz\u2060quux\u2028fred\u2028barney\u2029wilma\u0085betty\u200b").split() */ suite.T().Log("About to run line #323: r.Expr('foo\\u00a0bar\\u2001baz\\u2060quux\\u2028fred\\u2028barney\\u2029wilma\\u0085betty\\u200b').Split()") runAndAssert(suite.Suite, expected_, r.Expr("foo\u00a0bar\u2001baz\u2060quux\u2028fred\u2028barney\u2029wilma\u0085betty\u200b").Split(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #323") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_typeof_test.go000066400000000000000000000042161363464422500275460ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // These tests test the type of command func TestDatumTypeofSuite(t *testing.T) { suite.Run(t, new(DatumTypeofSuite)) } type DatumTypeofSuite struct { suite.Suite session *r.Session } func (suite *DatumTypeofSuite) SetupTest() { suite.T().Log("Setting up DatumTypeofSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dtype").Exec(suite.session) err = r.DBCreate("db_dtype").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dtype").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumTypeofSuite) TearDownSuite() { suite.T().Log("Tearing down DatumTypeofSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dtype").Exec(suite.session) suite.session.Close() } } func (suite *DatumTypeofSuite) TestCases() { suite.T().Log("Running DatumTypeofSuite: These tests test the type of command") { // datum/typeof.yaml line #5 /* 'NULL' */ var expected_ string = "NULL" /* r.expr(null).type_of() */ suite.T().Log("About to run line #5: r.Expr(nil).TypeOf()") runAndAssert(suite.Suite, expected_, r.Expr(nil).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // datum/typeof.yaml line #9 /* 'NULL' */ var expected_ string = "NULL" /* r.type_of(null) */ suite.T().Log("About to run line #9: r.TypeOf(nil)") runAndAssert(suite.Suite, expected_, r.TypeOf(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_datum_uuid_test.go000066400000000000000000000111421363464422500272020ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test that UUIDs work func TestDatumUuidSuite(t *testing.T) { suite.Run(t, new(DatumUuidSuite)) } type DatumUuidSuite struct { suite.Suite session *r.Session } func (suite *DatumUuidSuite) SetupTest() { suite.T().Log("Setting up DatumUuidSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_duuid").Exec(suite.session) err = r.DBCreate("db_duuid").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_duuid").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DatumUuidSuite) TearDownSuite() { suite.T().Log("Tearing down DatumUuidSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_duuid").Exec(suite.session) suite.session.Close() } } func (suite *DatumUuidSuite) TestCases() { suite.T().Log("Running DatumUuidSuite: Test that UUIDs work") { // datum/uuid.yaml line #3 /* uuid() */ var expected_ compare.Regex = compare.IsUUID() /* r.uuid() */ suite.T().Log("About to run line #3: r.UUID()") runAndAssert(suite.Suite, expected_, r.UUID(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #3") } { // datum/uuid.yaml line #5 /* uuid() */ var expected_ compare.Regex = compare.IsUUID() /* r.expr(r.uuid()) */ suite.T().Log("About to run line #5: r.Expr(r.UUID())") runAndAssert(suite.Suite, expected_, r.Expr(r.UUID()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // datum/uuid.yaml line #7 /* 'STRING' */ var expected_ string = "STRING" /* r.type_of(r.uuid()) */ suite.T().Log("About to run line #7: r.TypeOf(r.UUID())") runAndAssert(suite.Suite, expected_, r.TypeOf(r.UUID()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // datum/uuid.yaml line #9 /* true */ var expected_ bool = true /* r.uuid().ne(r.uuid()) */ suite.T().Log("About to run line #9: r.UUID().Ne(r.UUID())") runAndAssert(suite.Suite, expected_, r.UUID().Ne(r.UUID()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // datum/uuid.yaml line #11 /* ('97dd10a5-4fc4-554f-86c5-0d2c2e3d5330') */ var expected_ string = "97dd10a5-4fc4-554f-86c5-0d2c2e3d5330" /* r.uuid('magic') */ suite.T().Log("About to run line #11: r.UUID('magic')") runAndAssert(suite.Suite, expected_, r.UUID("magic"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // datum/uuid.yaml line #13 /* true */ var expected_ bool = true /* r.uuid('magic').eq(r.uuid('magic')) */ suite.T().Log("About to run line #13: r.UUID('magic').Eq(r.UUID('magic'))") runAndAssert(suite.Suite, expected_, r.UUID("magic").Eq(r.UUID("magic")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // datum/uuid.yaml line #15 /* true */ var expected_ bool = true /* r.uuid('magic').ne(r.uuid('beans')) */ suite.T().Log("About to run line #15: r.UUID('magic').Ne(r.UUID('beans'))") runAndAssert(suite.Suite, expected_, r.UUID("magic").Ne(r.UUID("beans")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // datum/uuid.yaml line #17 /* 10 */ var expected_ int = 10 /* r.expr([1,2,3,4,5,6,7,8,9,10]).map(lambda u:r.uuid()).distinct().count() */ suite.T().Log("About to run line #17: r.Expr([]interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Map(func(u r.Term) interface{} { return r.UUID()}).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).Map(func(u r.Term) interface{} { return r.UUID() }).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_default_test.go000066400000000000000000001245341363464422500265000ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests r.default func TestDefaultSuite(t *testing.T) { suite.Run(t, new(DefaultSuite)) } type DefaultSuite struct { suite.Suite session *r.Session } func (suite *DefaultSuite) SetupTest() { suite.T().Log("Setting up DefaultSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_def").Exec(suite.session) err = r.DBCreate("db_def").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_def").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *DefaultSuite) TearDownSuite() { suite.T().Log("Tearing down DefaultSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_def").Exec(suite.session) suite.session.Close() } } func (suite *DefaultSuite) TestCases() { suite.T().Log("Running DefaultSuite: Tests r.default") { // default.yaml line #3 /* 1 */ var expected_ int = 1 /* r.expr(1).default(2) */ suite.T().Log("About to run line #3: r.Expr(1).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #3") } { // default.yaml line #5 /* 2 */ var expected_ int = 2 /* r.expr(null).default(2) */ suite.T().Log("About to run line #5: r.Expr(nil).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // default.yaml line #7 /* 2 */ var expected_ int = 2 /* r.expr({})['b'].default(2) */ suite.T().Log("About to run line #7: r.Expr(map[interface{}]interface{}{}).AtIndex('b').Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}).AtIndex("b").Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // default.yaml line #10 /* err("ReqlQueryLogicError", "Cannot perform bracket on a non-object non-sequence `\"a\"`.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot perform bracket on a non-object non-sequence `\"a\"`.") /* r.expr(r.expr('a')['b']).default(2) */ suite.T().Log("About to run line #10: r.Expr(r.Expr('a').AtIndex('b')).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(r.Expr("a").AtIndex("b")).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // default.yaml line #14 /* 2 */ var expected_ int = 2 /* r.expr([]).reduce(lambda a,b:a+b).default(2) */ suite.T().Log("About to run line #14: r.Expr([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // default.yaml line #18 /* 2 */ var expected_ int = 2 /* r.expr([]).union([]).reduce(lambda a,b:a+b).default(2) */ suite.T().Log("About to run line #18: r.Expr([]interface{}{}).Union([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Union([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // default.yaml line #22 /* err("ReqlQueryLogicError", "Cannot convert STRING to SEQUENCE", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert STRING to SEQUENCE") /* r.expr('a').reduce(lambda a,b:a+b).default(2) */ suite.T().Log("About to run line #22: r.Expr('a').Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr("a").Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // default.yaml line #25 /* 2 */ var expected_ int = 2 /* (r.expr(null) + 5).default(2) */ suite.T().Log("About to run line #25: r.Expr(nil).Add(5).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Add(5).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // default.yaml line #28 /* 2 */ var expected_ int = 2 /* (5 + r.expr(null)).default(2) */ suite.T().Log("About to run line #28: r.Add(5, r.Expr(nil)).Default(2)") runAndAssert(suite.Suite, expected_, r.Add(5, r.Expr(nil)).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // default.yaml line #31 /* 2 */ var expected_ int = 2 /* (5 - r.expr(null)).default(2) */ suite.T().Log("About to run line #31: r.Sub(5, r.Expr(nil)).Default(2)") runAndAssert(suite.Suite, expected_, r.Sub(5, r.Expr(nil)).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // default.yaml line #34 /* 2 */ var expected_ int = 2 /* (r.expr(null) - 5).default(2) */ suite.T().Log("About to run line #34: r.Expr(nil).Sub(5).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Sub(5).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // default.yaml line #37 /* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* (r.expr('a') + 5).default(2) */ suite.T().Log("About to run line #37: r.Expr('a').Add(5).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr("a").Add(5).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // default.yaml line #40 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* (5 + r.expr('a')).default(2) */ suite.T().Log("About to run line #40: r.Add(5, r.Expr('a')).Default(2)") runAndAssert(suite.Suite, expected_, r.Add(5, r.Expr("a")).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // default.yaml line #43 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* (r.expr('a') - 5).default(2) */ suite.T().Log("About to run line #43: r.Expr('a').Sub(5).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr("a").Sub(5).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // default.yaml line #46 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* (5 - r.expr('a')).default(2) */ suite.T().Log("About to run line #46: r.Sub(5, r.Expr('a')).Default(2)") runAndAssert(suite.Suite, expected_, r.Sub(5, r.Expr("a")).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // default.yaml line #50 /* 1 */ var expected_ int = 1 /* r.expr(1).default(r.error()) */ suite.T().Log("About to run line #50: r.Expr(1).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr(1).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // default.yaml line #52 /* (null) */ var expected_ interface{} = nil /* r.expr(null).default(r.error()) */ suite.T().Log("About to run line #52: r.Expr(nil).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr(nil).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // default.yaml line #54 /* err("ReqlNonExistenceError", "No attribute `b` in object:", []) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `b` in object:") /* r.expr({})['b'].default(r.error()) */ suite.T().Log("About to run line #54: r.Expr(map[interface{}]interface{}{}).AtIndex('b').Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}).AtIndex("b").Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // default.yaml line #58 /* err("ReqlNonExistenceError", "Cannot reduce over an empty stream.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Cannot reduce over an empty stream.") /* r.expr([]).reduce(lambda a,b:a+b).default(r.error) */ suite.T().Log("About to run line #58: r.Expr([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // default.yaml line #62 /* err("ReqlNonExistenceError", "Cannot reduce over an empty stream.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Cannot reduce over an empty stream.") /* r.expr([]).union([]).reduce(lambda a,b:a+b).default(r.error) */ suite.T().Log("About to run line #62: r.Expr([]interface{}{}).Union([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Union([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // default.yaml line #65 /* err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* (r.expr(null) + 5).default(r.error) */ suite.T().Log("About to run line #65: r.Expr(nil).Add(5).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr(nil).Add(5).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // default.yaml line #68 /* err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* (5 + r.expr(null)).default(r.error) */ suite.T().Log("About to run line #68: r.Add(5, r.Expr(nil)).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Add(5, r.Expr(nil)).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #68") } { // default.yaml line #71 /* err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* (5 - r.expr(null)).default(r.error) */ suite.T().Log("About to run line #71: r.Sub(5, r.Expr(nil)).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Sub(5, r.Expr(nil)).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // default.yaml line #74 /* err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Expected type NUMBER but found NULL.") /* (r.expr(null) - 5).default(r.error) */ suite.T().Log("About to run line #74: r.Expr(nil).Sub(5).Default(r.Error())") runAndAssert(suite.Suite, expected_, r.Expr(nil).Sub(5).Default(r.Error()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } { // default.yaml line #79 /* 1 */ var expected_ int = 1 /* r.expr(1).default(lambda e:e) */ suite.T().Log("About to run line #79: r.Expr(1).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr(1).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #79") } { // default.yaml line #83 /* (null) */ var expected_ interface{} = nil /* r.expr(null).default(lambda e:e) */ suite.T().Log("About to run line #83: r.Expr(nil).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr(nil).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // default.yaml line #87 /* "No attribute `b` in object:\n{}" */ var expected_ string = "No attribute `b` in object:\n{}" /* r.expr({})['b'].default(lambda e:e) */ suite.T().Log("About to run line #87: r.Expr(map[interface{}]interface{}{}).AtIndex('b').Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}).AtIndex("b").Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } { // default.yaml line #91 /* ("Cannot reduce over an empty stream.") */ var expected_ string = "Cannot reduce over an empty stream." /* r.expr([]).reduce(lambda a,b:a+b).default(lambda e:e) */ suite.T().Log("About to run line #91: r.Expr([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // default.yaml line #95 /* ("Cannot reduce over an empty stream.") */ var expected_ string = "Cannot reduce over an empty stream." /* r.expr([]).union([]).reduce(lambda a,b:a+b).default(lambda e:e) */ suite.T().Log("About to run line #95: r.Expr([]interface{}{}).Union([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b)}).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Union([]interface{}{}).Reduce(func(a r.Term, b r.Term) interface{} { return r.Add(a, b) }).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #95") } { // default.yaml line #99 /* ("Expected type NUMBER but found NULL.") */ var expected_ string = "Expected type NUMBER but found NULL." /* (r.expr(null) + 5).default(lambda e:e) */ suite.T().Log("About to run line #99: r.Expr(nil).Add(5).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr(nil).Add(5).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #99") } { // default.yaml line #103 /* ("Expected type NUMBER but found NULL.") */ var expected_ string = "Expected type NUMBER but found NULL." /* (5 + r.expr(null)).default(lambda e:e) */ suite.T().Log("About to run line #103: r.Add(5, r.Expr(nil)).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Add(5, r.Expr(nil)).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // default.yaml line #107 /* ("Expected type NUMBER but found NULL.") */ var expected_ string = "Expected type NUMBER but found NULL." /* (5 - r.expr(null)).default(lambda e:e) */ suite.T().Log("About to run line #107: r.Sub(5, r.Expr(nil)).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Sub(5, r.Expr(nil)).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #107") } { // default.yaml line #111 /* ("Expected type NUMBER but found NULL.") */ var expected_ string = "Expected type NUMBER but found NULL." /* (r.expr(null) - 5).default(lambda e:e) */ suite.T().Log("About to run line #111: r.Expr(nil).Sub(5).Default(func(e r.Term) interface{} { return e})") runAndAssert(suite.Suite, expected_, r.Expr(nil).Sub(5).Default(func(e r.Term) interface{} { return e }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } // default.yaml line #115 // arr = r.expr([{'a':1},{'a':null},{}]).order_by('a') suite.T().Log("Possibly executing: var arr r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, }, map[interface{}]interface{}{'a': nil, }, map[interface{}]interface{}{}}).OrderBy('a')") arr := r.Expr([]interface{}{map[interface{}]interface{}{"a": 1}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{}}).OrderBy("a") _ = arr // Prevent any noused variable errors { // default.yaml line #118 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].eq(1)) */ suite.T().Log("About to run line #118: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)})") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } { // default.yaml line #122 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].eq(1), default=False) */ suite.T().Log("About to run line #122: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: false, })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // default.yaml line #126 /* [{}, {'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].eq(1), default=True) */ suite.T().Log("About to run line #126: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: true, })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #126") } { // default.yaml line #131 /* [{}, {'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].eq(1), default=r.js('true')) */ suite.T().Log("About to run line #131: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: r.JS('true'), })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: r.JS("true")}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #131") } { // default.yaml line #135 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].eq(1), default=r.js('false')) */ suite.T().Log("About to run line #135: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: r.JS('false'), })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: r.JS("false")}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #135") } { // default.yaml line #139 /* err("ReqlNonExistenceError", "No attribute `a` in object:", []) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `a` in object:") /* arr.filter(lambda x:x['a'].eq(1), default=r.error()) */ suite.T().Log("About to run line #139: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: r.Error(), })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: r.Error()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #139") } { // default.yaml line #144 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* r.expr(False).do(lambda d:arr.filter(lambda x:x['a'].eq(1), default=d)) */ suite.T().Log("About to run line #144: r.Expr(false).Do(func(d r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: d, })})") runAndAssert(suite.Suite, expected_, r.Expr(false).Do(func(d r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: d}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #144") } { // default.yaml line #148 /* [{}, {'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": 1}} /* r.expr(True).do(lambda d:arr.filter(lambda x:x['a'].eq(1), default=d)).order_by('a') */ suite.T().Log("About to run line #148: r.Expr(true).Do(func(d r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: d, })}).OrderBy('a')") runAndAssert(suite.Suite, expected_, r.Expr(true).Do(func(d r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: d}) }).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #148") } { // default.yaml line #154 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].default(0).eq(1)) */ suite.T().Log("About to run line #154: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(0).Eq(1)})") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(0).Eq(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #154") } { // default.yaml line #158 /* ([{}, {'a':null}, {'a':1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].default(1).eq(1)).order_by('a') */ suite.T().Log("About to run line #158: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(1).Eq(1)}).OrderBy('a')") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(1).Eq(1) }).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #158") } { // default.yaml line #162 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:x['a'].default(r.error()).eq(1)) */ suite.T().Log("About to run line #162: arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(r.Error()).Eq(1)})") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(r.Error()).Eq(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #162") } { // default.yaml line #168 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* r.expr(0).do(lambda i:arr.filter(lambda x:x['a'].default(i).eq(1))) */ suite.T().Log("About to run line #168: r.Expr(0).Do(func(i r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(i).Eq(1)})})") runAndAssert(suite.Suite, expected_, r.Expr(0).Do(func(i r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(i).Eq(1) }) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #168") } { // default.yaml line #172 /* ([{},{'a':null},{'a':1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{"a": 1}} /* r.expr(1).do(lambda i:arr.filter(lambda x:x['a'].default(i).eq(1))).order_by('a') */ suite.T().Log("About to run line #172: r.Expr(1).Do(func(i r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(i).Eq(1)})}).OrderBy('a')") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(func(i r.Term) interface{} { return arr.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(i).Eq(1) }) }).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #172") } { // default.yaml line #177 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2))) */ suite.T().Log("About to run line #177: arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))})") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #177") } { // default.yaml line #181 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2)), default=False) */ suite.T().Log("About to run line #181: arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))}).OptArgs(r.FilterOpts{Default: false, })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }).OptArgs(r.FilterOpts{Default: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #181") } { // default.yaml line #185 /* ([{}, {'a':null}, {'a':1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{"a": 1}} /* arr.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2)), default=True).order_by('a') */ suite.T().Log("About to run line #185: arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))}).OptArgs(r.FilterOpts{Default: true, }).OrderBy('a')") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }).OptArgs(r.FilterOpts{Default: true}).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #185") } { // default.yaml line #189 /* err("ReqlNonExistenceError", "No attribute `a` in object:", []) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `a` in object:") /* arr.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2)), default=r.error()) */ suite.T().Log("About to run line #189: arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))}).OptArgs(r.FilterOpts{Default: r.Error(), })") runAndAssert(suite.Suite, expected_, arr.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }).OptArgs(r.FilterOpts{Default: r.Error()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #189") } { // default.yaml line #193 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.table_create('default_test') */ suite.T().Log("About to run line #193: r.TableCreate('default_test')") runAndAssert(suite.Suite, expected_, r.TableCreate("default_test"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #193") } { // default.yaml line #196 /* ({'deleted':0,'replaced':0,'generated_keys':arrlen(3,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':3}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(3, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 3} /* r.table('default_test').insert(arr) */ suite.T().Log("About to run line #196: r.Table('default_test').Insert(arr)") runAndAssert(suite.Suite, expected_, r.Table("default_test").Insert(arr), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #196") } // default.yaml line #199 // tbl = r.table('default_test').order_by('a').pluck('a') suite.T().Log("Possibly executing: var tbl r.Term = r.Table('default_test').OrderBy('a').Pluck('a')") tbl := r.Table("default_test").OrderBy("a").Pluck("a") _ = tbl // Prevent any noused variable errors { // default.yaml line #202 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:x['a'].eq(1)) */ suite.T().Log("About to run line #202: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)})") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #202") } { // default.yaml line #206 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:x['a'].eq(1), default=False) */ suite.T().Log("About to run line #206: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: false, })") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #206") } { // default.yaml line #210 /* [{}, {'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:x['a'].eq(1), default=True) */ suite.T().Log("About to run line #210: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: true, })") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #210") } { // default.yaml line #215 /* err("ReqlNonExistenceError", "No attribute `a` in object:", []) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `a` in object:") /* tbl.filter(lambda x:x['a'].eq(1), default=r.error()) */ suite.T().Log("About to run line #215: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: r.Error(), })") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: r.Error()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #215") } { // default.yaml line #220 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* r.expr(False).do(lambda d:tbl.filter(lambda x:x['a'].eq(1), default=d)) */ suite.T().Log("About to run line #220: r.Expr(false).Do(func(d r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: d, })})") runAndAssert(suite.Suite, expected_, r.Expr(false).Do(func(d r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: d}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #220") } { // default.yaml line #224 /* [{}, {'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": 1}} /* r.expr(True).do(lambda d:tbl.filter(lambda x:x['a'].eq(1), default=d)).order_by('a') */ suite.T().Log("About to run line #224: r.Expr(true).Do(func(d r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Eq(1)}).OptArgs(r.FilterOpts{Default: d, })}).OrderBy('a')") runAndAssert(suite.Suite, expected_, r.Expr(true).Do(func(d r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Eq(1) }).OptArgs(r.FilterOpts{Default: d}) }).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #224") } { // default.yaml line #230 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:x['a'].default(0).eq(1)) */ suite.T().Log("About to run line #230: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(0).Eq(1)})") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(0).Eq(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #230") } { // default.yaml line #234 /* ([{}, {'a':null}, {'a':1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:x['a'].default(1).eq(1)).order_by('a') */ suite.T().Log("About to run line #234: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(1).Eq(1)}).OrderBy('a')") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(1).Eq(1) }).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #234") } { // default.yaml line #238 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:x['a'].default(r.error()).eq(1)) */ suite.T().Log("About to run line #238: tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(r.Error()).Eq(1)})") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(r.Error()).Eq(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #238") } { // default.yaml line #244 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* r.expr(0).do(lambda i:tbl.filter(lambda x:x['a'].default(i).eq(1))) */ suite.T().Log("About to run line #244: r.Expr(0).Do(func(i r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(i).Eq(1)})})") runAndAssert(suite.Suite, expected_, r.Expr(0).Do(func(i r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(i).Eq(1) }) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #244") } { // default.yaml line #248 /* ([{},{'a':null},{'a':1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{"a": 1}} /* r.expr(1).do(lambda i:tbl.filter(lambda x:x['a'].default(i).eq(1))).order_by('a') */ suite.T().Log("About to run line #248: r.Expr(1).Do(func(i r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex('a').Default(i).Eq(1)})}).OrderBy('a')") runAndAssert(suite.Suite, expected_, r.Expr(1).Do(func(i r.Term) interface{} { return tbl.Filter(func(x r.Term) interface{} { return x.AtIndex("a").Default(i).Eq(1) }) }).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #248") } { // default.yaml line #253 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2))) */ suite.T().Log("About to run line #253: tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))})") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #253") } { // default.yaml line #257 /* [{'a':1}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2)), default=False) */ suite.T().Log("About to run line #257: tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))}).OptArgs(r.FilterOpts{Default: false, })") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }).OptArgs(r.FilterOpts{Default: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #257") } { // default.yaml line #261 /* ([{}, {'a':null}, {'a':1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{}, map[interface{}]interface{}{"a": nil}, map[interface{}]interface{}{"a": 1}} /* tbl.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2)), default=True).order_by('a') */ suite.T().Log("About to run line #261: tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))}).OptArgs(r.FilterOpts{Default: true, }).OrderBy('a')") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }).OptArgs(r.FilterOpts{Default: true}).OrderBy("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #261") } { // default.yaml line #265 /* err("ReqlNonExistenceError", "No attribute `a` in object:", []) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `a` in object:") /* tbl.filter(lambda x:r.or_(x['a'].eq(1), x['a']['b'].eq(2)), default=r.error()) */ suite.T().Log("About to run line #265: tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex('a').Eq(1), x.AtIndex('a').AtIndex('b').Eq(2))}).OptArgs(r.FilterOpts{Default: r.Error(), })") runAndAssert(suite.Suite, expected_, tbl.Filter(func(x r.Term) interface{} { return r.Or(x.AtIndex("a").Eq(1), x.AtIndex("a").AtIndex("b").Eq(2)) }).OptArgs(r.FilterOpts{Default: r.Error()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #265") } { // default.yaml line #269 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* r.table_drop('default_test') */ suite.T().Log("About to run line #269: r.TableDrop('default_test')") runAndAssert(suite.Suite, expected_, r.TableDrop("default_test"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #269") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_geo_constructors_test.go000066400000000000000000000374661363464422500304650ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test geo constructors func TestGeoConstructorsSuite(t *testing.T) { suite.Run(t, new(GeoConstructorsSuite)) } type GeoConstructorsSuite struct { suite.Suite session *r.Session } func (suite *GeoConstructorsSuite) SetupTest() { suite.T().Log("Setting up GeoConstructorsSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_geoc").Exec(suite.session) err = r.DBCreate("db_geoc").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geoc").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *GeoConstructorsSuite) TearDownSuite() { suite.T().Log("Tearing down GeoConstructorsSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_geoc").Exec(suite.session) suite.session.Close() } } func (suite *GeoConstructorsSuite) TestCases() { suite.T().Log("Running GeoConstructorsSuite: Test geo constructors") { // geo/constructors.yaml line #4 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[0, 0], 'type':'Point'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, 0}, "type": "Point"} /* r.point(0, 0) */ suite.T().Log("About to run line #4: r.Point(0, 0)") runAndAssert(suite.Suite, expected_, r.Point(0, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // geo/constructors.yaml line #6 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[0, -90], 'type':'Point'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, -90}, "type": "Point"} /* r.point(0, -90) */ suite.T().Log("About to run line #6: r.Point(0, -90)") runAndAssert(suite.Suite, expected_, r.Point(0, -90), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // geo/constructors.yaml line #8 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[0, 90], 'type':'Point'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, 90}, "type": "Point"} /* r.point(0, 90) */ suite.T().Log("About to run line #8: r.Point(0, 90)") runAndAssert(suite.Suite, expected_, r.Point(0, 90), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // geo/constructors.yaml line #10 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[-180, 0], 'type':'Point'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{-180, 0}, "type": "Point"} /* r.point(-180, 0) */ suite.T().Log("About to run line #10: r.Point(-180, 0)") runAndAssert(suite.Suite, expected_, r.Point(-180, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // geo/constructors.yaml line #12 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[180, 0], 'type':'Point'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{180, 0}, "type": "Point"} /* r.point(180, 0) */ suite.T().Log("About to run line #12: r.Point(180, 0)") runAndAssert(suite.Suite, expected_, r.Point(180, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // geo/constructors.yaml line #14 /* err('ReqlQueryLogicError', 'Latitude must be between -90 and 90. Got -91.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Latitude must be between -90 and 90. Got -91.") /* r.point(0, -91) */ suite.T().Log("About to run line #14: r.Point(0, -91)") runAndAssert(suite.Suite, expected_, r.Point(0, -91), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // geo/constructors.yaml line #16 /* err('ReqlQueryLogicError', 'Latitude must be between -90 and 90. Got 91.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Latitude must be between -90 and 90. Got 91.") /* r.point(0, 91) */ suite.T().Log("About to run line #16: r.Point(0, 91)") runAndAssert(suite.Suite, expected_, r.Point(0, 91), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // geo/constructors.yaml line #18 /* err('ReqlQueryLogicError', 'Longitude must be between -180 and 180. Got -181.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Longitude must be between -180 and 180. Got -181.") /* r.point(-181, 0) */ suite.T().Log("About to run line #18: r.Point(-181, 0)") runAndAssert(suite.Suite, expected_, r.Point(-181, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // geo/constructors.yaml line #20 /* err('ReqlQueryLogicError', 'Longitude must be between -180 and 180. Got 181.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Longitude must be between -180 and 180. Got 181.") /* r.point(181, 0) */ suite.T().Log("About to run line #20: r.Point(181, 0)") runAndAssert(suite.Suite, expected_, r.Point(181, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // geo/constructors.yaml line #28 /* err('ReqlQueryLogicError', 'Invalid LineString. Are there antipodal or duplicate vertices?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid LineString. Are there antipodal or duplicate vertices?") /* r.line([0,0], [0,0]) */ suite.T().Log("About to run line #28: r.Line([]interface{}{0, 0}, []interface{}{0, 0})") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{0, 0}, []interface{}{0, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // geo/constructors.yaml line #30 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[0,0], [0,1]], 'type':'LineString'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{0, 0}, []interface{}{0, 1}}, "type": "LineString"} /* r.line([0,0], [0,1]) */ suite.T().Log("About to run line #30: r.Line([]interface{}{0, 0}, []interface{}{0, 1})") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{0, 0}, []interface{}{0, 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // geo/constructors.yaml line #32 /* err('ReqlQueryLogicError', 'Expected point coordinate pair. Got 1 element array instead of a 2 element one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected point coordinate pair. Got 1 element array instead of a 2 element one.") /* r.line([0,0], [1]) */ suite.T().Log("About to run line #32: r.Line([]interface{}{0, 0}, []interface{}{1})") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{0, 0}, []interface{}{1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } { // geo/constructors.yaml line #34 /* err('ReqlQueryLogicError', 'Expected point coordinate pair. Got 3 element array instead of a 2 element one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected point coordinate pair. Got 3 element array instead of a 2 element one.") /* r.line([0,0], [1,0,0]) */ suite.T().Log("About to run line #34: r.Line([]interface{}{0, 0}, []interface{}{1, 0, 0})") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{0, 0}, []interface{}{1, 0, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // geo/constructors.yaml line #36 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[0,0], [0,1], [0,0]], 'type':'LineString'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0, 0}}, "type": "LineString"} /* r.line([0,0], [0,1], [0,0]) */ suite.T().Log("About to run line #36: r.Line([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0, 0})") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // geo/constructors.yaml line #38 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[0,0], [0,1], [0,0]], 'type':'LineString'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0, 0}}, "type": "LineString"} /* r.line(r.point(0,0), r.point(0,1), r.point(0,0)) */ suite.T().Log("About to run line #38: r.Line(r.Point(0, 0), r.Point(0, 1), r.Point(0, 0))") runAndAssert(suite.Suite, expected_, r.Line(r.Point(0, 0), r.Point(0, 1), r.Point(0, 0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // geo/constructors.yaml line #40 /* err('ReqlQueryLogicError', 'Expected geometry of type `Point` but found `LineString`.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected geometry of type `Point` but found `LineString`.") /* r.line(r.point(0,0), r.point(1,0), r.line([0,0], [1,0])) */ suite.T().Log("About to run line #40: r.Line(r.Point(0, 0), r.Point(1, 0), r.Line([]interface{}{0, 0}, []interface{}{1, 0}))") runAndAssert(suite.Suite, expected_, r.Line(r.Point(0, 0), r.Point(1, 0), r.Line([]interface{}{0, 0}, []interface{}{1, 0})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // geo/constructors.yaml line #50 /* err('ReqlQueryLogicError', 'Invalid LinearRing. Are there antipodal or duplicate vertices? Is it self-intersecting?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid LinearRing. Are there antipodal or duplicate vertices? Is it self-intersecting?") /* r.polygon([0,0], [0,0], [0,0], [0,0]) */ suite.T().Log("About to run line #50: r.Polygon([]interface{}{0, 0}, []interface{}{0, 0}, []interface{}{0, 0}, []interface{}{0, 0})") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{0, 0}, []interface{}{0, 0}, []interface{}{0, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // geo/constructors.yaml line #52 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0], [0,1], [1,0], [0,0]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0}}}, "type": "Polygon"} /* r.polygon([0,0], [0,1], [1,0]) */ suite.T().Log("About to run line #52: r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0})") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // geo/constructors.yaml line #54 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0], [0,1], [1,0], [0,0]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0}}}, "type": "Polygon"} /* r.polygon([0,0], [0,1], [1,0], [0,0]) */ suite.T().Log("About to run line #54: r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0})") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // geo/constructors.yaml line #56 /* err('ReqlQueryLogicError', 'Invalid LinearRing. Are there antipodal or duplicate vertices? Is it self-intersecting?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Invalid LinearRing. Are there antipodal or duplicate vertices? Is it self-intersecting?") /* r.polygon([0,0], [0,1], [1,0], [-1,0.5]) */ suite.T().Log("About to run line #56: r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{-1, 0.5})") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{-1, 0.5}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #56") } { // geo/constructors.yaml line #58 /* err('ReqlQueryLogicError', 'Expected point coordinate pair. Got 1 element array instead of a 2 element one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected point coordinate pair. Got 1 element array instead of a 2 element one.") /* r.polygon([0,0], [0,1], [0]) */ suite.T().Log("About to run line #58: r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0})") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // geo/constructors.yaml line #60 /* err('ReqlQueryLogicError', 'Expected point coordinate pair. Got 3 element array instead of a 2 element one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected point coordinate pair. Got 3 element array instead of a 2 element one.") /* r.polygon([0,0], [0,1], [0,1,0]) */ suite.T().Log("About to run line #60: r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0, 1, 0})") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{0, 1, 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // geo/constructors.yaml line #62 /* err('ReqlQueryLogicError', 'Expected geometry of type `Point` but found `LineString`.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected geometry of type `Point` but found `LineString`.") /* r.polygon(r.point(0,0), r.point(0,1), r.line([0,0], [0,1])) */ suite.T().Log("About to run line #62: r.Polygon(r.Point(0, 0), r.Point(0, 1), r.Line([]interface{}{0, 0}, []interface{}{0, 1}))") runAndAssert(suite.Suite, expected_, r.Polygon(r.Point(0, 0), r.Point(0, 1), r.Line([]interface{}{0, 0}, []interface{}{0, 1})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_geo_geojson_test.go000066400000000000000000000223471363464422500273510ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test geoJSON conversion func TestGeoGeojsonSuite(t *testing.T) { suite.Run(t, new(GeoGeojsonSuite)) } type GeoGeojsonSuite struct { suite.Suite session *r.Session } func (suite *GeoGeojsonSuite) SetupTest() { suite.T().Log("Setting up GeoGeojsonSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_geoj").Exec(suite.session) err = r.DBCreate("db_geoj").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geoj").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *GeoGeojsonSuite) TearDownSuite() { suite.T().Log("Tearing down GeoGeojsonSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_geoj").Exec(suite.session) suite.session.Close() } } func (suite *GeoGeojsonSuite) TestCases() { suite.T().Log("Running GeoGeojsonSuite: Test geoJSON conversion") { // geo/geojson.yaml line #4 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[0, 0], 'type':'Point'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, 0}, "type": "Point"} /* r.geojson({'coordinates':[0, 0], 'type':'Point'}) */ suite.T().Log("About to run line #4: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{0, 0}, 'type': 'Point', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{0, 0}, "type": "Point"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // geo/geojson.yaml line #6 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[0,0], [0,1]], 'type':'LineString'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{0, 0}, []interface{}{0, 1}}, "type": "LineString"} /* r.geojson({'coordinates':[[0,0], [0,1]], 'type':'LineString'}) */ suite.T().Log("About to run line #6: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{[]interface{}{0, 0}, []interface{}{0, 1}}, 'type': 'LineString', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{[]interface{}{0, 0}, []interface{}{0, 1}}, "type": "LineString"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // geo/geojson.yaml line #8 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0], [0,1], [1,0], [0,0]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0}}}, "type": "Polygon"} /* r.geojson({'coordinates':[[[0,0], [0,1], [1,0], [0,0]]], 'type':'Polygon'}) */ suite.T().Log("About to run line #8: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0}}}, 'type': 'Polygon', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{0, 1}, []interface{}{1, 0}, []interface{}{0, 0}}}, "type": "Polygon"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // geo/geojson.yaml line #12 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found ARRAY.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found ARRAY.") /* r.geojson({'coordinates':[[], 0], 'type':'Point'}) */ suite.T().Log("About to run line #12: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{[]interface{}{}, 0}, 'type': 'Point', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{[]interface{}{}, 0}, "type": "Point"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // geo/geojson.yaml line #14 /* err('ReqlQueryLogicError', 'Expected type ARRAY but found BOOL.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type ARRAY but found BOOL.") /* r.geojson({'coordinates':true, 'type':'Point'}) */ suite.T().Log("About to run line #14: r.GeoJSON(map[interface{}]interface{}{'coordinates': true, 'type': 'Point', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": true, "type": "Point"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // geo/geojson.yaml line #16 /* err('ReqlNonExistenceError', 'No attribute `coordinates` in object:', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `coordinates` in object:") /* r.geojson({'type':'Point'}) */ suite.T().Log("About to run line #16: r.GeoJSON(map[interface{}]interface{}{'type': 'Point', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"type": "Point"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // geo/geojson.yaml line #18 /* err('ReqlNonExistenceError', 'No attribute `type` in object:', [0]) */ var expected_ Err = err("ReqlNonExistenceError", "No attribute `type` in object:") /* r.geojson({'coordinates':[0, 0]}) */ suite.T().Log("About to run line #18: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{0, 0}, })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{0, 0}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // geo/geojson.yaml line #20 /* err('ReqlQueryLogicError', 'Unrecognized GeoJSON type `foo`.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Unrecognized GeoJSON type `foo`.") /* r.geojson({'coordinates':[0, 0], 'type':'foo'}) */ suite.T().Log("About to run line #20: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{0, 0}, 'type': 'foo', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{0, 0}, "type": "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // geo/geojson.yaml line #22 /* err('ReqlQueryLogicError', 'Unrecognized field `foo` found in geometry object.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Unrecognized field `foo` found in geometry object.") /* r.geojson({'coordinates':[0, 0], 'type':'Point', 'foo':'wrong'}) */ suite.T().Log("About to run line #22: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{0, 0}, 'type': 'Point', 'foo': 'wrong', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{0, 0}, "type": "Point", "foo": "wrong"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // geo/geojson.yaml line #26 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[0, 0], 'type':'Point', 'crs':null}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, 0}, "type": "Point", "crs": nil} /* r.geojson({'coordinates':[0, 0], 'type':'Point', 'crs':null}) */ suite.T().Log("About to run line #26: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{0, 0}, 'type': 'Point', 'crs': nil, })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{0, 0}, "type": "Point", "crs": nil}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // geo/geojson.yaml line #30 /* err('ReqlQueryLogicError', 'GeoJSON type `MultiPoint` is not supported.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "GeoJSON type `MultiPoint` is not supported.") /* r.geojson({'coordinates':[0, 0], 'type':'MultiPoint'}) */ suite.T().Log("About to run line #30: r.GeoJSON(map[interface{}]interface{}{'coordinates': []interface{}{0, 0}, 'type': 'MultiPoint', })") runAndAssert(suite.Suite, expected_, r.GeoJSON(map[interface{}]interface{}{"coordinates": []interface{}{0, 0}, "type": "MultiPoint"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_geo_indexing_test.go000066400000000000000000001004431363464422500275040ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test ReQL interface to geo indexes func TestGeoIndexingSuite(t *testing.T) { suite.Run(t, new(GeoIndexingSuite)) } type GeoIndexingSuite struct { suite.Suite session *r.Session } func (suite *GeoIndexingSuite) SetupTest() { suite.T().Log("Setting up GeoIndexingSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_geo_index").Exec(suite.session) err = r.DBCreate("db_geo_index").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geo_index").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_geo_index").TableDrop("table_test_indexing").Exec(suite.session) err = r.DB("db_geo_index").TableCreate("table_test_indexing").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geo_index").Table("table_test_indexing").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *GeoIndexingSuite) TearDownSuite() { suite.T().Log("Tearing down GeoIndexingSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_geo_index").TableDrop("table_test_indexing").Exec(suite.session) r.DBDrop("db_geo_index").Exec(suite.session) suite.session.Close() } } func (suite *GeoIndexingSuite) TestCases() { suite.T().Log("Running GeoIndexingSuite: Test ReQL interface to geo indexes") table_test_indexing := r.DB("db_geo_index").Table("table_test_indexing") _ = table_test_indexing // Prevent any noused variable errors // geo/indexing.yaml line #4 // 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])}] 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}), }}") 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})}} _ = rows // Prevent any noused variable errors { // geo/indexing.yaml line #8 /* ({'deleted':0,'inserted':3,'skipped':0,'errors':0,'replaced':0,'unchanged':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "inserted": 3, "skipped": 0, "errors": 0, "replaced": 0, "unchanged": 0} /* table_test_indexing.insert(rows) */ suite.T().Log("About to run line #8: table_test_indexing.Insert(rows)") runAndAssert(suite.Suite, expected_, table_test_indexing.Insert(rows), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // geo/indexing.yaml line #12 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_indexing.index_create('g', geo=true) */ suite.T().Log("About to run line #12: table_test_indexing.IndexCreate('g').OptArgs(r.IndexCreateOpts{Geo: true, })") runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreate("g").OptArgs(r.IndexCreateOpts{Geo: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // geo/indexing.yaml line #16 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_indexing.index_create('m', geo=true, multi=true) */ suite.T().Log("About to run line #16: table_test_indexing.IndexCreate('m').OptArgs(r.IndexCreateOpts{Geo: true, Multi: true, })") runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreate("m").OptArgs(r.IndexCreateOpts{Geo: true, Multi: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // geo/indexing.yaml line #19 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_indexing.index_create('other') */ suite.T().Log("About to run line #19: table_test_indexing.IndexCreate('other')") runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreate("other"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // geo/indexing.yaml line #23 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_indexing.index_create('point_det', lambda x: r.point(x, x) ) */ suite.T().Log("About to run line #23: table_test_indexing.IndexCreateFunc('point_det', func(x r.Term) interface{} { return r.Point(x, x)})") runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreateFunc("point_det", func(x r.Term) interface{} { return r.Point(x, x) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // geo/indexing.yaml line #27 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_indexing.index_wait() */ suite.T().Log("About to run line #27: table_test_indexing.IndexWait()") runAndAssert(suite.Suite, expected_, table_test_indexing.IndexWait(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // geo/indexing.yaml line #32 /* err('ReqlQueryLogicError', 'Could not prove function deterministic. Index functions must be deterministic.') */ var expected_ Err = err("ReqlQueryLogicError", "Could not prove function deterministic. Index functions must be deterministic.") /* table_test_indexing.index_create('point_det', lambda x: r.line(x, x) ) */ suite.T().Log("About to run line #32: table_test_indexing.IndexCreateFunc('point_det', func(x r.Term) interface{} { return r.Line(x, x)})") runAndAssert(suite.Suite, expected_, table_test_indexing.IndexCreateFunc("point_det", func(x r.Term) interface{} { return r.Line(x, x) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } { // geo/indexing.yaml line #37 /* err('ReqlQueryLogicError', 'Index `other` is not a geospatial index. get_intersecting can only be used with a geospatial index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Index `other` is not a geospatial index. get_intersecting can only be used with a geospatial index.") /* table_test_indexing.get_intersecting(r.point(0,0), index='other').count() */ suite.T().Log("About to run line #37: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'other', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "other"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // geo/indexing.yaml line #41 /* err_regex('ReqlOpFailedError', 'Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]', [0]) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_indexing.get_intersecting(r.point(0,0), index='missing').count() */ suite.T().Log("About to run line #41: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'missing', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "missing"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #41") } { // geo/indexing.yaml line #44 /* err('ReqlQueryLogicError', 'get_intersecting requires an index argument.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "get_intersecting requires an index argument.") /* table_test_indexing.get_intersecting(r.point(0,0)).count() */ suite.T().Log("About to run line #44: table_test_indexing.GetIntersecting(r.Point(0, 0)).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // geo/indexing.yaml line #47 /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") /* table_test_indexing.get_all(0, index='g').count() */ suite.T().Log("About to run line #47: table_test_indexing.GetAll(0).OptArgs(r.GetAllOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetAll(0).OptArgs(r.GetAllOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // geo/indexing.yaml line #51 /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") /* table_test_indexing.between(0, 1, index='g').count() */ suite.T().Log("About to run line #51: table_test_indexing.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.Between(0, 1).OptArgs(r.BetweenOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // geo/indexing.yaml line #55 /* err('ReqlQueryLogicError', 'Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Index `g` is a geospatial index. Only get_nearest and get_intersecting can use a geospatial index.") /* table_test_indexing.order_by(index='g').count() */ suite.T().Log("About to run line #55: table_test_indexing.OrderBy().OptArgs(r.OrderByOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.OrderBy().OptArgs(r.OrderByOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // geo/indexing.yaml line #77 /* err('ReqlQueryLogicError', 'get_intersecting cannot use the primary index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "get_intersecting cannot use the primary index.") /* table_test_indexing.get_intersecting(r.point(0,0), index='id').count() */ suite.T().Log("About to run line #77: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #77") } { // geo/indexing.yaml line #82 /* 1 */ var expected_ int = 1 /* table_test_indexing.get_intersecting(r.point(0,0), index='g').count() */ suite.T().Log("About to run line #82: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // geo/indexing.yaml line #86 /* 1 */ var expected_ int = 1 /* table_test_indexing.get_intersecting(r.point(10,10), index='g').count() */ suite.T().Log("About to run line #86: table_test_indexing.GetIntersecting(r.Point(10, 10)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(10, 10)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // geo/indexing.yaml line #90 /* 1 */ var expected_ int = 1 /* table_test_indexing.get_intersecting(r.point(0.5,0.5), index='g').count() */ suite.T().Log("About to run line #90: table_test_indexing.GetIntersecting(r.Point(0.5, 0.5)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0.5, 0.5)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #90") } { // geo/indexing.yaml line #94 /* 0 */ var expected_ int = 0 /* table_test_indexing.get_intersecting(r.point(20,20), index='g').count() */ suite.T().Log("About to run line #94: table_test_indexing.GetIntersecting(r.Point(20, 20)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(20, 20)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #94") } { // geo/indexing.yaml line #98 /* 2 */ var expected_ int = 2 /* table_test_indexing.get_intersecting(r.polygon([0,0], [1,0], [1,1], [0,1]), index='g').count() */ 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()") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #98") } { // geo/indexing.yaml line #102 /* 3 */ var expected_ int = 3 /* table_test_indexing.get_intersecting(r.line([0,0], [10,10]), index='g').count() */ 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()") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } { // geo/indexing.yaml line #106 /* ("SELECTION") */ var expected_ string = "SELECTION" /* table_test_indexing.get_intersecting(r.point(0,0), index='g').type_of() */ suite.T().Log("About to run line #106: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } { // geo/indexing.yaml line #110 /* ("SELECTION") */ var expected_ string = "SELECTION" /* table_test_indexing.get_intersecting(r.point(0,0), index='g').filter(true).type_of() */ suite.T().Log("About to run line #110: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'g', }).Filter(true).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "g"}).Filter(true).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // geo/indexing.yaml line #114 /* ("STREAM") */ var expected_ string = "STREAM" /* table_test_indexing.get_intersecting(r.point(0,0), index='g').map(r.row).type_of() */ 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()") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #114") } { // geo/indexing.yaml line #119 /* 1 */ var expected_ int = 1 /* table_test_indexing.get_intersecting(r.point(0,0), index='m').count() */ suite.T().Log("About to run line #119: table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(0, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #119") } { // geo/indexing.yaml line #123 /* 1 */ var expected_ int = 1 /* table_test_indexing.get_intersecting(r.point(1,0), index='m').count() */ suite.T().Log("About to run line #123: table_test_indexing.GetIntersecting(r.Point(1, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(1, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } { // geo/indexing.yaml line #127 /* 1 */ var expected_ int = 1 /* table_test_indexing.get_intersecting(r.point(2,0), index='m').count() */ suite.T().Log("About to run line #127: table_test_indexing.GetIntersecting(r.Point(2, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(2, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #127") } { // geo/indexing.yaml line #131 /* 0 */ var expected_ int = 0 /* table_test_indexing.get_intersecting(r.point(3,0), index='m').count() */ suite.T().Log("About to run line #131: table_test_indexing.GetIntersecting(r.Point(3, 0)).OptArgs(r.GetIntersectingOpts{Index: 'm', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetIntersecting(r.Point(3, 0)).OptArgs(r.GetIntersectingOpts{Index: "m"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #131") } { // geo/indexing.yaml line #136 /* 2 */ var expected_ int = 2 /* table_test_indexing.get_intersecting(r.polygon([0,0], [0,1], [1,1], [1,0]), index='m').count() */ 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()") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #136") } { // geo/indexing.yaml line #142 /* err('ReqlQueryLogicError', 'Index `other` is not a geospatial index. get_nearest can only be used with a geospatial index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Index `other` is not a geospatial index. get_nearest can only be used with a geospatial index.") /* table_test_indexing.get_nearest(r.point(0,0), index='other') */ suite.T().Log("About to run line #142: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'other', })") runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "other"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #142") } { // geo/indexing.yaml line #146 /* err_regex('ReqlOpFailedError', 'Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]', [0]) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `missing` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_indexing.get_nearest(r.point(0,0), index='missing') */ suite.T().Log("About to run line #146: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'missing', })") runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "missing"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #146") } { // geo/indexing.yaml line #149 /* err('ReqlQueryLogicError', 'get_nearest requires an index argument.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "get_nearest requires an index argument.") /* table_test_indexing.get_nearest(r.point(0,0)) */ suite.T().Log("About to run line #149: table_test_indexing.GetNearest(r.Point(0, 0))") runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #149") } { // geo/indexing.yaml line #170 /* err('ReqlQueryLogicError', 'get_nearest cannot use the primary index.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "get_nearest cannot use the primary index.") /* table_test_indexing.get_nearest(r.point(0,0), index='id').count() */ suite.T().Log("About to run line #170: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #170") } { // geo/indexing.yaml line #175 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}}]) */ 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}}} /* table_test_indexing.get_nearest(r.point(0,0), index='g').pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #175") } { // geo/indexing.yaml line #179 /* ([{'dist':0,'doc':{'id':2}},{'dist':0.11130264976984369,'doc':{'id':1}}]) */ 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}}} /* table_test_indexing.get_nearest(r.point(-0.000001,1), index='g').pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #179") } { // geo/indexing.yaml line #183 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}},{'dist':1565109.0992178896,'doc':{'id':0}}]) */ 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}}} /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1565110).pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #183") } { // geo/indexing.yaml line #187 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.055659745396754216,'doc':{'id':2}}]) */ 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}}} /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1565110, max_results=2).pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #187") } { // geo/indexing.yaml line #191 /* 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]) */ 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.)") /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=10000000).pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #191") } { // geo/indexing.yaml line #195 /* ([{'dist':0,'doc':{'id':1}},{'dist':0.00005565974539675422,'doc':{'id':2}},{'dist':1565.1090992178897,'doc':{'id':0}}]) */ 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}}} /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1566, unit='km').pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #195") } { // geo/indexing.yaml line #198 /* ([{'dist':0, 'doc':{'id':1}}, {'dist':8.726646259990191e-09, 'doc':{'id':2}}, {'dist':0.24619691677893205, 'doc':{'id':0}}]) */ 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}}} /* table_test_indexing.get_nearest(r.point(0,0), index='g', max_dist=1, geo_system='unit_sphere').pluck('dist', {'doc':'id'}) */ 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', })") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #198") } { // geo/indexing.yaml line #202 /* ("ARRAY") */ var expected_ string = "ARRAY" /* table_test_indexing.get_nearest(r.point(0,0), index='g').type_of() */ suite.T().Log("About to run line #202: table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: 'g', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_indexing.GetNearest(r.Point(0, 0)).OptArgs(r.GetNearestOpts{Index: "g"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #202") } { // geo/indexing.yaml line #206 /* ("ARRAY") */ var expected_ string = "ARRAY" /* table_test_indexing.get_nearest(r.point(0,0), index='g').map(r.row).type_of() */ 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()") 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{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #206") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_geo_intersection_inclusion_test.go000066400000000000000000001200121363464422500324620ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test intersects and includes semantics func TestGeoIntersectionInclusionSuite(t *testing.T) { suite.Run(t, new(GeoIntersectionInclusionSuite)) } type GeoIntersectionInclusionSuite struct { suite.Suite session *r.Session } func (suite *GeoIntersectionInclusionSuite) SetupTest() { suite.T().Log("Setting up GeoIntersectionInclusionSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_geoint").Exec(suite.session) err = r.DBCreate("db_geoint").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geoint").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *GeoIntersectionInclusionSuite) TearDownSuite() { suite.T().Log("Tearing down GeoIntersectionInclusionSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_geoint").Exec(suite.session) suite.session.Close() } } func (suite *GeoIntersectionInclusionSuite) TestCases() { suite.T().Log("Running GeoIntersectionInclusionSuite: Test intersects and includes semantics") { // geo/intersection_inclusion.yaml line #4 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(1.5,1.5)) */ suite.T().Log("About to run line #4: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(1.5, 1.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(1.5, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // geo/intersection_inclusion.yaml line #6 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(2.5,2.5)) */ suite.T().Log("About to run line #6: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(2.5, 2.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(2.5, 2.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // geo/intersection_inclusion.yaml line #8 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.5,1.5)) */ suite.T().Log("About to run line #8: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.5, 1.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.5, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // geo/intersection_inclusion.yaml line #10 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.05,1.05)) */ suite.T().Log("About to run line #10: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.05, 1.05))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.05, 1.05)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // geo/intersection_inclusion.yaml line #13 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(2,2)) */ suite.T().Log("About to run line #13: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(2, 2))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(2, 2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // geo/intersection_inclusion.yaml line #15 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.point(2,1.5)) */ suite.T().Log("About to run line #15: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(2, 1.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Point(2, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // geo/intersection_inclusion.yaml line #17 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([1.5,1.5], [2,2])) */ suite.T().Log("About to run line #17: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } { // geo/intersection_inclusion.yaml line #19 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([1.5,1.5], [2,1.5])) */ suite.T().Log("About to run line #19: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 1.5}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 1.5})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // geo/intersection_inclusion.yaml line #22 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.1,1.1)) */ suite.T().Log("About to run line #22: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.1, 1.1))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.1, 1.1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // geo/intersection_inclusion.yaml line #24 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.point(1.5,1.1)) */ suite.T().Log("About to run line #24: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.5, 1.1))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Point(1.5, 1.1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // geo/intersection_inclusion.yaml line #27 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([2,2], [3,3])) */ suite.T().Log("About to run line #27: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{2, 2}, []interface{}{3, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{2, 2}, []interface{}{3, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // geo/intersection_inclusion.yaml line #29 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([2,1.5], [3,3])) */ suite.T().Log("About to run line #29: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{2, 1.5}, []interface{}{3, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{2, 1.5}, []interface{}{3, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // geo/intersection_inclusion.yaml line #31 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.line([1.5,1.5], [3,3])) */ suite.T().Log("About to run line #31: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{1.5, 1.5}, []interface{}{3, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Line([]interface{}{1.5, 1.5}, []interface{}{3, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // geo/intersection_inclusion.yaml line #33 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8])) */ suite.T().Log("About to run line #33: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // geo/intersection_inclusion.yaml line #35 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([1.5,1.5], [2.5,1.5], [2.5,2.5], [1.5,2.5])) */ suite.T().Log("About to run line #35: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{1.5, 1.5}, []interface{}{2.5, 1.5}, []interface{}{2.5, 2.5}, []interface{}{1.5, 2.5}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{1.5, 1.5}, []interface{}{2.5, 1.5}, []interface{}{2.5, 2.5}, []interface{}{1.5, 2.5})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // geo/intersection_inclusion.yaml line #37 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8])) */ suite.T().Log("About to run line #37: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // geo/intersection_inclusion.yaml line #39 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).intersects(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])) */ suite.T().Log("About to run line #39: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Intersects(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // geo/intersection_inclusion.yaml line #42 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([2,1.1], [3,1.1], [3,1.9], [2,1.9])) */ suite.T().Log("About to run line #42: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{2, 1.1}, []interface{}{3, 1.1}, []interface{}{3, 1.9}, []interface{}{2, 1.9}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{2, 1.1}, []interface{}{3, 1.1}, []interface{}{3, 1.9}, []interface{}{2, 1.9})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // geo/intersection_inclusion.yaml line #44 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).intersects(r.polygon([2,2], [3,2], [3,3], [2,3])) */ suite.T().Log("About to run line #44: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{2, 2}, []interface{}{3, 2}, []interface{}{3, 3}, []interface{}{2, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Intersects(r.Polygon([]interface{}{2, 2}, []interface{}{3, 2}, []interface{}{3, 3}, []interface{}{2, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // geo/intersection_inclusion.yaml line #46 /* false */ var expected_ bool = false /* r.point(1,1).intersects(r.point(1.5,1.5)) */ suite.T().Log("About to run line #46: r.Point(1, 1).Intersects(r.Point(1.5, 1.5))") runAndAssert(suite.Suite, expected_, r.Point(1, 1).Intersects(r.Point(1.5, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // geo/intersection_inclusion.yaml line #48 /* true */ var expected_ bool = true /* r.point(1,1).intersects(r.point(1,1)) */ suite.T().Log("About to run line #48: r.Point(1, 1).Intersects(r.Point(1, 1))") runAndAssert(suite.Suite, expected_, r.Point(1, 1).Intersects(r.Point(1, 1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #48") } { // geo/intersection_inclusion.yaml line #50 /* true */ var expected_ bool = true /* r.line([1,1], [2,1]).intersects(r.point(1,1)) */ suite.T().Log("About to run line #50: r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Point(1, 1))") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Point(1, 1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // geo/intersection_inclusion.yaml line #55 /* true */ var expected_ bool = true /* r.line([1,1], [1,2]).intersects(r.point(1,1.8)) */ suite.T().Log("About to run line #55: r.Line([]interface{}{1, 1}, []interface{}{1, 2}).Intersects(r.Point(1, 1.8))") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 1}, []interface{}{1, 2}).Intersects(r.Point(1, 1.8)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // geo/intersection_inclusion.yaml line #57 /* true */ var expected_ bool = true /* r.line([1,0], [2,0]).intersects(r.point(1.8,0)) */ suite.T().Log("About to run line #57: r.Line([]interface{}{1, 0}, []interface{}{2, 0}).Intersects(r.Point(1.8, 0))") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 0}, []interface{}{2, 0}).Intersects(r.Point(1.8, 0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // geo/intersection_inclusion.yaml line #59 /* false */ var expected_ bool = false /* r.line([1,1], [2,1]).intersects(r.point(1.5,1.5)) */ suite.T().Log("About to run line #59: r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Point(1.5, 1.5))") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Point(1.5, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #59") } { // geo/intersection_inclusion.yaml line #61 /* true */ var expected_ bool = true /* r.line([1,1], [2,1]).intersects(r.line([2,1], [3,1])) */ suite.T().Log("About to run line #61: r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Line([]interface{}{2, 1}, []interface{}{3, 1}))") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{1, 1}, []interface{}{2, 1}).Intersects(r.Line([]interface{}{2, 1}, []interface{}{3, 1})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #61") } { // geo/intersection_inclusion.yaml line #64 /* 2 */ var expected_ int = 2 /* r.expr([r.point(1, 0), r.point(3,0), r.point(2, 0)]).intersects(r.line([0,0], [2, 0])).count() */ suite.T().Log("About to run line #64: r.Expr([]interface{}{r.Point(1, 0), r.Point(3, 0), r.Point(2, 0)}).Intersects(r.Line([]interface{}{0, 0}, []interface{}{2, 0})).Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Point(1, 0), r.Point(3, 0), r.Point(2, 0)}).Intersects(r.Line([]interface{}{0, 0}, []interface{}{2, 0})).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #64") } { // geo/intersection_inclusion.yaml line #68 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(1.5,1.5)) */ suite.T().Log("About to run line #68: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(1.5, 1.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(1.5, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #68") } { // geo/intersection_inclusion.yaml line #70 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2.5,2.5)) */ suite.T().Log("About to run line #70: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2.5, 2.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2.5, 2.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // geo/intersection_inclusion.yaml line #72 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.5,1.5)) */ suite.T().Log("About to run line #72: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.5, 1.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.5, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #72") } { // geo/intersection_inclusion.yaml line #74 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.05,1.05)) */ suite.T().Log("About to run line #74: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.05, 1.05))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.05, 1.05)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } { // geo/intersection_inclusion.yaml line #76 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2,2)) */ suite.T().Log("About to run line #76: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2, 2))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2, 2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #76") } { // geo/intersection_inclusion.yaml line #78 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.point(2,1.5)) */ suite.T().Log("About to run line #78: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2, 1.5))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Point(2, 1.5)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #78") } { // geo/intersection_inclusion.yaml line #80 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([1.5,1.5], [2,2])) */ suite.T().Log("About to run line #80: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #80") } { // geo/intersection_inclusion.yaml line #82 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([1.5,1.5], [2,1.5])) */ suite.T().Log("About to run line #82: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 1.5}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{1.5, 1.5}, []interface{}{2, 1.5})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // geo/intersection_inclusion.yaml line #84 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.1,1.1)) */ suite.T().Log("About to run line #84: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.1, 1.1))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.1, 1.1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // geo/intersection_inclusion.yaml line #86 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.point(1.5,1.1)) */ suite.T().Log("About to run line #86: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.5, 1.1))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Point(1.5, 1.1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // geo/intersection_inclusion.yaml line #88 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([2,2], [3,3])) */ suite.T().Log("About to run line #88: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{2, 2}, []interface{}{3, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{2, 2}, []interface{}{3, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // geo/intersection_inclusion.yaml line #90 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([2,1.5], [2,2])) */ suite.T().Log("About to run line #90: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{2, 1.5}, []interface{}{2, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{2, 1.5}, []interface{}{2, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #90") } { // geo/intersection_inclusion.yaml line #92 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([2,1], [2,2])) */ suite.T().Log("About to run line #92: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{2, 1}, []interface{}{2, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{2, 1}, []interface{}{2, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } { // geo/intersection_inclusion.yaml line #94 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.line([1.5,1.5], [3,3])) */ suite.T().Log("About to run line #94: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{1.5, 1.5}, []interface{}{3, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Line([]interface{}{1.5, 1.5}, []interface{}{3, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #94") } { // geo/intersection_inclusion.yaml line #96 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1,1], [2,1], [2,2], [1,2])) */ suite.T().Log("About to run line #96: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #96") } { // geo/intersection_inclusion.yaml line #98 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8])) */ suite.T().Log("About to run line #98: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #98") } { // geo/intersection_inclusion.yaml line #100 /* true */ var expected_ bool = true /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1.5,1.5], [2,1.5], [2,2], [1.5,2])) */ suite.T().Log("About to run line #100: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1.5, 1.5}, []interface{}{2, 1.5}, []interface{}{2, 2}, []interface{}{1.5, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1.5, 1.5}, []interface{}{2, 1.5}, []interface{}{2, 2}, []interface{}{1.5, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // geo/intersection_inclusion.yaml line #102 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([1.5,1.5], [2.5,1.5], [2.5,2.5], [1.5,2.5])) */ suite.T().Log("About to run line #102: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1.5, 1.5}, []interface{}{2.5, 1.5}, []interface{}{2.5, 2.5}, []interface{}{1.5, 2.5}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{1.5, 1.5}, []interface{}{2.5, 1.5}, []interface{}{2.5, 2.5}, []interface{}{1.5, 2.5})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } { // geo/intersection_inclusion.yaml line #104 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.polygon([1.2,1.2], [1.8,1.2], [1.8,1.8], [1.2,1.8])) */ suite.T().Log("About to run line #104: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Polygon([]interface{}{1.2, 1.2}, []interface{}{1.8, 1.2}, []interface{}{1.8, 1.8}, []interface{}{1.2, 1.8})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #104") } { // geo/intersection_inclusion.yaml line #106 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).polygon_sub(r.polygon([1.1,1.1], [1.9,1.1], [1.9,1.9], [1.1,1.9])).includes(r.polygon([1.1,1.1], [2,1.1], [2,2], [1.1,2])) */ suite.T().Log("About to run line #106: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{2, 1.1}, []interface{}{2, 2}, []interface{}{1.1, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).PolygonSub(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{1.9, 1.1}, []interface{}{1.9, 1.9}, []interface{}{1.1, 1.9})).Includes(r.Polygon([]interface{}{1.1, 1.1}, []interface{}{2, 1.1}, []interface{}{2, 2}, []interface{}{1.1, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } { // geo/intersection_inclusion.yaml line #108 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([2,1.1], [3,1.1], [3,1.9], [2,1.9])) */ suite.T().Log("About to run line #108: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{2, 1.1}, []interface{}{3, 1.1}, []interface{}{3, 1.9}, []interface{}{2, 1.9}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{2, 1.1}, []interface{}{3, 1.1}, []interface{}{3, 1.9}, []interface{}{2, 1.9})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // geo/intersection_inclusion.yaml line #110 /* false */ var expected_ bool = false /* r.polygon([1,1], [2,1], [2,2], [1,2]).includes(r.polygon([2,2], [3,2], [3,3], [2,3])) */ suite.T().Log("About to run line #110: r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{2, 2}, []interface{}{3, 2}, []interface{}{3, 3}, []interface{}{2, 3}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{1, 1}, []interface{}{2, 1}, []interface{}{2, 2}, []interface{}{1, 2}).Includes(r.Polygon([]interface{}{2, 2}, []interface{}{3, 2}, []interface{}{3, 3}, []interface{}{2, 3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // geo/intersection_inclusion.yaml line #113 /* 1 */ var expected_ int = 1 /* r.expr([r.polygon([0,0], [1,1], [1,0]), r.polygon([0,1], [1,2], [1,1])]).includes(r.point(0,0)).count() */ suite.T().Log("About to run line #113: r.Expr([]interface{}{r.Polygon([]interface{}{0, 0}, []interface{}{1, 1}, []interface{}{1, 0}), r.Polygon([]interface{}{0, 1}, []interface{}{1, 2}, []interface{}{1, 1})}).Includes(r.Point(0, 0)).Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Polygon([]interface{}{0, 0}, []interface{}{1, 1}, []interface{}{1, 0}), r.Polygon([]interface{}{0, 1}, []interface{}{1, 2}, []interface{}{1, 1})}).Includes(r.Point(0, 0)).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #113") } { // geo/intersection_inclusion.yaml line #116 /* err('ReqlQueryLogicError', 'Expected geometry of type `Polygon` but found `Point`.') */ var expected_ Err = err("ReqlQueryLogicError", "Expected geometry of type `Polygon` but found `Point`.") /* r.point(0,0).includes(r.point(0,0)) */ suite.T().Log("About to run line #116: r.Point(0, 0).Includes(r.Point(0, 0))") runAndAssert(suite.Suite, expected_, r.Point(0, 0).Includes(r.Point(0, 0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #116") } { // geo/intersection_inclusion.yaml line #118 /* err('ReqlQueryLogicError', 'Expected geometry of type `Polygon` but found `LineString`.') */ var expected_ Err = err("ReqlQueryLogicError", "Expected geometry of type `Polygon` but found `LineString`.") /* r.line([0,0], [0,1]).includes(r.point(0,0)) */ suite.T().Log("About to run line #118: r.Line([]interface{}{0, 0}, []interface{}{0, 1}).Includes(r.Point(0, 0))") runAndAssert(suite.Suite, expected_, r.Line([]interface{}{0, 0}, []interface{}{0, 1}).Includes(r.Point(0, 0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_geo_operations_test.go000066400000000000000000000633751363464422500300760ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test basic geometry operators func TestGeoOperationsSuite(t *testing.T) { suite.Run(t, new(GeoOperationsSuite)) } type GeoOperationsSuite struct { suite.Suite session *r.Session } func (suite *GeoOperationsSuite) SetupTest() { suite.T().Log("Setting up GeoOperationsSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_geoop").Exec(suite.session) err = r.DBCreate("db_geoop").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geoop").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *GeoOperationsSuite) TearDownSuite() { suite.T().Log("Tearing down GeoOperationsSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_geoop").Exec(suite.session) suite.session.Close() } } func (suite *GeoOperationsSuite) TestCases() { suite.T().Log("Running GeoOperationsSuite: Test basic geometry operators") { // geo/operations.yaml line #5 /* ("89011.26253835332") */ var expected_ string = "89011.26253835332" /* r.distance(r.point(-122, 37), r.point(-123, 37)).coerce_to('STRING') */ suite.T().Log("About to run line #5: r.Distance(r.Point(-122, 37), r.Point(-123, 37)).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(-122, 37), r.Point(-123, 37)).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // geo/operations.yaml line #7 /* ("110968.30443995494") */ var expected_ string = "110968.30443995494" /* r.distance(r.point(-122, 37), r.point(-122, 36)).coerce_to('STRING') */ suite.T().Log("About to run line #7: r.Distance(r.Point(-122, 37), r.Point(-122, 36)).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(-122, 37), r.Point(-122, 36)).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // geo/operations.yaml line #9 /* true */ var expected_ bool = true /* r.distance(r.point(-122, 37), r.point(-122, 36)).eq(r.distance(r.point(-122, 36), r.point(-122, 37))) */ suite.T().Log("About to run line #9: r.Distance(r.Point(-122, 37), r.Point(-122, 36)).Eq(r.Distance(r.Point(-122, 36), r.Point(-122, 37)))") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(-122, 37), r.Point(-122, 36)).Eq(r.Distance(r.Point(-122, 36), r.Point(-122, 37))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // geo/operations.yaml line #11 /* ("89011.26253835332") */ var expected_ string = "89011.26253835332" /* r.point(-122, 37).distance(r.point(-123, 37)).coerce_to('STRING') */ suite.T().Log("About to run line #11: r.Point(-122, 37).Distance(r.Point(-123, 37)).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Point(-122, 37).Distance(r.Point(-123, 37)).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } // geo/operations.yaml line #13 // someDist = r.distance(r.point(-122, 37), r.point(-123, 37)) suite.T().Log("Possibly executing: var someDist r.Term = r.Distance(r.Point(-122, 37), r.Point(-123, 37))") someDist := r.Distance(r.Point(-122, 37), r.Point(-123, 37)) _ = someDist // Prevent any noused variable errors { // geo/operations.yaml line #15 /* true */ var expected_ bool = true /* someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='m')) */ suite.T().Log("About to run line #15: someDist.Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: 'm', }))") runAndAssert(suite.Suite, expected_, someDist.Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: "m"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // geo/operations.yaml line #19 /* true */ var expected_ bool = true /* someDist.mul(1.0/1000.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='km')) */ suite.T().Log("About to run line #19: someDist.Mul(r.Div(1.0, 1000.0)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: 'km', }))") runAndAssert(suite.Suite, expected_, someDist.Mul(r.Div(1.0, 1000.0)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: "km"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // geo/operations.yaml line #23 /* true */ var expected_ bool = true /* someDist.mul(1.0/1609.344).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='mi')) */ suite.T().Log("About to run line #23: someDist.Mul(r.Div(1.0, 1609.344)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: 'mi', }))") runAndAssert(suite.Suite, expected_, someDist.Mul(r.Div(1.0, 1609.344)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: "mi"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // geo/operations.yaml line #27 /* true */ var expected_ bool = true /* someDist.mul(1.0/0.3048).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='ft')) */ suite.T().Log("About to run line #27: someDist.Mul(r.Div(1.0, 0.3048)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: 'ft', }))") runAndAssert(suite.Suite, expected_, someDist.Mul(r.Div(1.0, 0.3048)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: "ft"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // geo/operations.yaml line #31 /* true */ var expected_ bool = true /* someDist.mul(1.0/1852.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='nm')) */ suite.T().Log("About to run line #31: someDist.Mul(r.Div(1.0, 1852.0)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: 'nm', }))") runAndAssert(suite.Suite, expected_, someDist.Mul(r.Div(1.0, 1852.0)).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{Unit: "nm"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // geo/operations.yaml line #35 /* true */ var expected_ bool = true /* someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), geo_system='WGS84')) */ suite.T().Log("About to run line #35: someDist.Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{GeoSystem: 'WGS84', }))") runAndAssert(suite.Suite, expected_, someDist.Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{GeoSystem: "WGS84"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // geo/operations.yaml line #40 /* true */ var expected_ bool = true /* someDist.div(10).eq(r.distance(r.point(-122, 37), r.point(-123, 37), geo_system={'a':637813.7, 'f':(1.0/298.257223563)})) */ suite.T().Log("About to run line #40: someDist.Div(10).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{GeoSystem: map[interface{}]interface{}{'a': 637813.7, 'f': r.Div(1.0, 298.257223563), }, }))") runAndAssert(suite.Suite, expected_, someDist.Div(10).Eq(r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{GeoSystem: map[interface{}]interface{}{"a": 637813.7, "f": r.Div(1.0, 298.257223563)}})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // geo/operations.yaml line #43 /* ("0.01393875509649327") */ var expected_ string = "0.01393875509649327" /* r.distance(r.point(-122, 37), r.point(-123, 37), geo_system='unit_sphere').coerce_to('STRING') */ suite.T().Log("About to run line #43: r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{GeoSystem: 'unit_sphere', }).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(-122, 37), r.Point(-123, 37)).OptArgs(r.DistanceOpts{GeoSystem: "unit_sphere"}).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // geo/operations.yaml line #47 /* ("0") */ var expected_ string = "0" /* r.distance(r.point(0, 0), r.point(0, 0)).coerce_to('STRING') */ suite.T().Log("About to run line #47: r.Distance(r.Point(0, 0), r.Point(0, 0)).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Point(0, 0)).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // geo/operations.yaml line #50 /* ("40007862.917250897") */ var expected_ string = "40007862.917250897" /* r.distance(r.point(0, 0), r.point(180, 0)).mul(2).coerce_to('STRING') */ suite.T().Log("About to run line #50: r.Distance(r.Point(0, 0), r.Point(180, 0)).Mul(2).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Point(180, 0)).Mul(2).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // geo/operations.yaml line #52 /* ("40007862.917250897") */ var expected_ string = "40007862.917250897" /* r.distance(r.point(0, -90), r.point(0, 90)).mul(2).coerce_to('STRING') */ suite.T().Log("About to run line #52: r.Distance(r.Point(0, -90), r.Point(0, 90)).Mul(2).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, -90), r.Point(0, 90)).Mul(2).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // geo/operations.yaml line #54 /* ("0") */ var expected_ string = "0" /* r.distance(r.point(0, 0), r.line([0,0], [0,1])).coerce_to('STRING') */ suite.T().Log("About to run line #54: r.Distance(r.Point(0, 0), r.Line([]interface{}{0, 0}, []interface{}{0, 1})).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Line([]interface{}{0, 0}, []interface{}{0, 1})).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // geo/operations.yaml line #56 /* ("0") */ var expected_ string = "0" /* r.distance(r.line([0,0], [0,1]), r.point(0, 0)).coerce_to('STRING') */ suite.T().Log("About to run line #56: r.Distance(r.Line([]interface{}{0, 0}, []interface{}{0, 1}), r.Point(0, 0)).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Line([]interface{}{0, 0}, []interface{}{0, 1}), r.Point(0, 0)).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #56") } { // geo/operations.yaml line #58 /* true */ var expected_ bool = true /* r.distance(r.point(0, 0), r.line([0.1,0], [1,0])).eq(r.distance(r.point(0, 0), r.point(0.1, 0))) */ suite.T().Log("About to run line #58: r.Distance(r.Point(0, 0), r.Line([]interface{}{0.1, 0}, []interface{}{1, 0})).Eq(r.Distance(r.Point(0, 0), r.Point(0.1, 0)))") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Line([]interface{}{0.1, 0}, []interface{}{1, 0})).Eq(r.Distance(r.Point(0, 0), r.Point(0.1, 0))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // geo/operations.yaml line #60 /* ("492471.4990055255") */ var expected_ string = "492471.4990055255" /* r.distance(r.point(0, 0), r.line([5,-1], [4,2])).coerce_to('STRING') */ suite.T().Log("About to run line #60: r.Distance(r.Point(0, 0), r.Line([]interface{}{5, -1}, []interface{}{4, 2})).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Line([]interface{}{5, -1}, []interface{}{4, 2})).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // geo/operations.yaml line #62 /* ("492471.4990055255") */ var expected_ string = "492471.4990055255" /* r.distance(r.point(0, 0), r.polygon([5,-1], [4,2], [10,10])).coerce_to('STRING') */ suite.T().Log("About to run line #62: r.Distance(r.Point(0, 0), r.Polygon([]interface{}{5, -1}, []interface{}{4, 2}, []interface{}{10, 10})).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Polygon([]interface{}{5, -1}, []interface{}{4, 2}, []interface{}{10, 10})).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // geo/operations.yaml line #64 /* ("0") */ var expected_ string = "0" /* r.distance(r.point(0, 0), r.polygon([0,-1], [0,1], [10,10])).coerce_to('STRING') */ suite.T().Log("About to run line #64: r.Distance(r.Point(0, 0), r.Polygon([]interface{}{0, -1}, []interface{}{0, 1}, []interface{}{10, 10})).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0, 0), r.Polygon([]interface{}{0, -1}, []interface{}{0, 1}, []interface{}{10, 10})).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #64") } { // geo/operations.yaml line #66 /* ("0") */ var expected_ string = "0" /* r.distance(r.point(0.5, 0.5), r.polygon([0,-1], [0,1], [10,10])).coerce_to('STRING') */ suite.T().Log("About to run line #66: r.Distance(r.Point(0.5, 0.5), r.Polygon([]interface{}{0, -1}, []interface{}{0, 1}, []interface{}{10, 10})).CoerceTo('STRING')") runAndAssert(suite.Suite, expected_, r.Distance(r.Point(0.5, 0.5), r.Polygon([]interface{}{0, -1}, []interface{}{0, 1}, []interface{}{10, 10})).CoerceTo("STRING"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } { // geo/operations.yaml line #71 /* false */ var expected_ bool = false /* r.circle([0,0], 1, fill=false).eq(r.circle([0,0], 1, fill=true)) */ suite.T().Log("About to run line #71: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: false, }).Eq(r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: true, }))") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: false}).Eq(r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: true})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // geo/operations.yaml line #75 /* true */ var expected_ bool = true /* r.circle([0,0], 1, fill=false).fill().eq(r.circle([0,0], 1, fill=true)) */ suite.T().Log("About to run line #75: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: false, }).Fill().Eq(r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: true, }))") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: false}).Fill().Eq(r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{Fill: true})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } { // geo/operations.yaml line #80 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0],[1,0],[1,1],[0,1],[0,0]],[[0.1,0.1],[0.9,0.1],[0.9,0.9],[0.1,0.9],[0.1,0.1]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}, []interface{}{0, 0}}, []interface{}{[]interface{}{0.1, 0.1}, []interface{}{0.9, 0.1}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9}, []interface{}{0.1, 0.1}}}, "type": "Polygon"} /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0.1,0.1], [0.9,0.1], [0.9,0.9], [0.1,0.9])) */ suite.T().Log("About to run line #80: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0.1, 0.1}, []interface{}{0.9, 0.1}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0.1, 0.1}, []interface{}{0.9, 0.1}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #80") } { // geo/operations.yaml line #82 /* err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "The second argument to `polygon_sub` is not contained in the first one.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0.1,0.9], [0.9,0.0], [0.9,0.9], [0.1,0.9])) */ suite.T().Log("About to run line #82: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0.1, 0.9}, []interface{}{0.9, 0.0}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0.1, 0.9}, []interface{}{0.9, 0.0}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // geo/operations.yaml line #84 /* err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "The second argument to `polygon_sub` is not contained in the first one.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,0], [2,0], [2,2], [0,2])) */ suite.T().Log("About to run line #84: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, 0}, []interface{}{2, 0}, []interface{}{2, 2}, []interface{}{0, 2}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, 0}, []interface{}{2, 0}, []interface{}{2, 2}, []interface{}{0, 2})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // geo/operations.yaml line #86 /* err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "The second argument to `polygon_sub` is not contained in the first one.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,-2], [1,-2], [-1,1], [0,-1])) */ suite.T().Log("About to run line #86: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, -2}, []interface{}{1, -2}, []interface{}{-1, 1}, []interface{}{0, -1}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, -2}, []interface{}{1, -2}, []interface{}{-1, 1}, []interface{}{0, -1})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // geo/operations.yaml line #88 /* err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "The second argument to `polygon_sub` is not contained in the first one.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,-1], [1,-1], [1,0], [0,0])) */ suite.T().Log("About to run line #88: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, -1}, []interface{}{1, -1}, []interface{}{1, 0}, []interface{}{0, 0}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, -1}, []interface{}{1, -1}, []interface{}{1, 0}, []interface{}{0, 0})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // geo/operations.yaml line #90 /* err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "The second argument to `polygon_sub` is not contained in the first one.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0.1,-1], [0.9,-1], [0.9,0.5], [0.1,0.5])) */ suite.T().Log("About to run line #90: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0.1, -1}, []interface{}{0.9, -1}, []interface{}{0.9, 0.5}, []interface{}{0.1, 0.5}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0.1, -1}, []interface{}{0.9, -1}, []interface{}{0.9, 0.5}, []interface{}{0.1, 0.5})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #90") } { // geo/operations.yaml line #92 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0],[1,0],[1,1],[0,1],[0,0]],[[0,0],[0.1,0.9],[0.9,0.9],[0.9,0.1],[0,0]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}, []interface{}{0, 0}}, []interface{}{[]interface{}{0, 0}, []interface{}{0.1, 0.9}, []interface{}{0.9, 0.9}, []interface{}{0.9, 0.1}, []interface{}{0, 0}}}, "type": "Polygon"} /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,0],[0.1,0.9],[0.9,0.9],[0.9,0.1])) */ suite.T().Log("About to run line #92: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, 0}, []interface{}{0.1, 0.9}, []interface{}{0.9, 0.9}, []interface{}{0.9, 0.1}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, 0}, []interface{}{0.1, 0.9}, []interface{}{0.9, 0.9}, []interface{}{0.9, 0.1})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } { // geo/operations.yaml line #94 /* err('ReqlQueryLogicError', 'Expected a Polygon with only an outer shell. This one has holes.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected a Polygon with only an outer shell. This one has holes.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,0],[0.1,0.9],[0.9,0.9],[0.9,0.1]).polygon_sub(r.polygon([0.2,0.2],[0.5,0.8],[0.8,0.2]))) */ suite.T().Log("About to run line #94: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, 0}, []interface{}{0.1, 0.9}, []interface{}{0.9, 0.9}, []interface{}{0.9, 0.1}).PolygonSub(r.Polygon([]interface{}{0.2, 0.2}, []interface{}{0.5, 0.8}, []interface{}{0.8, 0.2})))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Polygon([]interface{}{0, 0}, []interface{}{0.1, 0.9}, []interface{}{0.9, 0.9}, []interface{}{0.9, 0.1}).PolygonSub(r.Polygon([]interface{}{0.2, 0.2}, []interface{}{0.5, 0.8}, []interface{}{0.8, 0.2}))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #94") } { // geo/operations.yaml line #96 /* err('ReqlQueryLogicError', 'Expected a Polygon but found a LineString.', []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected a Polygon but found a LineString.") /* r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.line([0,0],[0.9,0.1],[0.9,0.9],[0.1,0.9])) */ suite.T().Log("About to run line #96: r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Line([]interface{}{0, 0}, []interface{}{0.9, 0.1}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9}))") runAndAssert(suite.Suite, expected_, r.Polygon([]interface{}{0, 0}, []interface{}{1, 0}, []interface{}{1, 1}, []interface{}{0, 1}).PolygonSub(r.Line([]interface{}{0, 0}, []interface{}{0.9, 0.1}, []interface{}{0.9, 0.9}, []interface{}{0.1, 0.9})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #96") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_geo_primitives_test.go000066400000000000000000000252211363464422500300720ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test geometric primitive constructors func TestGeoPrimitivesSuite(t *testing.T) { suite.Run(t, new(GeoPrimitivesSuite)) } type GeoPrimitivesSuite struct { suite.Suite session *r.Session } func (suite *GeoPrimitivesSuite) SetupTest() { suite.T().Log("Setting up GeoPrimitivesSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_geopr").Exec(suite.session) err = r.DBCreate("db_geopr").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_geopr").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *GeoPrimitivesSuite) TearDownSuite() { suite.T().Log("Tearing down GeoPrimitivesSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_geopr").Exec(suite.session) suite.session.Close() } } func (suite *GeoPrimitivesSuite) TestCases() { suite.T().Log("Running GeoPrimitivesSuite: Test geometric primitive constructors") { // geo/primitives.yaml line #5 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} /* r.circle([0,0], 1, num_vertices=3) */ suite.T().Log("About to run line #5: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // geo/primitives.yaml line #10 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} /* r.circle(r.point(0,0), 1, num_vertices=3) */ suite.T().Log("About to run line #10: r.Circle(r.Point(0, 0), 1).OptArgs(r.CircleOpts{NumVertices: 3, })") runAndAssert(suite.Suite, expected_, r.Circle(r.Point(0, 0), 1).OptArgs(r.CircleOpts{NumVertices: 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // geo/primitives.yaml line #15 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]], 'type':'LineString'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}, "type": "LineString"} /* r.circle([0,0], 1, num_vertices=3, fill=false) */ suite.T().Log("About to run line #15: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, Fill: false, })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, Fill: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // geo/primitives.yaml line #20 /* err('ReqlQueryLogicError', 'Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 14000000m, but must be smaller than 9985163.1855612862855m.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 14000000m, but must be smaller than 9985163.1855612862855m.") /* r.circle([0,0], 14000000, num_vertices=3) */ suite.T().Log("About to run line #20: r.Circle([]interface{}{0, 0}, 14000000).OptArgs(r.CircleOpts{NumVertices: 3, })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 14000000).OptArgs(r.CircleOpts{NumVertices: 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // geo/primitives.yaml line #25 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} /* r.circle([0,0], 1, num_vertices=3, geo_system='WGS84') */ suite.T().Log("About to run line #25: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: 'WGS84', })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: "WGS84"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // geo/primitives.yaml line #30 /* err('ReqlQueryLogicError', 'Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 2m, but must be smaller than 1.570796326794896558m.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 2m, but must be smaller than 1.570796326794896558m.") /* r.circle([0,0], 2, num_vertices=3, geo_system='unit_sphere') */ suite.T().Log("About to run line #30: r.Circle([]interface{}{0, 0}, 2).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: 'unit_sphere', })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 2).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: "unit_sphere"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // geo/primitives.yaml line #35 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -5.729577951308232], [-4.966092947444857, 2.861205754495701], [4.966092947444857, 2.861205754495701], [0, -5.729577951308232]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -5.729577951308232}, []interface{}{-4.966092947444857, 2.861205754495701}, []interface{}{4.966092947444857, 2.861205754495701}, []interface{}{0, -5.729577951308232}}}, "type": "Polygon"} /* r.circle([0,0], 0.1, num_vertices=3, geo_system='unit_sphere') */ suite.T().Log("About to run line #35: r.Circle([]interface{}{0, 0}, 0.1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: 'unit_sphere', })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 0.1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: "unit_sphere"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // geo/primitives.yaml line #42 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} /* r.circle([0,0], 1.0/1000.0, num_vertices=3, unit='km') */ suite.T().Log("About to run line #42: r.Circle([]interface{}{0, 0}, r.Div(1.0, 1000.0)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: 'km', })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, r.Div(1.0, 1000.0)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: "km"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // geo/primitives.yaml line #47 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} /* r.circle([0,0], 1.0/1609.344, num_vertices=3, unit='mi') */ suite.T().Log("About to run line #47: r.Circle([]interface{}{0, 0}, r.Div(1.0, 1609.344)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: 'mi', })") runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, r.Div(1.0, 1609.344)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: "mi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_joins_test.go000066400000000000000000000502541363464422500261730ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests that manipulation data in tables func TestJoinsSuite(t *testing.T) { suite.Run(t, new(JoinsSuite)) } type JoinsSuite struct { suite.Suite session *r.Session } func (suite *JoinsSuite) SetupTest() { suite.T().Log("Setting up JoinsSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_joins").Exec(suite.session) err = r.DBCreate("db_joins").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("messages").Exec(suite.session) err = r.DB("db_joins").TableCreate("messages").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("messages").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("otable_test_joins").Exec(suite.session) err = r.DB("db_joins").TableCreate("otable_test_joins").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("otable_test_joins").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("otable_test_joins2").Exec(suite.session) err = r.DB("db_joins").TableCreate("otable_test_joins2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("otable_test_joins2").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("receivers").Exec(suite.session) err = r.DB("db_joins").TableCreate("receivers").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("receivers").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("senders").Exec(suite.session) err = r.DB("db_joins").TableCreate("senders").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("senders").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("table_test_joins").Exec(suite.session) err = r.DB("db_joins").TableCreate("table_test_joins").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("table_test_joins").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_joins").TableDrop("table_test_joins2").Exec(suite.session) err = r.DB("db_joins").TableCreate("table_test_joins2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_joins").Table("table_test_joins2").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *JoinsSuite) TearDownSuite() { suite.T().Log("Tearing down JoinsSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_joins").TableDrop("messages").Exec(suite.session) r.DB("db_joins").TableDrop("otable_test_joins").Exec(suite.session) r.DB("db_joins").TableDrop("otable_test_joins2").Exec(suite.session) r.DB("db_joins").TableDrop("receivers").Exec(suite.session) r.DB("db_joins").TableDrop("senders").Exec(suite.session) r.DB("db_joins").TableDrop("table_test_joins").Exec(suite.session) r.DB("db_joins").TableDrop("table_test_joins2").Exec(suite.session) r.DBDrop("db_joins").Exec(suite.session) suite.session.Close() } } func (suite *JoinsSuite) TestCases() { suite.T().Log("Running JoinsSuite: Tests that manipulation data in tables") messages := r.DB("db_joins").Table("messages") _ = messages // Prevent any noused variable errors otable_test_joins := r.DB("db_joins").Table("otable_test_joins") _ = otable_test_joins // Prevent any noused variable errors otable_test_joins2 := r.DB("db_joins").Table("otable_test_joins2") _ = otable_test_joins2 // Prevent any noused variable errors receivers := r.DB("db_joins").Table("receivers") _ = receivers // Prevent any noused variable errors senders := r.DB("db_joins").Table("senders") _ = senders // Prevent any noused variable errors table_test_joins := r.DB("db_joins").Table("table_test_joins") _ = table_test_joins // Prevent any noused variable errors table_test_joins2 := r.DB("db_joins").Table("table_test_joins2") _ = table_test_joins2 // Prevent any noused variable errors { // joins.yaml line #7 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.db('test').table_create('test3', primary_key='foo') */ suite.T().Log("About to run line #7: r.DB('test').TableCreate('test3').OptArgs(r.TableCreateOpts{PrimaryKey: 'foo', })") runAndAssert(suite.Suite, expected_, r.DB("db_joins").TableCreate("test3").OptArgs(r.TableCreateOpts{PrimaryKey: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } // joins.yaml line #11 // table_test_joins3 = r.db('test').table('test3') suite.T().Log("Possibly executing: var table_test_joins3 r.Term = r.DB('test').Table('test3')") table_test_joins3 := r.DB("db_joins").Table("test3") _ = table_test_joins3 // Prevent any noused variable errors { // joins.yaml line #13 /* partial({'errors':0, 'inserted':100}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 100}) /* table_test_joins.insert(r.range(0, 100).map({'id':r.row, 'a':r.row % 4})) */ suite.T().Log("About to run line #13: table_test_joins.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{'id': r.Row, 'a': r.Row.Mod(4), }))") runAndAssert(suite.Suite, expected_, table_test_joins.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{"id": r.Row, "a": r.Row.Mod(4)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // joins.yaml line #18 /* partial({'errors':0, 'inserted':100}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 100}) /* table_test_joins2.insert(r.range(0, 100).map({'id':r.row, 'b':r.row % 4})) */ suite.T().Log("About to run line #18: table_test_joins2.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{'id': r.Row, 'b': r.Row.Mod(4), }))") runAndAssert(suite.Suite, expected_, table_test_joins2.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{"id": r.Row, "b": r.Row.Mod(4)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // joins.yaml line #23 /* partial({'errors':0, 'inserted':100}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 100}) /* table_test_joins3.insert(r.range(0, 100).map({'foo':r.row, 'b':r.row % 4})) */ suite.T().Log("About to run line #23: table_test_joins3.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{'foo': r.Row, 'b': r.Row.Mod(4), }))") runAndAssert(suite.Suite, expected_, table_test_joins3.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{"foo": r.Row, "b": r.Row.Mod(4)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // joins.yaml line #28 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* otable_test_joins.insert(r.range(1,100).map({'id': r.row, 'a': r.row})) */ suite.T().Log("About to run line #28: otable_test_joins.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{'id': r.Row, 'a': r.Row, }))") runAndAssert(suite.Suite, expected_, otable_test_joins.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{"id": r.Row, "a": r.Row})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // joins.yaml line #29 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* otable_test_joins2.insert(r.range(1,100).map({'id': r.row, 'b': 2 * r.row})) */ suite.T().Log("About to run line #29: otable_test_joins2.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{'id': r.Row, 'b': r.Mul(2, r.Row), }))") runAndAssert(suite.Suite, expected_, otable_test_joins2.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{"id": r.Row, "b": r.Mul(2, r.Row)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } // joins.yaml line #34 // ij = table_test_joins.inner_join(table_test_joins2, lambda x,y:x['a'] == y['b']).zip() suite.T().Log("Possibly executing: var ij r.Term = table_test_joins.InnerJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex('a').Eq(y.AtIndex('b'))}).Zip()") ij := table_test_joins.InnerJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex("a").Eq(y.AtIndex("b")) }).Zip() _ = ij // Prevent any noused variable errors { // joins.yaml line #37 /* 2500 */ var expected_ int = 2500 /* ij.count() */ suite.T().Log("About to run line #37: ij.Count()") runAndAssert(suite.Suite, expected_, ij.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // joins.yaml line #39 /* 0 */ var expected_ int = 0 /* ij.filter(lambda row:row['a'] != row['b']).count() */ suite.T().Log("About to run line #39: ij.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Ne(row.AtIndex('b'))}).Count()") runAndAssert(suite.Suite, expected_, ij.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Ne(row.AtIndex("b")) }).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } // joins.yaml line #46 // oj = table_test_joins.outer_join(table_test_joins2, lambda x,y:x['a'] == y['b']).zip() suite.T().Log("Possibly executing: var oj r.Term = table_test_joins.OuterJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex('a').Eq(y.AtIndex('b'))}).Zip()") oj := table_test_joins.OuterJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex("a").Eq(y.AtIndex("b")) }).Zip() _ = oj // Prevent any noused variable errors { // joins.yaml line #49 /* 2500 */ var expected_ int = 2500 /* oj.count() */ suite.T().Log("About to run line #49: oj.Count()") runAndAssert(suite.Suite, expected_, oj.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // joins.yaml line #51 /* 0 */ var expected_ int = 0 /* oj.filter(lambda row:row['a'] != row['b']).count() */ suite.T().Log("About to run line #51: oj.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Ne(row.AtIndex('b'))}).Count()") runAndAssert(suite.Suite, expected_, oj.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Ne(row.AtIndex("b")) }).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } // joins.yaml line #57 // blah = otable_test_joins.order_by("id").eq_join(r.row['id'], otable_test_joins2, ordered=True).zip() suite.T().Log("Possibly executing: var blah r.Term = otable_test_joins.OrderBy('id').EqJoin(r.Row.AtIndex('id'), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true, }).Zip()") blah := maybeRun(otable_test_joins.OrderBy("id").EqJoin(r.Row.AtIndex("id"), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true}).Zip(), suite.session, r.RunOpts{}) _ = blah // Prevent any noused variable errors // joins.yaml line #59 // blah = otable_test_joins.order_by(r.desc("id")).eq_join(r.row['id'], otable_test_joins2, ordered=True).zip() suite.T().Log("Possibly executing: var blah r.Term = otable_test_joins.OrderBy(r.Desc('id')).EqJoin(r.Row.AtIndex('id'), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true, }).Zip()") blah = maybeRun(otable_test_joins.OrderBy(r.Desc("id")).EqJoin(r.Row.AtIndex("id"), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true}).Zip(), suite.session, r.RunOpts{}) // joins.yaml line #61 // blah = otable_test_joins.order_by("id").eq_join(r.row['a'], otable_test_joins2, ordered=True).zip() suite.T().Log("Possibly executing: var blah r.Term = otable_test_joins.OrderBy('id').EqJoin(r.Row.AtIndex('a'), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true, }).Zip()") blah = maybeRun(otable_test_joins.OrderBy("id").EqJoin(r.Row.AtIndex("a"), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true}).Zip(), suite.session, r.RunOpts{}) { // joins.yaml line #65 /* 100 */ var expected_ int = 100 /* table_test_joins.eq_join('a', table_test_joins2).zip().count() */ suite.T().Log("About to run line #65: table_test_joins.EqJoin('a', table_test_joins2).Zip().Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin("a", table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // joins.yaml line #68 /* 0 */ var expected_ int = 0 /* table_test_joins.eq_join('fake', table_test_joins2).zip().count() */ suite.T().Log("About to run line #68: table_test_joins.EqJoin('fake', table_test_joins2).Zip().Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin("fake", table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #68") } { // joins.yaml line #71 /* 100 */ var expected_ int = 100 /* table_test_joins.eq_join(lambda x:x['a'], table_test_joins2).zip().count() */ suite.T().Log("About to run line #71: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('a')}, table_test_joins2).Zip().Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("a") }, table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // joins.yaml line #76 /* 0 */ var expected_ int = 0 /* table_test_joins.eq_join(lambda x:x['fake'], table_test_joins2).zip().count() */ suite.T().Log("About to run line #76: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('fake')}, table_test_joins2).Zip().Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("fake") }, table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #76") } { // joins.yaml line #81 /* 0 */ var expected_ int = 0 /* table_test_joins.eq_join(lambda x:null, table_test_joins2).zip().count() */ suite.T().Log("About to run line #81: table_test_joins.EqJoin(func(x r.Term) interface{} { return nil}, table_test_joins2).Zip().Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return nil }, table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #81") } { // joins.yaml line #86 /* 100 */ var expected_ int = 100 /* table_test_joins.eq_join(lambda x:x['a'], table_test_joins2).count() */ suite.T().Log("About to run line #86: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('a')}, table_test_joins2).Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("a") }, table_test_joins2).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // joins.yaml line #92 /* 100 */ var expected_ int = 100 /* table_test_joins.eq_join('a', table_test_joins3).zip().count() */ suite.T().Log("About to run line #92: table_test_joins.EqJoin('a', table_test_joins3).Zip().Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin("a", table_test_joins3).Zip().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } { // joins.yaml line #95 /* 100 */ var expected_ int = 100 /* table_test_joins.eq_join(lambda x:x['a'], table_test_joins3).count() */ suite.T().Log("About to run line #95: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('a')}, table_test_joins3).Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("a") }, table_test_joins3).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #95") } { // joins.yaml line #101 /* 100 */ var expected_ int = 100 /* table_test_joins.eq_join(r.row['a'], table_test_joins2).count() */ suite.T().Log("About to run line #101: table_test_joins.EqJoin(r.Row.AtIndex('a'), table_test_joins2).Count()") runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(r.Row.AtIndex("a"), table_test_joins2).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } // joins.yaml line #106 // left = r.expr([{'a':1},{'a':2},{'a':3}]) suite.T().Log("Possibly executing: var left r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, }, map[interface{}]interface{}{'a': 2, }, map[interface{}]interface{}{'a': 3, }})") left := r.Expr([]interface{}{map[interface{}]interface{}{"a": 1}, map[interface{}]interface{}{"a": 2}, map[interface{}]interface{}{"a": 3}}) _ = left // Prevent any noused variable errors // joins.yaml line #107 // right = r.expr([{'b':2},{'b':3}]) suite.T().Log("Possibly executing: var right r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'b': 2, }, map[interface{}]interface{}{'b': 3, }})") right := r.Expr([]interface{}{map[interface{}]interface{}{"b": 2}, map[interface{}]interface{}{"b": 3}}) _ = right // Prevent any noused variable errors { // joins.yaml line #109 /* [{'a':2,'b':2},{'a':3,'b':3}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 2, "b": 2}, map[interface{}]interface{}{"a": 3, "b": 3}} /* left.inner_join(right, lambda l, r:l['a'] == r['b']).zip() */ suite.T().Log("About to run line #109: left.InnerJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex('a').Eq(r.AtIndex('b'))}).Zip()") runAndAssert(suite.Suite, expected_, left.InnerJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex("a").Eq(r.AtIndex("b")) }).Zip(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // joins.yaml line #115 /* [{'a':1},{'a':2,'b':2},{'a':3,'b':3}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}, map[interface{}]interface{}{"a": 2, "b": 2}, map[interface{}]interface{}{"a": 3, "b": 3}} /* left.outer_join(right, lambda l, r:l['a'] == r['b']).zip() */ suite.T().Log("About to run line #115: left.OuterJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex('a').Eq(r.AtIndex('b'))}).Zip()") runAndAssert(suite.Suite, expected_, left.OuterJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex("a").Eq(r.AtIndex("b")) }).Zip(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #115") } { // joins.yaml line #132 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* r.db('test').table_drop('test3') */ suite.T().Log("About to run line #132: r.DB('test').TableDrop('test3')") runAndAssert(suite.Suite, expected_, r.DB("db_joins").TableDrop("test3"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #132") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_json_test.go000066400000000000000000000343071363464422500260230ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests RQL json parsing func TestJsonSuite(t *testing.T) { suite.Run(t, new(JsonSuite)) } type JsonSuite struct { suite.Suite session *r.Session } func (suite *JsonSuite) SetupTest() { suite.T().Log("Setting up JsonSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_json").Exec(suite.session) err = r.DBCreate("db_json").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_json").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *JsonSuite) TearDownSuite() { suite.T().Log("Tearing down JsonSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_json").Exec(suite.session) suite.session.Close() } } func (suite *JsonSuite) TestCases() { suite.T().Log("Running JsonSuite: Tests RQL json parsing") { // json.yaml line #4 /* [1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3} /* r.json("[1,2,3]") */ suite.T().Log("About to run line #4: r.JSON('[1,2,3]')") runAndAssert(suite.Suite, expected_, r.JSON("[1,2,3]"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // json.yaml line #7 /* 1 */ var expected_ int = 1 /* r.json("1") */ suite.T().Log("About to run line #7: r.JSON('1')") runAndAssert(suite.Suite, expected_, r.JSON("1"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // json.yaml line #10 /* {} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{} /* r.json("{}") */ suite.T().Log("About to run line #10: r.JSON('{}')") runAndAssert(suite.Suite, expected_, r.JSON("{}"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // json.yaml line #13 /* "foo" */ var expected_ string = "foo" /* r.json('"foo"') */ suite.T().Log("About to run line #13: r.JSON('\\'foo\\'')") runAndAssert(suite.Suite, expected_, r.JSON("\"foo\""), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // json.yaml line #16 /* err("ReqlQueryLogicError", 'Failed to parse "[1,2" as JSON:' + ' Missing a comma or \']\' after an array element.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Failed to parse \"[1,2\" as JSON:"+" Missing a comma or ']' after an array element.") /* r.json("[1,2") */ suite.T().Log("About to run line #16: r.JSON('[1,2')") runAndAssert(suite.Suite, expected_, r.JSON("[1,2"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // json.yaml line #19 /* '[1,2,3]' */ var expected_ string = "[1,2,3]" /* r.json("[1,2,3]").to_json_string() */ suite.T().Log("About to run line #19: r.JSON('[1,2,3]').ToJSON()") runAndAssert(suite.Suite, expected_, r.JSON("[1,2,3]").ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // json.yaml line #23 /* '[1,2,3]' */ var expected_ string = "[1,2,3]" /* r.json("[1,2,3]").to_json() */ suite.T().Log("About to run line #23: r.JSON('[1,2,3]').ToJSON()") runAndAssert(suite.Suite, expected_, r.JSON("[1,2,3]").ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // json.yaml line #26 /* '{"foo":4}' */ var expected_ string = "{\"foo\":4}" /* r.json("{\"foo\":4}").to_json_string() */ suite.T().Log("About to run line #26: r.JSON('{\\'foo\\':4}').ToJSON()") runAndAssert(suite.Suite, expected_, r.JSON("{\"foo\":4}").ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // json.yaml line #30 /* '{"foo":4}' */ var expected_ string = "{\"foo\":4}" /* r.json("{\"foo\":4}").to_json() */ suite.T().Log("About to run line #30: r.JSON('{\\'foo\\':4}').ToJSON()") runAndAssert(suite.Suite, expected_, r.JSON("{\"foo\":4}").ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } // json.yaml line #34 // text = '[{"id":1,"first_name":"Harry","last_name":"Riley","email":"hriley0@usgs.gov","country":"Andorra","ip_address":"221.25.65.136"},{"id":2,"first_name":"Bonnie","last_name":"Anderson","email":"banderson1@list-manage.com","country":"Tuvalu","ip_address":"116.162.43.150"},{"id":3,"first_name":"Marie","last_name":"Schmidt","email":"mschmidt2@diigo.com","country":"Iraq","ip_address":"181.105.59.57"},{"id":4,"first_name":"Phillip","last_name":"Willis","email":"pwillis3@com.com","country":"Montenegro","ip_address":"24.223.139.156"}]' suite.T().Log("Possibly executing: var text string = '[{\\'id\\':1,\\'first_name\\':\\'Harry\\',\\'last_name\\':\\'Riley\\',\\'email\\':\\'hriley0@usgs.gov\\',\\'country\\':\\'Andorra\\',\\'ip_address\\':\\'221.25.65.136\\'},{\\'id\\':2,\\'first_name\\':\\'Bonnie\\',\\'last_name\\':\\'Anderson\\',\\'email\\':\\'banderson1@list-manage.com\\',\\'country\\':\\'Tuvalu\\',\\'ip_address\\':\\'116.162.43.150\\'},{\\'id\\':3,\\'first_name\\':\\'Marie\\',\\'last_name\\':\\'Schmidt\\',\\'email\\':\\'mschmidt2@diigo.com\\',\\'country\\':\\'Iraq\\',\\'ip_address\\':\\'181.105.59.57\\'},{\\'id\\':4,\\'first_name\\':\\'Phillip\\',\\'last_name\\':\\'Willis\\',\\'email\\':\\'pwillis3@com.com\\',\\'country\\':\\'Montenegro\\',\\'ip_address\\':\\'24.223.139.156\\'}]'") text := "[{\"id\":1,\"first_name\":\"Harry\",\"last_name\":\"Riley\",\"email\":\"hriley0@usgs.gov\",\"country\":\"Andorra\",\"ip_address\":\"221.25.65.136\"},{\"id\":2,\"first_name\":\"Bonnie\",\"last_name\":\"Anderson\",\"email\":\"banderson1@list-manage.com\",\"country\":\"Tuvalu\",\"ip_address\":\"116.162.43.150\"},{\"id\":3,\"first_name\":\"Marie\",\"last_name\":\"Schmidt\",\"email\":\"mschmidt2@diigo.com\",\"country\":\"Iraq\",\"ip_address\":\"181.105.59.57\"},{\"id\":4,\"first_name\":\"Phillip\",\"last_name\":\"Willis\",\"email\":\"pwillis3@com.com\",\"country\":\"Montenegro\",\"ip_address\":\"24.223.139.156\"}]" _ = text // Prevent any noused variable errors // json.yaml line #35 // sorted = '[{"country":"Andorra","email":"hriley0@usgs.gov","first_name":"Harry","id":1,"ip_address":"221.25.65.136","last_name":"Riley"},{"country":"Tuvalu","email":"banderson1@list-manage.com","first_name":"Bonnie","id":2,"ip_address":"116.162.43.150","last_name":"Anderson"},{"country":"Iraq","email":"mschmidt2@diigo.com","first_name":"Marie","id":3,"ip_address":"181.105.59.57","last_name":"Schmidt"},{"country":"Montenegro","email":"pwillis3@com.com","first_name":"Phillip","id":4,"ip_address":"24.223.139.156","last_name":"Willis"}]' suite.T().Log("Possibly executing: var sorted string = '[{\\'country\\':\\'Andorra\\',\\'email\\':\\'hriley0@usgs.gov\\',\\'first_name\\':\\'Harry\\',\\'id\\':1,\\'ip_address\\':\\'221.25.65.136\\',\\'last_name\\':\\'Riley\\'},{\\'country\\':\\'Tuvalu\\',\\'email\\':\\'banderson1@list-manage.com\\',\\'first_name\\':\\'Bonnie\\',\\'id\\':2,\\'ip_address\\':\\'116.162.43.150\\',\\'last_name\\':\\'Anderson\\'},{\\'country\\':\\'Iraq\\',\\'email\\':\\'mschmidt2@diigo.com\\',\\'first_name\\':\\'Marie\\',\\'id\\':3,\\'ip_address\\':\\'181.105.59.57\\',\\'last_name\\':\\'Schmidt\\'},{\\'country\\':\\'Montenegro\\',\\'email\\':\\'pwillis3@com.com\\',\\'first_name\\':\\'Phillip\\',\\'id\\':4,\\'ip_address\\':\\'24.223.139.156\\',\\'last_name\\':\\'Willis\\'}]'") sorted := "[{\"country\":\"Andorra\",\"email\":\"hriley0@usgs.gov\",\"first_name\":\"Harry\",\"id\":1,\"ip_address\":\"221.25.65.136\",\"last_name\":\"Riley\"},{\"country\":\"Tuvalu\",\"email\":\"banderson1@list-manage.com\",\"first_name\":\"Bonnie\",\"id\":2,\"ip_address\":\"116.162.43.150\",\"last_name\":\"Anderson\"},{\"country\":\"Iraq\",\"email\":\"mschmidt2@diigo.com\",\"first_name\":\"Marie\",\"id\":3,\"ip_address\":\"181.105.59.57\",\"last_name\":\"Schmidt\"},{\"country\":\"Montenegro\",\"email\":\"pwillis3@com.com\",\"first_name\":\"Phillip\",\"id\":4,\"ip_address\":\"24.223.139.156\",\"last_name\":\"Willis\"}]" _ = sorted // Prevent any noused variable errors { // json.yaml line #37 /* sorted */ var expected_ string = sorted /* r.json(text).to_json_string() */ suite.T().Log("About to run line #37: r.JSON(text).ToJSON()") runAndAssert(suite.Suite, expected_, r.JSON(text).ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // json.yaml line #40 /* err('ReqlQueryLogicError', 'Cannot convert `r.minval` to JSON.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.minval` to JSON.") /* r.expr(r.minval).to_json_string() */ suite.T().Log("About to run line #40: r.Expr(r.MinVal).ToJSON()") runAndAssert(suite.Suite, expected_, r.Expr(r.MinVal).ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // json.yaml line #43 /* err('ReqlQueryLogicError', 'Cannot convert `r.maxval` to JSON.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.maxval` to JSON.") /* r.expr(r.maxval).to_json_string() */ suite.T().Log("About to run line #43: r.Expr(r.MaxVal).ToJSON()") runAndAssert(suite.Suite, expected_, r.Expr(r.MaxVal).ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // json.yaml line #46 /* err('ReqlQueryLogicError', 'Cannot convert `r.minval` to JSON.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.minval` to JSON.") /* r.expr(r.minval).coerce_to('string') */ suite.T().Log("About to run line #46: r.Expr(r.MinVal).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr(r.MinVal).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // json.yaml line #49 /* err('ReqlQueryLogicError', 'Cannot convert `r.maxval` to JSON.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.maxval` to JSON.") /* r.expr(r.maxval).coerce_to('string') */ suite.T().Log("About to run line #49: r.Expr(r.MaxVal).CoerceTo('string')") runAndAssert(suite.Suite, expected_, r.Expr(r.MaxVal).CoerceTo("string"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // json.yaml line #52 /* {'timezone':'+00:00','$reql_type$':'TIME','epoch_time':1410393600} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"timezone": "+00:00", "$reql_type$": "TIME", "epoch_time": 1410393600} /* r.time(2014,9,11, 'Z') */ suite.T().Log("About to run line #52: r.Time(2014, 9, 11, 'Z')") runAndAssert(suite.Suite, expected_, r.Time(2014, 9, 11, "Z"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", TimeFormat: "raw", }) suite.T().Log("Finished running line #52") } { // json.yaml line #57 /* '{"$reql_type$":"TIME","epoch_time":1410393600,"timezone":"+00:00"}' */ var expected_ string = "{\"$reql_type$\":\"TIME\",\"epoch_time\":1410393600,\"timezone\":\"+00:00\"}" /* r.time(2014,9,11, 'Z').to_json_string() */ suite.T().Log("About to run line #57: r.Time(2014, 9, 11, 'Z').ToJSON()") runAndAssert(suite.Suite, expected_, r.Time(2014, 9, 11, "Z").ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // json.yaml line #60 /* {'$reql_type$':'GEOMETRY','coordinates':[0,0],'type':'Point'} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{0, 0}, "type": "Point"} /* r.point(0,0) */ suite.T().Log("About to run line #60: r.Point(0, 0)") runAndAssert(suite.Suite, expected_, r.Point(0, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // json.yaml line #63 /* '{"$reql_type$":"GEOMETRY","coordinates":[0,0],"type":"Point"}' */ var expected_ string = "{\"$reql_type$\":\"GEOMETRY\",\"coordinates\":[0,0],\"type\":\"Point\"}" /* r.point(0,0).to_json_string() */ suite.T().Log("About to run line #63: r.Point(0, 0).ToJSON()") runAndAssert(suite.Suite, expected_, r.Point(0, 0).ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } // json.yaml line #68 // s = b'\x66\x6f\x6f' suite.T().Log("Possibly executing: var s []byte = []byte{102,111,111}") s := []byte{102, 111, 111} _ = s // Prevent any noused variable errors { // json.yaml line #70 /* s */ var expected_ []byte = s /* r.binary(s) */ suite.T().Log("About to run line #70: r.Binary(s)") runAndAssert(suite.Suite, expected_, r.Binary(s), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // json.yaml line #73 /* '{"$reql_type$":"BINARY","data":"Zm9v"}' */ var expected_ string = "{\"$reql_type$\":\"BINARY\",\"data\":\"Zm9v\"}" /* r.expr("foo").coerce_to("binary").to_json_string() */ suite.T().Log("About to run line #73: r.Expr('foo').CoerceTo('binary').ToJSON()") runAndAssert(suite.Suite, expected_, r.Expr("foo").CoerceTo("binary").ToJSON(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_match_test.go000066400000000000000000000210611363464422500261370ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests for match func TestMatchSuite(t *testing.T) { suite.Run(t, new(MatchSuite)) } type MatchSuite struct { suite.Suite session *r.Session } func (suite *MatchSuite) SetupTest() { suite.T().Log("Setting up MatchSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_match").Exec(suite.session) err = r.DBCreate("db_match").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_match").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_match").TableDrop("table_test_match").Exec(suite.session) err = r.DB("db_match").TableCreate("table_test_match").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_match").Table("table_test_match").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MatchSuite) TearDownSuite() { suite.T().Log("Tearing down MatchSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_match").TableDrop("table_test_match").Exec(suite.session) r.DBDrop("db_match").Exec(suite.session) suite.session.Close() } } func (suite *MatchSuite) TestCases() { suite.T().Log("Running MatchSuite: Tests for match") table_test_match := r.DB("db_match").Table("table_test_match") _ = table_test_match // Prevent any noused variable errors { // match.yaml line #4 /* ({'str':'bcde','groups':[null,{'start':2,'str':'cde','end':5}],'start':1,'end':5}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"str": "bcde", "groups": []interface{}{nil, map[interface{}]interface{}{"start": 2, "str": "cde", "end": 5}}, "start": 1, "end": 5} /* r.expr("abcdefg").match("a(b.e)|b(c.e)") */ suite.T().Log("About to run line #4: r.Expr('abcdefg').Match('a(b.e)|b(c.e)')") runAndAssert(suite.Suite, expected_, r.Expr("abcdefg").Match("a(b.e)|b(c.e)"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // match.yaml line #6 /* (null) */ var expected_ interface{} = nil /* r.expr("abcdefg").match("a(b.e)|B(c.e)") */ suite.T().Log("About to run line #6: r.Expr('abcdefg').Match('a(b.e)|B(c.e)')") runAndAssert(suite.Suite, expected_, r.Expr("abcdefg").Match("a(b.e)|B(c.e)"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // match.yaml line #8 /* ({'str':'bcde','groups':[null,{'start':2,'str':'cde','end':5}],'start':1,'end':5}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"str": "bcde", "groups": []interface{}{nil, map[interface{}]interface{}{"start": 2, "str": "cde", "end": 5}}, "start": 1, "end": 5} /* r.expr("abcdefg").match("(?i)a(b.e)|B(c.e)") */ suite.T().Log("About to run line #8: r.Expr('abcdefg').Match('(?i)a(b.e)|B(c.e)')") runAndAssert(suite.Suite, expected_, r.Expr("abcdefg").Match("(?i)a(b.e)|B(c.e)"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // match.yaml line #12 /* (["aca", "ada"]) */ var expected_ []interface{} = []interface{}{"aca", "ada"} /* r.expr(["aba", "aca", "ada", "aea"]).filter(lambda row:row.match("a(.)a")['groups'][0]['str'].match("[cd]")) */ suite.T().Log("About to run line #12: r.Expr([]interface{}{'aba', 'aca', 'ada', 'aea'}).Filter(func(row r.Term) interface{} { return row.Match('a(.)a').AtIndex('groups').AtIndex(0).AtIndex('str').Match('[cd]')})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{"aba", "aca", "ada", "aea"}).Filter(func(row r.Term) interface{} { return row.Match("a(.)a").AtIndex("groups").AtIndex(0).AtIndex("str").Match("[cd]") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // match.yaml line #16 /* ({'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':3}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 3} /* table_test_match.insert([{'id':0,'a':'abc'},{'id':1,'a':'ab'},{'id':2,'a':'bc'}]) */ suite.T().Log("About to run line #16: table_test_match.Insert([]interface{}{map[interface{}]interface{}{'id': 0, 'a': 'abc', }, map[interface{}]interface{}{'id': 1, 'a': 'ab', }, map[interface{}]interface{}{'id': 2, 'a': 'bc', }})") runAndAssert(suite.Suite, expected_, table_test_match.Insert([]interface{}{map[interface{}]interface{}{"id": 0, "a": "abc"}, map[interface{}]interface{}{"id": 1, "a": "ab"}, map[interface{}]interface{}{"id": 2, "a": "bc"}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // match.yaml line #20 /* ([{'id':0,'a':'abc'},{'id':1,'a':'ab'},{'id':2,'a':'bc'}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 0, "a": "abc"}, map[interface{}]interface{}{"id": 1, "a": "ab"}, map[interface{}]interface{}{"id": 2, "a": "bc"}} /* table_test_match.filter(lambda row:row['a'].match('b')).order_by('id') */ suite.T().Log("About to run line #20: table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Match('b')}).OrderBy('id')") runAndAssert(suite.Suite, expected_, table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Match("b") }).OrderBy("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // match.yaml line #24 /* ([{'id':0,'a':'abc'},{'id':1,'a':'ab'}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 0, "a": "abc"}, map[interface{}]interface{}{"id": 1, "a": "ab"}} /* table_test_match.filter(lambda row:row['a'].match('ab')).order_by('id') */ suite.T().Log("About to run line #24: table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Match('ab')}).OrderBy('id')") runAndAssert(suite.Suite, expected_, table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Match("ab") }).OrderBy("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // match.yaml line #28 /* ([{'id':1,'a':'ab'}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 1, "a": "ab"}} /* table_test_match.filter(lambda row:row['a'].match('ab$')).order_by('id') */ suite.T().Log("About to run line #28: table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Match('ab$')}).OrderBy('id')") runAndAssert(suite.Suite, expected_, table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Match("ab$") }).OrderBy("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // match.yaml line #32 /* ([]) */ var expected_ []interface{} = []interface{}{} /* table_test_match.filter(lambda row:row['a'].match('^b$')).order_by('id') */ suite.T().Log("About to run line #32: table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Match('^b$')}).OrderBy('id')") runAndAssert(suite.Suite, expected_, table_test_match.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Match("^b$") }).OrderBy("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } { // match.yaml line #36 /* err("ReqlQueryLogicError", "Error in regexp `ab\\9` (portion `\\9`): invalid escape sequence: \\9", []) */ var expected_ Err = err("ReqlQueryLogicError", "Error in regexp `ab\\9` (portion `\\9`): invalid escape sequence: \\9") /* r.expr("").match("ab\\9") */ suite.T().Log("About to run line #36: r.Expr('').Match('ab\\\\9')") runAndAssert(suite.Suite, expected_, r.Expr("").Match("ab\\9"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_add_test.go000066400000000000000000000132631363464422500277660ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests for basic usage of the add operation func TestMathLogicAddSuite(t *testing.T) { suite.Run(t, new(MathLogicAddSuite)) } type MathLogicAddSuite struct { suite.Suite session *r.Session } func (suite *MathLogicAddSuite) SetupTest() { suite.T().Log("Setting up MathLogicAddSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_add").Exec(suite.session) err = r.DBCreate("db_logic_add").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_add").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicAddSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicAddSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_add").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicAddSuite) TestCases() { suite.T().Log("Running MathLogicAddSuite: Tests for basic usage of the add operation") { // math_logic/add.yaml line #3 /* 2 */ var expected_ int = 2 /* r.add(1, 1) */ suite.T().Log("About to run line #3: r.Add(1, 1)") runAndAssert(suite.Suite, expected_, r.Add(1, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #3") } { // math_logic/add.yaml line #8 /* 2 */ var expected_ int = 2 /* r.expr(1) + 1 */ suite.T().Log("About to run line #8: r.Expr(1).Add(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Add(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/add.yaml line #9 /* 2 */ var expected_ int = 2 /* 1 + r.expr(1) */ suite.T().Log("About to run line #9: r.Add(1, r.Expr(1))") runAndAssert(suite.Suite, expected_, r.Add(1, r.Expr(1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // math_logic/add.yaml line #10 /* 2 */ var expected_ int = 2 /* r.expr(1).add(1) */ suite.T().Log("About to run line #10: r.Expr(1).Add(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Add(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // math_logic/add.yaml line #16 /* 0 */ var expected_ int = 0 /* r.expr(-1) + 1 */ suite.T().Log("About to run line #16: r.Expr(-1).Add(1)") runAndAssert(suite.Suite, expected_, r.Expr(-1).Add(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // math_logic/add.yaml line #21 /* 10.25 */ var expected_ float64 = 10.25 /* r.expr(1.75) + 8.5 */ suite.T().Log("About to run line #21: r.Expr(1.75).Add(8.5)") runAndAssert(suite.Suite, expected_, r.Expr(1.75).Add(8.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // math_logic/add.yaml line #27 /* '' */ var expected_ string = "" /* r.expr('') + '' */ suite.T().Log("About to run line #27: r.Expr('').Add('')") runAndAssert(suite.Suite, expected_, r.Expr("").Add(""), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // math_logic/add.yaml line #32 /* 'abcdef' */ var expected_ string = "abcdef" /* r.expr('abc') + 'def' */ suite.T().Log("About to run line #32: r.Expr('abc').Add('def')") runAndAssert(suite.Suite, expected_, r.Expr("abc").Add("def"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } { // math_logic/add.yaml line #52 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr(1) + 'a' */ suite.T().Log("About to run line #52: r.Expr(1).Add('a')") runAndAssert(suite.Suite, expected_, r.Expr(1).Add("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // math_logic/add.yaml line #57 /* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* r.expr('a') + 1 */ suite.T().Log("About to run line #57: r.Expr('a').Add(1)") runAndAssert(suite.Suite, expected_, r.Expr("a").Add(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // math_logic/add.yaml line #62 /* err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.", [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type ARRAY but found NUMBER.") /* r.expr([]) + 1 */ suite.T().Log("About to run line #62: r.Expr([]interface{}{}).Add(1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Add(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_aliases_test.go000066400000000000000000000260531363464422500306600ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Test named aliases for math and logic operators func TestMathLogicAliasesSuite(t *testing.T) { suite.Run(t, new(MathLogicAliasesSuite)) } type MathLogicAliasesSuite struct { suite.Suite session *r.Session } func (suite *MathLogicAliasesSuite) SetupTest() { suite.T().Log("Setting up MathLogicAliasesSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_ali").Exec(suite.session) err = r.DBCreate("db_logic_ali").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_ali").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicAliasesSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicAliasesSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_ali").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicAliasesSuite) TestCases() { suite.T().Log("Running MathLogicAliasesSuite: Test named aliases for math and logic operators") { // math_logic/aliases.yaml line #5 /* 1 */ var expected_ int = 1 /* r.expr(0).add(1) */ suite.T().Log("About to run line #5: r.Expr(0).Add(1)") runAndAssert(suite.Suite, expected_, r.Expr(0).Add(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // math_logic/aliases.yaml line #6 /* 1 */ var expected_ int = 1 /* r.add(0, 1) */ suite.T().Log("About to run line #6: r.Add(0, 1)") runAndAssert(suite.Suite, expected_, r.Add(0, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // math_logic/aliases.yaml line #7 /* 1 */ var expected_ int = 1 /* r.expr(2).sub(1) */ suite.T().Log("About to run line #7: r.Expr(2).Sub(1)") runAndAssert(suite.Suite, expected_, r.Expr(2).Sub(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // math_logic/aliases.yaml line #8 /* 1 */ var expected_ int = 1 /* r.sub(2, 1) */ suite.T().Log("About to run line #8: r.Sub(2, 1)") runAndAssert(suite.Suite, expected_, r.Sub(2, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/aliases.yaml line #9 /* 1 */ var expected_ int = 1 /* r.expr(2).div(2) */ suite.T().Log("About to run line #9: r.Expr(2).Div(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Div(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // math_logic/aliases.yaml line #10 /* 1 */ var expected_ int = 1 /* r.div(2, 2) */ suite.T().Log("About to run line #10: r.Div(2, 2)") runAndAssert(suite.Suite, expected_, r.Div(2, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // math_logic/aliases.yaml line #11 /* 1 */ var expected_ int = 1 /* r.expr(1).mul(1) */ suite.T().Log("About to run line #11: r.Expr(1).Mul(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Mul(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // math_logic/aliases.yaml line #12 /* 1 */ var expected_ int = 1 /* r.mul(1, 1) */ suite.T().Log("About to run line #12: r.Mul(1, 1)") runAndAssert(suite.Suite, expected_, r.Mul(1, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // math_logic/aliases.yaml line #13 /* 1 */ var expected_ int = 1 /* r.expr(1).mod(2) */ suite.T().Log("About to run line #13: r.Expr(1).Mod(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Mod(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // math_logic/aliases.yaml line #14 /* 1 */ var expected_ int = 1 /* r.mod(1, 2) */ suite.T().Log("About to run line #14: r.Mod(1, 2)") runAndAssert(suite.Suite, expected_, r.Mod(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // math_logic/aliases.yaml line #25 /* True */ var expected_ bool = true /* r.expr(True).and_(True) */ suite.T().Log("About to run line #25: r.Expr(true).And(true)") runAndAssert(suite.Suite, expected_, r.Expr(true).And(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // math_logic/aliases.yaml line #26 /* True */ var expected_ bool = true /* r.expr(True).or_(True) */ suite.T().Log("About to run line #26: r.Expr(true).Or(true)") runAndAssert(suite.Suite, expected_, r.Expr(true).Or(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // math_logic/aliases.yaml line #27 /* True */ var expected_ bool = true /* r.and_(True, True) */ suite.T().Log("About to run line #27: r.And(true, true)") runAndAssert(suite.Suite, expected_, r.And(true, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // math_logic/aliases.yaml line #28 /* True */ var expected_ bool = true /* r.or_(True, True) */ suite.T().Log("About to run line #28: r.Or(true, true)") runAndAssert(suite.Suite, expected_, r.Or(true, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // math_logic/aliases.yaml line #29 /* True */ var expected_ bool = true /* r.expr(False).not_() */ suite.T().Log("About to run line #29: r.Expr(false).Not()") runAndAssert(suite.Suite, expected_, r.Expr(false).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // math_logic/aliases.yaml line #30 /* True */ var expected_ bool = true /* r.not_(False) */ suite.T().Log("About to run line #30: r.Not(false)") runAndAssert(suite.Suite, expected_, r.Not(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // math_logic/aliases.yaml line #34 /* True */ var expected_ bool = true /* r.expr(1).eq(1) */ suite.T().Log("About to run line #34: r.Expr(1).Eq(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Eq(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // math_logic/aliases.yaml line #35 /* True */ var expected_ bool = true /* r.expr(1).ne(2) */ suite.T().Log("About to run line #35: r.Expr(1).Ne(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Ne(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // math_logic/aliases.yaml line #36 /* True */ var expected_ bool = true /* r.expr(1).lt(2) */ suite.T().Log("About to run line #36: r.Expr(1).Lt(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Lt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // math_logic/aliases.yaml line #37 /* True */ var expected_ bool = true /* r.expr(1).gt(0) */ suite.T().Log("About to run line #37: r.Expr(1).Gt(0)") runAndAssert(suite.Suite, expected_, r.Expr(1).Gt(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // math_logic/aliases.yaml line #38 /* True */ var expected_ bool = true /* r.expr(1).le(1) */ suite.T().Log("About to run line #38: r.Expr(1).Le(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Le(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // math_logic/aliases.yaml line #39 /* True */ var expected_ bool = true /* r.expr(1).ge(1) */ suite.T().Log("About to run line #39: r.Expr(1).Ge(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Ge(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // math_logic/aliases.yaml line #40 /* True */ var expected_ bool = true /* r.eq(1, 1) */ suite.T().Log("About to run line #40: r.Eq(1, 1)") runAndAssert(suite.Suite, expected_, r.Eq(1, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // math_logic/aliases.yaml line #41 /* True */ var expected_ bool = true /* r.ne(1, 2) */ suite.T().Log("About to run line #41: r.Ne(1, 2)") runAndAssert(suite.Suite, expected_, r.Ne(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #41") } { // math_logic/aliases.yaml line #42 /* True */ var expected_ bool = true /* r.lt(1, 2) */ suite.T().Log("About to run line #42: r.Lt(1, 2)") runAndAssert(suite.Suite, expected_, r.Lt(1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // math_logic/aliases.yaml line #43 /* True */ var expected_ bool = true /* r.gt(1, 0) */ suite.T().Log("About to run line #43: r.Gt(1, 0)") runAndAssert(suite.Suite, expected_, r.Gt(1, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // math_logic/aliases.yaml line #44 /* True */ var expected_ bool = true /* r.le(1, 1) */ suite.T().Log("About to run line #44: r.Le(1, 1)") runAndAssert(suite.Suite, expected_, r.Le(1, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // math_logic/aliases.yaml line #45 /* True */ var expected_ bool = true /* r.ge(1, 1) */ suite.T().Log("About to run line #45: r.Ge(1, 1)") runAndAssert(suite.Suite, expected_, r.Ge(1, 1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #45") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_comparison_test.go000066400000000000000000001246311363464422500314120ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of comparison operators func TestMathLogicComparisonSuite(t *testing.T) { suite.Run(t, new(MathLogicComparisonSuite)) } type MathLogicComparisonSuite struct { suite.Suite session *r.Session } func (suite *MathLogicComparisonSuite) SetupTest() { suite.T().Log("Setting up MathLogicComparisonSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_comp").Exec(suite.session) err = r.DBCreate("db_logic_comp").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_comp").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicComparisonSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicComparisonSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_comp").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicComparisonSuite) TestCases() { suite.T().Log("Running MathLogicComparisonSuite: Tests of comparison operators") { // math_logic/comparison.yaml line #10 /* true */ var expected_ bool = true /* r.expr(1) < 2 */ suite.T().Log("About to run line #10: r.Expr(1).Lt(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Lt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // math_logic/comparison.yaml line #11 /* true */ var expected_ bool = true /* 1 < r.expr(2) */ suite.T().Log("About to run line #11: r.Lt(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Lt(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // math_logic/comparison.yaml line #12 /* true */ var expected_ bool = true /* r.expr(1).lt(2) */ suite.T().Log("About to run line #12: r.Expr(1).Lt(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Lt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // math_logic/comparison.yaml line #19 /* false */ var expected_ bool = false /* r.expr(3) < 2 */ suite.T().Log("About to run line #19: r.Expr(3).Lt(2)") runAndAssert(suite.Suite, expected_, r.Expr(3).Lt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // math_logic/comparison.yaml line #22 /* false */ var expected_ bool = false /* r.expr(2) < 2 */ suite.T().Log("About to run line #22: r.Expr(2).Lt(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Lt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // math_logic/comparison.yaml line #38 /* false */ var expected_ bool = false /* r.expr(1) > 2 */ suite.T().Log("About to run line #38: r.Expr(1).Gt(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Gt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // math_logic/comparison.yaml line #39 /* false */ var expected_ bool = false /* 1 > r.expr(2) */ suite.T().Log("About to run line #39: r.Gt(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Gt(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // math_logic/comparison.yaml line #40 /* false */ var expected_ bool = false /* r.expr(1).gt(2) */ suite.T().Log("About to run line #40: r.Expr(1).Gt(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Gt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // math_logic/comparison.yaml line #45 /* true */ var expected_ bool = true /* r.expr(3) > 2 */ suite.T().Log("About to run line #45: r.Expr(3).Gt(2)") runAndAssert(suite.Suite, expected_, r.Expr(3).Gt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #45") } { // math_logic/comparison.yaml line #49 /* false */ var expected_ bool = false /* r.expr(2) > 2 */ suite.T().Log("About to run line #49: r.Expr(2).Gt(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Gt(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // math_logic/comparison.yaml line #63 /* false */ var expected_ bool = false /* r.expr(1) == 2 */ suite.T().Log("About to run line #63: r.Expr(1).Eq(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Eq(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } { // math_logic/comparison.yaml line #64 /* false */ var expected_ bool = false /* 1 == r.expr(2) */ suite.T().Log("About to run line #64: r.Eq(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Eq(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #64") } { // math_logic/comparison.yaml line #65 /* false */ var expected_ bool = false /* r.expr(1).eq(2) */ suite.T().Log("About to run line #65: r.Expr(1).Eq(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Eq(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // math_logic/comparison.yaml line #68 /* false */ var expected_ bool = false /* r.expr(3) == 2 */ suite.T().Log("About to run line #68: r.Expr(3).Eq(2)") runAndAssert(suite.Suite, expected_, r.Expr(3).Eq(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #68") } { // math_logic/comparison.yaml line #72 /* true */ var expected_ bool = true /* r.expr(2) == 2 */ suite.T().Log("About to run line #72: r.Expr(2).Eq(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Eq(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #72") } { // math_logic/comparison.yaml line #86 /* true */ var expected_ bool = true /* r.expr(1) != 2 */ suite.T().Log("About to run line #86: r.Expr(1).Ne(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Ne(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // math_logic/comparison.yaml line #87 /* true */ var expected_ bool = true /* 1 != r.expr(2) */ suite.T().Log("About to run line #87: r.Ne(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Ne(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } { // math_logic/comparison.yaml line #88 /* true */ var expected_ bool = true /* r.expr(1).ne(2) */ suite.T().Log("About to run line #88: r.Expr(1).Ne(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Ne(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // math_logic/comparison.yaml line #91 /* true */ var expected_ bool = true /* r.expr(3) != 2 */ suite.T().Log("About to run line #91: r.Expr(3).Ne(2)") runAndAssert(suite.Suite, expected_, r.Expr(3).Ne(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // math_logic/comparison.yaml line #95 /* false */ var expected_ bool = false /* r.expr(2) != 2 */ suite.T().Log("About to run line #95: r.Expr(2).Ne(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Ne(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #95") } { // math_logic/comparison.yaml line #109 /* true */ var expected_ bool = true /* r.expr(1) <= 2 */ suite.T().Log("About to run line #109: r.Expr(1).Le(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Le(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // math_logic/comparison.yaml line #110 /* true */ var expected_ bool = true /* 1 <= r.expr(2) */ suite.T().Log("About to run line #110: r.Le(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Le(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // math_logic/comparison.yaml line #111 /* true */ var expected_ bool = true /* r.expr(1).le(2) */ suite.T().Log("About to run line #111: r.Expr(1).Le(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Le(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // math_logic/comparison.yaml line #116 /* false */ var expected_ bool = false /* r.expr(3) <= 2 */ suite.T().Log("About to run line #116: r.Expr(3).Le(2)") runAndAssert(suite.Suite, expected_, r.Expr(3).Le(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #116") } { // math_logic/comparison.yaml line #120 /* true */ var expected_ bool = true /* r.expr(2) <= 2 */ suite.T().Log("About to run line #120: r.Expr(2).Le(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Le(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #120") } { // math_logic/comparison.yaml line #134 /* false */ var expected_ bool = false /* r.expr(1) >= 2 */ suite.T().Log("About to run line #134: r.Expr(1).Ge(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Ge(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #134") } { // math_logic/comparison.yaml line #135 /* false */ var expected_ bool = false /* 1 >= r.expr(2) */ suite.T().Log("About to run line #135: r.Ge(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Ge(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #135") } { // math_logic/comparison.yaml line #136 /* false */ var expected_ bool = false /* r.expr(1).ge(2) */ suite.T().Log("About to run line #136: r.Expr(1).Ge(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Ge(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #136") } { // math_logic/comparison.yaml line #141 /* true */ var expected_ bool = true /* r.expr(3) >= 2 */ suite.T().Log("About to run line #141: r.Expr(3).Ge(2)") runAndAssert(suite.Suite, expected_, r.Expr(3).Ge(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #141") } { // math_logic/comparison.yaml line #145 /* true */ var expected_ bool = true /* r.expr(2) >= 2 */ suite.T().Log("About to run line #145: r.Expr(2).Ge(2)") runAndAssert(suite.Suite, expected_, r.Expr(2).Ge(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #145") } { // math_logic/comparison.yaml line #158 /* true */ var expected_ bool = true /* r.expr(null) == null */ suite.T().Log("About to run line #158: r.Expr(nil).Eq(nil)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Eq(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #158") } { // math_logic/comparison.yaml line #159 /* true */ var expected_ bool = true /* null == r.expr(null) */ suite.T().Log("About to run line #159: r.Eq(nil, r.Expr(nil))") runAndAssert(suite.Suite, expected_, r.Eq(nil, r.Expr(nil)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // math_logic/comparison.yaml line #164 /* false */ var expected_ bool = false /* r.expr(null) < null */ suite.T().Log("About to run line #164: r.Expr(nil).Lt(nil)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Lt(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #164") } { // math_logic/comparison.yaml line #165 /* false */ var expected_ bool = false /* null < r.expr(null) */ suite.T().Log("About to run line #165: r.Lt(nil, r.Expr(nil))") runAndAssert(suite.Suite, expected_, r.Lt(nil, r.Expr(nil)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #165") } { // math_logic/comparison.yaml line #166 /* false */ var expected_ bool = false /* r.expr(null).lt(null) */ suite.T().Log("About to run line #166: r.Expr(nil).Lt(nil)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Lt(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #166") } { // math_logic/comparison.yaml line #172 /* false */ var expected_ bool = false /* r.expr(null) > null */ suite.T().Log("About to run line #172: r.Expr(nil).Gt(nil)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Gt(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #172") } { // math_logic/comparison.yaml line #173 /* false */ var expected_ bool = false /* null > r.expr(null) */ suite.T().Log("About to run line #173: r.Gt(nil, r.Expr(nil))") runAndAssert(suite.Suite, expected_, r.Gt(nil, r.Expr(nil)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #173") } { // math_logic/comparison.yaml line #174 /* false */ var expected_ bool = false /* r.expr(null).gt(null) */ suite.T().Log("About to run line #174: r.Expr(nil).Gt(nil)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Gt(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #174") } { // math_logic/comparison.yaml line #180 /* true */ var expected_ bool = true /* r.expr('a') == 'a' */ suite.T().Log("About to run line #180: r.Expr('a').Eq('a')") runAndAssert(suite.Suite, expected_, r.Expr("a").Eq("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #180") } { // math_logic/comparison.yaml line #184 /* false */ var expected_ bool = false /* r.expr('a') == 'aa' */ suite.T().Log("About to run line #184: r.Expr('a').Eq('aa')") runAndAssert(suite.Suite, expected_, r.Expr("a").Eq("aa"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #184") } { // math_logic/comparison.yaml line #188 /* true */ var expected_ bool = true /* r.expr('a') < 'aa' */ suite.T().Log("About to run line #188: r.Expr('a').Lt('aa')") runAndAssert(suite.Suite, expected_, r.Expr("a").Lt("aa"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #188") } { // math_logic/comparison.yaml line #192 /* true */ var expected_ bool = true /* r.expr('a') < 'bb' */ suite.T().Log("About to run line #192: r.Expr('a').Lt('bb')") runAndAssert(suite.Suite, expected_, r.Expr("a").Lt("bb"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #192") } { // math_logic/comparison.yaml line #196 /* true */ var expected_ bool = true /* r.expr('bb') > 'a' */ suite.T().Log("About to run line #196: r.Expr('bb').Gt('a')") runAndAssert(suite.Suite, expected_, r.Expr("bb").Gt("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #196") } { // math_logic/comparison.yaml line #200 /* true */ var expected_ bool = true /* r.expr('abcdef') < 'abcdeg' */ suite.T().Log("About to run line #200: r.Expr('abcdef').Lt('abcdeg')") runAndAssert(suite.Suite, expected_, r.Expr("abcdef").Lt("abcdeg"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #200") } { // math_logic/comparison.yaml line #204 /* false */ var expected_ bool = false /* r.expr('abcdefg') > 'abcdeg' */ suite.T().Log("About to run line #204: r.Expr('abcdefg').Gt('abcdeg')") runAndAssert(suite.Suite, expected_, r.Expr("abcdefg").Gt("abcdeg"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #204") } { // math_logic/comparison.yaml line #208 /* true */ var expected_ bool = true /* r.expr('A quick brown fox') > 'A quick brawn fox' */ suite.T().Log("About to run line #208: r.Expr('A quick brown fox').Gt('A quick brawn fox')") runAndAssert(suite.Suite, expected_, r.Expr("A quick brown fox").Gt("A quick brawn fox"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #208") } { // math_logic/comparison.yaml line #216 /* true */ var expected_ bool = true /* r.expr([1]) < [2] */ suite.T().Log("About to run line #216: r.Expr([]interface{}{1}).Lt([]interface{}{2})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1}).Lt([]interface{}{2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #216") } { // math_logic/comparison.yaml line #221 /* false */ var expected_ bool = false /* r.expr([1]) > [2] */ suite.T().Log("About to run line #221: r.Expr([]interface{}{1}).Gt([]interface{}{2})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1}).Gt([]interface{}{2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #221") } { // math_logic/comparison.yaml line #226 /* true */ var expected_ bool = true /* r.expr([1, 0]) < [2] */ suite.T().Log("About to run line #226: r.Expr([]interface{}{1, 0}).Lt([]interface{}{2})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 0}).Lt([]interface{}{2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #226") } { // math_logic/comparison.yaml line #231 /* false */ var expected_ bool = false /* r.expr([1, 0]) < [1] */ suite.T().Log("About to run line #231: r.Expr([]interface{}{1, 0}).Lt([]interface{}{1})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 0}).Lt([]interface{}{1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #231") } { // math_logic/comparison.yaml line #236 /* true */ var expected_ bool = true /* r.expr([1, 0]) > [0] */ suite.T().Log("About to run line #236: r.Expr([]interface{}{1, 0}).Gt([]interface{}{0})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 0}).Gt([]interface{}{0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #236") } { // math_logic/comparison.yaml line #241 /* true */ var expected_ bool = true /* r.expr([1, 'a']) < [1, 'b'] */ suite.T().Log("About to run line #241: r.Expr([]interface{}{1, 'a'}).Lt([]interface{}{1, 'b'})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, "a"}).Lt([]interface{}{1, "b"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #241") } { // math_logic/comparison.yaml line #246 /* true */ var expected_ bool = true /* r.expr([0, 'z']) < [1, 'b'] */ suite.T().Log("About to run line #246: r.Expr([]interface{}{0, 'z'}).Lt([]interface{}{1, 'b'})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{0, "z"}).Lt([]interface{}{1, "b"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #246") } { // math_logic/comparison.yaml line #251 /* false */ var expected_ bool = false /* r.expr([1, 1, 1]) < [1, 0, 2] */ suite.T().Log("About to run line #251: r.Expr([]interface{}{1, 1, 1}).Lt([]interface{}{1, 0, 2})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 1, 1}).Lt([]interface{}{1, 0, 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #251") } { // math_logic/comparison.yaml line #256 /* true */ var expected_ bool = true /* r.expr([1, 0, 2]) < [1, 1, 1] */ suite.T().Log("About to run line #256: r.Expr([]interface{}{1, 0, 2}).Lt([]interface{}{1, 1, 1})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 0, 2}).Lt([]interface{}{1, 1, 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #256") } { // math_logic/comparison.yaml line #263 /* true */ var expected_ bool = true /* r.expr({'a':0}) == {'a':0} */ suite.T().Log("About to run line #263: r.Expr(map[interface{}]interface{}{'a': 0, }).Eq(map[interface{}]interface{}{'a': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0}).Eq(map[interface{}]interface{}{"a": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #263") } { // math_logic/comparison.yaml line #267 /* true */ var expected_ bool = true /* r.expr({'a':0, 'b':1}) == {'b':1, 'a':0} */ suite.T().Log("About to run line #267: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, }).Eq(map[interface{}]interface{}{'b': 1, 'a': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1}).Eq(map[interface{}]interface{}{"b": 1, "a": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #267") } { // math_logic/comparison.yaml line #271 /* false */ var expected_ bool = false /* r.expr({'a':0, 'b':1, 'c':2}) == {'b':1, 'a':0} */ suite.T().Log("About to run line #271: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, }).Eq(map[interface{}]interface{}{'b': 1, 'a': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}).Eq(map[interface{}]interface{}{"b": 1, "a": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #271") } { // math_logic/comparison.yaml line #275 /* false */ var expected_ bool = false /* r.expr({'a':0, 'b':1}) == {'b':1, 'a':0, 'c':2} */ suite.T().Log("About to run line #275: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, }).Eq(map[interface{}]interface{}{'b': 1, 'a': 0, 'c': 2, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1}).Eq(map[interface{}]interface{}{"b": 1, "a": 0, "c": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #275") } { // math_logic/comparison.yaml line #279 /* false */ var expected_ bool = false /* r.expr({'a':0, 'b':1, 'd':2}) == {'b':1, 'a':0, 'c':2} */ suite.T().Log("About to run line #279: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, 'd': 2, }).Eq(map[interface{}]interface{}{'b': 1, 'a': 0, 'c': 2, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1, "d": 2}).Eq(map[interface{}]interface{}{"b": 1, "a": 0, "c": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #279") } { // math_logic/comparison.yaml line #283 /* true */ var expected_ bool = true /* r.expr({'a':0}) < {'b':0} */ suite.T().Log("About to run line #283: r.Expr(map[interface{}]interface{}{'a': 0, }).Lt(map[interface{}]interface{}{'b': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0}).Lt(map[interface{}]interface{}{"b": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #283") } { // math_logic/comparison.yaml line #287 /* true */ var expected_ bool = true /* r.expr({'a':1}) < {'b':0} */ suite.T().Log("About to run line #287: r.Expr(map[interface{}]interface{}{'a': 1, }).Lt(map[interface{}]interface{}{'b': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 1}).Lt(map[interface{}]interface{}{"b": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #287") } { // math_logic/comparison.yaml line #291 /* false */ var expected_ bool = false /* r.expr({'b':1}) < {'b':0} */ suite.T().Log("About to run line #291: r.Expr(map[interface{}]interface{}{'b': 1, }).Lt(map[interface{}]interface{}{'b': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"b": 1}).Lt(map[interface{}]interface{}{"b": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #291") } { // math_logic/comparison.yaml line #295 /* false */ var expected_ bool = false /* r.expr({'b':1}) < {'a':0} */ suite.T().Log("About to run line #295: r.Expr(map[interface{}]interface{}{'b': 1, }).Lt(map[interface{}]interface{}{'a': 0, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"b": 1}).Lt(map[interface{}]interface{}{"a": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #295") } { // math_logic/comparison.yaml line #299 /* false */ var expected_ bool = false /* r.expr({'a':0, 'b':1, 'c':2}) < {'a':0, 'b':1, 'c':2} */ suite.T().Log("About to run line #299: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, }).Lt(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}).Lt(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #299") } { // math_logic/comparison.yaml line #303 /* false */ var expected_ bool = false /* r.expr({'a':0, 'b':1, 'c':2, 'd':3}) < {'a':0, 'b':1, 'c':2} */ suite.T().Log("About to run line #303: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, 'd': 3, }).Lt(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2, "d": 3}).Lt(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #303") } { // math_logic/comparison.yaml line #307 /* true */ var expected_ bool = true /* r.expr({'a':0, 'b':1, 'c':2}) < {'a':0, 'b':1, 'c':2, 'd':3} */ suite.T().Log("About to run line #307: r.Expr(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, }).Lt(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, 'd': 3, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}).Lt(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2, "d": 3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #307") } { // math_logic/comparison.yaml line #311 /* false */ var expected_ bool = false /* r.expr({'a':0, 'c':2}) < {'a':0, 'b':1, 'c':2} */ suite.T().Log("About to run line #311: r.Expr(map[interface{}]interface{}{'a': 0, 'c': 2, }).Lt(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "c": 2}).Lt(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #311") } { // math_logic/comparison.yaml line #315 /* true */ var expected_ bool = true /* r.expr({'a':0, 'c':2}) > {'a':0, 'b':1, 'c':2} */ suite.T().Log("About to run line #315: r.Expr(map[interface{}]interface{}{'a': 0, 'c': 2, }).Gt(map[interface{}]interface{}{'a': 0, 'b': 1, 'c': 2, })") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{"a": 0, "c": 2}).Gt(map[interface{}]interface{}{"a": 0, "b": 1, "c": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #315") } // math_logic/comparison.yaml line #331 // everything = r.expr([[],r.now(),r.binary(b"\x00"),false,null,-5,{},"a",r.maxval]) suite.T().Log("Possibly executing: var everything r.Term = r.Expr([]interface{}{[]interface{}{}, r.Now(), r.Binary([]byte{0}), false, nil, -5, map[interface{}]interface{}{}, 'a', r.MaxVal})") everything := r.Expr([]interface{}{[]interface{}{}, r.Now(), r.Binary([]byte{0}), false, nil, -5, map[interface{}]interface{}{}, "a", r.MaxVal}) _ = everything // Prevent any noused variable errors { // math_logic/comparison.yaml line #336 /* true */ var expected_ bool = true /* r.and_(r.args(everything.map(r.lt(r.minval, r.row)))) */ suite.T().Log("About to run line #336: r.And(r.Args(everything.Map(r.Lt(r.MinVal, r.Row))))") runAndAssert(suite.Suite, expected_, r.And(r.Args(everything.Map(r.Lt(r.MinVal, r.Row)))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #336") } { // math_logic/comparison.yaml line #341 /* false */ var expected_ bool = false /* r.or_(r.args(everything.map(r.gt(r.minval, r.row)))) */ suite.T().Log("About to run line #341: r.Or(r.Args(everything.Map(r.Gt(r.MinVal, r.Row))))") runAndAssert(suite.Suite, expected_, r.Or(r.Args(everything.Map(r.Gt(r.MinVal, r.Row)))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #341") } { // math_logic/comparison.yaml line #345 /* true */ var expected_ bool = true /* r.eq(r.minval, r.minval) */ suite.T().Log("About to run line #345: r.Eq(r.MinVal, r.MinVal)") runAndAssert(suite.Suite, expected_, r.Eq(r.MinVal, r.MinVal), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #345") } { // math_logic/comparison.yaml line #348 /* true */ var expected_ bool = true /* r.expr([]) < True */ suite.T().Log("About to run line #348: r.Expr([]interface{}{}).Lt(true)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Lt(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #348") } { // math_logic/comparison.yaml line #353 /* true */ var expected_ bool = true /* r.expr([1,2]) < False */ suite.T().Log("About to run line #353: r.Expr([]interface{}{1, 2}).Lt(false)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Lt(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #353") } { // math_logic/comparison.yaml line #358 /* false */ var expected_ bool = false /* r.expr(False) < [] */ suite.T().Log("About to run line #358: r.Expr(false).Lt([]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr(false).Lt([]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #358") } { // math_logic/comparison.yaml line #363 /* true */ var expected_ bool = true /* r.expr([]) < r.binary(b"\xAE") */ suite.T().Log("About to run line #363: r.Expr([]interface{}{}).Lt(r.Binary([]byte{174}))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Lt(r.Binary([]byte{174})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #363") } { // math_logic/comparison.yaml line #368 /* true */ var expected_ bool = true /* r.expr([1,2]) < r.binary(b"\xAE") */ suite.T().Log("About to run line #368: r.Expr([]interface{}{1, 2}).Lt(r.Binary([]byte{174}))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Lt(r.Binary([]byte{174})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #368") } { // math_logic/comparison.yaml line #373 /* true */ var expected_ bool = true /* True < r.expr(null) */ suite.T().Log("About to run line #373: r.Lt(true, r.Expr(nil))") runAndAssert(suite.Suite, expected_, r.Lt(true, r.Expr(nil)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #373") } { // math_logic/comparison.yaml line #378 /* true */ var expected_ bool = true /* r.expr(null) > [] */ suite.T().Log("About to run line #378: r.Expr(nil).Gt([]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr(nil).Gt([]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #378") } { // math_logic/comparison.yaml line #383 /* true */ var expected_ bool = true /* r.expr(null) < 12 */ suite.T().Log("About to run line #383: r.Expr(nil).Lt(12)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Lt(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #383") } { // math_logic/comparison.yaml line #388 /* true */ var expected_ bool = true /* r.expr(null) < -2 */ suite.T().Log("About to run line #388: r.Expr(nil).Lt(-2)") runAndAssert(suite.Suite, expected_, r.Expr(nil).Lt(-2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #388") } { // math_logic/comparison.yaml line #393 /* true */ var expected_ bool = true /* r.expr(-12) < {} */ suite.T().Log("About to run line #393: r.Expr(-12).Lt(map[interface{}]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr(-12).Lt(map[interface{}]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #393") } { // math_logic/comparison.yaml line #398 /* true */ var expected_ bool = true /* r.expr(100) < {'a':-12} */ suite.T().Log("About to run line #398: r.Expr(100).Lt(map[interface{}]interface{}{'a': -12, })") runAndAssert(suite.Suite, expected_, r.Expr(100).Lt(map[interface{}]interface{}{"a": -12}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #398") } { // math_logic/comparison.yaml line #403 /* false */ var expected_ bool = false /* r.expr(r.binary(b"\xAE")) < 12 */ suite.T().Log("About to run line #403: r.Expr(r.Binary([]byte{174})).Lt(12)") runAndAssert(suite.Suite, expected_, r.Expr(r.Binary([]byte{174})).Lt(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #403") } { // math_logic/comparison.yaml line #408 /* true */ var expected_ bool = true /* r.binary(b"0xAE") < 'abc' */ suite.T().Log("About to run line #408: r.Binary([]byte{48,120,65,69}).Lt('abc')") runAndAssert(suite.Suite, expected_, r.Binary([]byte{48, 120, 65, 69}).Lt("abc"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #408") } { // math_logic/comparison.yaml line #413 /* false */ var expected_ bool = false /* r.binary(b"0xAE") > r.now() */ suite.T().Log("About to run line #413: r.Binary([]byte{48,120,65,69}).Gt(r.Now())") runAndAssert(suite.Suite, expected_, r.Binary([]byte{48, 120, 65, 69}).Gt(r.Now()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #413") } { // math_logic/comparison.yaml line #418 /* true */ var expected_ bool = true /* r.now() > 12 */ suite.T().Log("About to run line #418: r.Now().Gt(12)") runAndAssert(suite.Suite, expected_, r.Now().Gt(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #418") } { // math_logic/comparison.yaml line #422 /* false */ var expected_ bool = false /* r.now() > 'abc' */ suite.T().Log("About to run line #422: r.Now().Gt('abc')") runAndAssert(suite.Suite, expected_, r.Now().Gt("abc"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #422") } { // math_logic/comparison.yaml line #426 /* true */ var expected_ bool = true /* r.expr("abc") > {'a':-12} */ suite.T().Log("About to run line #426: r.Expr('abc').Gt(map[interface{}]interface{}{'a': -12, })") runAndAssert(suite.Suite, expected_, r.Expr("abc").Gt(map[interface{}]interface{}{"a": -12}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #426") } { // math_logic/comparison.yaml line #431 /* true */ var expected_ bool = true /* r.expr("abc") > {'abc':'abc'} */ suite.T().Log("About to run line #431: r.Expr('abc').Gt(map[interface{}]interface{}{'abc': 'abc', })") runAndAssert(suite.Suite, expected_, r.Expr("abc").Gt(map[interface{}]interface{}{"abc": "abc"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #431") } { // math_logic/comparison.yaml line #436 /* true */ var expected_ bool = true /* r.expr('zzz') > 128 */ suite.T().Log("About to run line #436: r.Expr('zzz').Gt(128)") runAndAssert(suite.Suite, expected_, r.Expr("zzz").Gt(128), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #436") } { // math_logic/comparison.yaml line #441 /* true */ var expected_ bool = true /* r.expr('zzz') > {} */ suite.T().Log("About to run line #441: r.Expr('zzz').Gt(map[interface{}]interface{}{})") runAndAssert(suite.Suite, expected_, r.Expr("zzz").Gt(map[interface{}]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #441") } { // math_logic/comparison.yaml line #446 /* true */ var expected_ bool = true /* 'zzz' > r.expr(-152) */ suite.T().Log("About to run line #446: r.Gt('zzz', r.Expr(-152))") runAndAssert(suite.Suite, expected_, r.Gt("zzz", r.Expr(-152)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #446") } { // math_logic/comparison.yaml line #451 /* true */ var expected_ bool = true /* 'zzz' > r.expr(null) */ suite.T().Log("About to run line #451: r.Gt('zzz', r.Expr(nil))") runAndAssert(suite.Suite, expected_, r.Gt("zzz", r.Expr(nil)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #451") } { // math_logic/comparison.yaml line #456 /* true */ var expected_ bool = true /* 'zzz' > r.expr([]) */ suite.T().Log("About to run line #456: r.Gt('zzz', r.Expr([]interface{}{}))") runAndAssert(suite.Suite, expected_, r.Gt("zzz", r.Expr([]interface{}{})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #456") } // math_logic/comparison.yaml line #463 // everything2 = r.expr([r.minval,[],r.now(),r.binary(b"\x00"),false,null,-5,{},"a"]) suite.T().Log("Possibly executing: var everything2 r.Term = r.Expr([]interface{}{r.MinVal, []interface{}{}, r.Now(), r.Binary([]byte{0}), false, nil, -5, map[interface{}]interface{}{}, 'a'})") everything2 := r.Expr([]interface{}{r.MinVal, []interface{}{}, r.Now(), r.Binary([]byte{0}), false, nil, -5, map[interface{}]interface{}{}, "a"}) _ = everything2 // Prevent any noused variable errors { // math_logic/comparison.yaml line #467 /* true */ var expected_ bool = true /* r.and_(r.args(everything2.map(r.gt(r.maxval, r.row)))) */ suite.T().Log("About to run line #467: r.And(r.Args(everything2.Map(r.Gt(r.MaxVal, r.Row))))") runAndAssert(suite.Suite, expected_, r.And(r.Args(everything2.Map(r.Gt(r.MaxVal, r.Row)))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #467") } { // math_logic/comparison.yaml line #472 /* false */ var expected_ bool = false /* r.or_(r.args(everything2.map(r.lt(r.maxval, r.row)))) */ suite.T().Log("About to run line #472: r.Or(r.Args(everything2.Map(r.Lt(r.MaxVal, r.Row))))") runAndAssert(suite.Suite, expected_, r.Or(r.Args(everything2.Map(r.Lt(r.MaxVal, r.Row)))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #472") } { // math_logic/comparison.yaml line #476 /* true */ var expected_ bool = true /* r.eq(r.maxval, r.maxval) */ suite.T().Log("About to run line #476: r.Eq(r.MaxVal, r.MaxVal)") runAndAssert(suite.Suite, expected_, r.Eq(r.MaxVal, r.MaxVal), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #476") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_div_test.go000066400000000000000000000163451363464422500300240ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests for the basic usage of the division operation func TestMathLogicDivSuite(t *testing.T) { suite.Run(t, new(MathLogicDivSuite)) } type MathLogicDivSuite struct { suite.Suite session *r.Session } func (suite *MathLogicDivSuite) SetupTest() { suite.T().Log("Setting up MathLogicDivSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_div").Exec(suite.session) err = r.DBCreate("db_logic_div").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_div").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicDivSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicDivSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_div").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicDivSuite) TestCases() { suite.T().Log("Running MathLogicDivSuite: Tests for the basic usage of the division operation") { // math_logic/div.yaml line #6 /* 2 */ var expected_ int = 2 /* r.expr(4) / 2 */ suite.T().Log("About to run line #6: r.Expr(4).Div(2)") runAndAssert(suite.Suite, expected_, r.Expr(4).Div(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // math_logic/div.yaml line #7 /* 2 */ var expected_ int = 2 /* 4 / r.expr(2) */ suite.T().Log("About to run line #7: r.Div(4, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Div(4, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // math_logic/div.yaml line #8 /* 2 */ var expected_ int = 2 /* r.expr(4).div(2) */ suite.T().Log("About to run line #8: r.Expr(4).Div(2)") runAndAssert(suite.Suite, expected_, r.Expr(4).Div(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/div.yaml line #15 /* 0.5 */ var expected_ float64 = 0.5 /* r.expr(-1) / -2 */ suite.T().Log("About to run line #15: r.Expr(-1).Div(-2)") runAndAssert(suite.Suite, expected_, r.Expr(-1).Div(-2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // math_logic/div.yaml line #20 /* 4.9 / 0.7 */ var expected_ float64 = 4.9 / 0.7 /* r.expr(4.9) / 0.7 */ suite.T().Log("About to run line #20: r.Expr(4.9).Div(0.7)") runAndAssert(suite.Suite, expected_, r.Expr(4.9).Div(0.7), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // math_logic/div.yaml line #25 /* 1.0/120 */ var expected_ float64 = 1.0 / 120 /* r.expr(1).div(2,3,4,5) */ suite.T().Log("About to run line #25: r.Expr(1).Div(2, 3, 4, 5)") runAndAssert(suite.Suite, expected_, r.Expr(1).Div(2, 3, 4, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // math_logic/div.yaml line #37 /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") /* r.expr(1) / 0 */ suite.T().Log("About to run line #37: r.Expr(1).Div(0)") runAndAssert(suite.Suite, expected_, r.Expr(1).Div(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // math_logic/div.yaml line #38 /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") /* r.expr(2.0) / 0 */ suite.T().Log("About to run line #38: r.Expr(2.0).Div(0)") runAndAssert(suite.Suite, expected_, r.Expr(2.0).Div(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // math_logic/div.yaml line #39 /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") /* r.expr(3) / 0.0 */ suite.T().Log("About to run line #39: r.Expr(3).Div(0.0)") runAndAssert(suite.Suite, expected_, r.Expr(3).Div(0.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // math_logic/div.yaml line #40 /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") /* r.expr(4.0) / 0.0 */ suite.T().Log("About to run line #40: r.Expr(4.0).Div(0.0)") runAndAssert(suite.Suite, expected_, r.Expr(4.0).Div(0.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // math_logic/div.yaml line #41 /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") /* r.expr(0) / 0 */ suite.T().Log("About to run line #41: r.Expr(0).Div(0)") runAndAssert(suite.Suite, expected_, r.Expr(0).Div(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #41") } { // math_logic/div.yaml line #42 /* err('ReqlQueryLogicError', 'Cannot divide by zero.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot divide by zero.") /* r.expr(0.0) / 0.0 */ suite.T().Log("About to run line #42: r.Expr(0.0).Div(0.0)") runAndAssert(suite.Suite, expected_, r.Expr(0.0).Div(0.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // math_logic/div.yaml line #46 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('a') / 0.8 */ suite.T().Log("About to run line #46: r.Expr('a').Div(0.8)") runAndAssert(suite.Suite, expected_, r.Expr("a").Div(0.8), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // math_logic/div.yaml line #50 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr(1) / 'a' */ suite.T().Log("About to run line #50: r.Expr(1).Div('a')") runAndAssert(suite.Suite, expected_, r.Expr(1).Div("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_floor_ceil_round_test.go000066400000000000000000000464161363464422500325700ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // tests for `floor`, `ceil`, and `round`, tests inspired by the Python test suite func TestMathLogicFloorCeilRoundSuite(t *testing.T) { suite.Run(t, new(MathLogicFloorCeilRoundSuite)) } type MathLogicFloorCeilRoundSuite struct { suite.Suite session *r.Session } func (suite *MathLogicFloorCeilRoundSuite) SetupTest() { suite.T().Log("Setting up MathLogicFloorCeilRoundSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_floor").Exec(suite.session) err = r.DBCreate("db_logic_floor").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_floor").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicFloorCeilRoundSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicFloorCeilRoundSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_floor").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicFloorCeilRoundSuite) TestCases() { suite.T().Log("Running MathLogicFloorCeilRoundSuite: tests for `floor`, `ceil`, and `round`, tests inspired by the Python test suite") { // math_logic/floor_ceil_round.yaml line #3 /* "NUMBER" */ var expected_ string = "NUMBER" /* r.floor(1.0).type_of() */ suite.T().Log("About to run line #3: r.Floor(1.0).TypeOf()") runAndAssert(suite.Suite, expected_, r.Floor(1.0).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #3") } { // math_logic/floor_ceil_round.yaml line #5 /* 1.0 */ var expected_ float64 = 1.0 /* r.floor(1.0) */ suite.T().Log("About to run line #5: r.Floor(1.0)") runAndAssert(suite.Suite, expected_, r.Floor(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // math_logic/floor_ceil_round.yaml line #7 /* 1.0 */ var expected_ float64 = 1.0 /* r.expr(1.0).floor() */ suite.T().Log("About to run line #7: r.Expr(1.0).Floor()") runAndAssert(suite.Suite, expected_, r.Expr(1.0).Floor(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // math_logic/floor_ceil_round.yaml line #10 /* 0.0 */ var expected_ float64 = 0.0 /* r.floor(0.5) */ suite.T().Log("About to run line #10: r.Floor(0.5)") runAndAssert(suite.Suite, expected_, r.Floor(0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // math_logic/floor_ceil_round.yaml line #12 /* 1.0 */ var expected_ float64 = 1.0 /* r.floor(1.0) */ suite.T().Log("About to run line #12: r.Floor(1.0)") runAndAssert(suite.Suite, expected_, r.Floor(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // math_logic/floor_ceil_round.yaml line #14 /* 1.0 */ var expected_ float64 = 1.0 /* r.floor(1.5) */ suite.T().Log("About to run line #14: r.Floor(1.5)") runAndAssert(suite.Suite, expected_, r.Floor(1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // math_logic/floor_ceil_round.yaml line #16 /* -1.0 */ var expected_ float64 = -1.0 /* r.floor(-0.5) */ suite.T().Log("About to run line #16: r.Floor(-0.5)") runAndAssert(suite.Suite, expected_, r.Floor(-0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // math_logic/floor_ceil_round.yaml line #18 /* -1.0 */ var expected_ float64 = -1.0 /* r.floor(-1.0) */ suite.T().Log("About to run line #18: r.Floor(-1.0)") runAndAssert(suite.Suite, expected_, r.Floor(-1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // math_logic/floor_ceil_round.yaml line #20 /* -2.0 */ var expected_ float64 = -2.0 /* r.floor(-1.5) */ suite.T().Log("About to run line #20: r.Floor(-1.5)") runAndAssert(suite.Suite, expected_, r.Floor(-1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // math_logic/floor_ceil_round.yaml line #23 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('X').floor() */ suite.T().Log("About to run line #23: r.Expr('X').Floor()") runAndAssert(suite.Suite, expected_, r.Expr("X").Floor(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // math_logic/floor_ceil_round.yaml line #27 /* "NUMBER" */ var expected_ string = "NUMBER" /* r.ceil(1.0).type_of() */ suite.T().Log("About to run line #27: r.Ceil(1.0).TypeOf()") runAndAssert(suite.Suite, expected_, r.Ceil(1.0).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // math_logic/floor_ceil_round.yaml line #29 /* 1.0 */ var expected_ float64 = 1.0 /* r.ceil(1.0) */ suite.T().Log("About to run line #29: r.Ceil(1.0)") runAndAssert(suite.Suite, expected_, r.Ceil(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // math_logic/floor_ceil_round.yaml line #31 /* 1.0 */ var expected_ float64 = 1.0 /* r.expr(1.0).ceil() */ suite.T().Log("About to run line #31: r.Expr(1.0).Ceil()") runAndAssert(suite.Suite, expected_, r.Expr(1.0).Ceil(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // math_logic/floor_ceil_round.yaml line #34 /* 1.0 */ var expected_ float64 = 1.0 /* r.ceil(0.5) */ suite.T().Log("About to run line #34: r.Ceil(0.5)") runAndAssert(suite.Suite, expected_, r.Ceil(0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // math_logic/floor_ceil_round.yaml line #36 /* 1.0 */ var expected_ float64 = 1.0 /* r.ceil(1.0) */ suite.T().Log("About to run line #36: r.Ceil(1.0)") runAndAssert(suite.Suite, expected_, r.Ceil(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // math_logic/floor_ceil_round.yaml line #38 /* 2.0 */ var expected_ float64 = 2.0 /* r.ceil(1.5) */ suite.T().Log("About to run line #38: r.Ceil(1.5)") runAndAssert(suite.Suite, expected_, r.Ceil(1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // math_logic/floor_ceil_round.yaml line #40 /* 0.0 */ var expected_ float64 = 0.0 /* r.ceil(-0.5) */ suite.T().Log("About to run line #40: r.Ceil(-0.5)") runAndAssert(suite.Suite, expected_, r.Ceil(-0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // math_logic/floor_ceil_round.yaml line #42 /* -1.0 */ var expected_ float64 = -1.0 /* r.ceil(-1.0) */ suite.T().Log("About to run line #42: r.Ceil(-1.0)") runAndAssert(suite.Suite, expected_, r.Ceil(-1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // math_logic/floor_ceil_round.yaml line #44 /* -1.0 */ var expected_ float64 = -1.0 /* r.ceil(-1.5) */ suite.T().Log("About to run line #44: r.Ceil(-1.5)") runAndAssert(suite.Suite, expected_, r.Ceil(-1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // math_logic/floor_ceil_round.yaml line #47 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('X').ceil() */ suite.T().Log("About to run line #47: r.Expr('X').Ceil()") runAndAssert(suite.Suite, expected_, r.Expr("X").Ceil(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // math_logic/floor_ceil_round.yaml line #51 /* "NUMBER" */ var expected_ string = "NUMBER" /* r.round(1.0).type_of() */ suite.T().Log("About to run line #51: r.Round(1.0).TypeOf()") runAndAssert(suite.Suite, expected_, r.Round(1.0).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // math_logic/floor_ceil_round.yaml line #53 /* 1.0 */ var expected_ float64 = 1.0 /* r.round(1.0) */ suite.T().Log("About to run line #53: r.Round(1.0)") runAndAssert(suite.Suite, expected_, r.Round(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // math_logic/floor_ceil_round.yaml line #55 /* 1.0 */ var expected_ float64 = 1.0 /* r.expr(1.0).round() */ suite.T().Log("About to run line #55: r.Expr(1.0).Round()") runAndAssert(suite.Suite, expected_, r.Expr(1.0).Round(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // math_logic/floor_ceil_round.yaml line #58 /* 1.0 */ var expected_ float64 = 1.0 /* r.round(0.5) */ suite.T().Log("About to run line #58: r.Round(0.5)") runAndAssert(suite.Suite, expected_, r.Round(0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // math_logic/floor_ceil_round.yaml line #60 /* -1.0 */ var expected_ float64 = -1.0 /* r.round(-0.5) */ suite.T().Log("About to run line #60: r.Round(-0.5)") runAndAssert(suite.Suite, expected_, r.Round(-0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // math_logic/floor_ceil_round.yaml line #63 /* 0.0 */ var expected_ float64 = 0.0 /* r.round(0.0) */ suite.T().Log("About to run line #63: r.Round(0.0)") runAndAssert(suite.Suite, expected_, r.Round(0.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } { // math_logic/floor_ceil_round.yaml line #65 /* 1.0 */ var expected_ float64 = 1.0 /* r.round(1.0) */ suite.T().Log("About to run line #65: r.Round(1.0)") runAndAssert(suite.Suite, expected_, r.Round(1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // math_logic/floor_ceil_round.yaml line #67 /* 10.0 */ var expected_ float64 = 10.0 /* r.round(10.0) */ suite.T().Log("About to run line #67: r.Round(10.0)") runAndAssert(suite.Suite, expected_, r.Round(10.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #67") } { // math_logic/floor_ceil_round.yaml line #69 /* 1000000000.0 */ var expected_ float64 = 1000000000.0 /* r.round(1000000000.0) */ suite.T().Log("About to run line #69: r.Round(1000000000.0)") runAndAssert(suite.Suite, expected_, r.Round(1000000000.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } { // math_logic/floor_ceil_round.yaml line #71 /* 1e20 */ var expected_ float64 = 1e+20 /* r.round(1e20) */ suite.T().Log("About to run line #71: r.Round(1e+20)") runAndAssert(suite.Suite, expected_, r.Round(1e+20), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // math_logic/floor_ceil_round.yaml line #74 /* -1.0 */ var expected_ float64 = -1.0 /* r.round(-1.0) */ suite.T().Log("About to run line #74: r.Round(-1.0)") runAndAssert(suite.Suite, expected_, r.Round(-1.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } { // math_logic/floor_ceil_round.yaml line #76 /* -10.0 */ var expected_ float64 = -10.0 /* r.round(-10.0) */ suite.T().Log("About to run line #76: r.Round(-10.0)") runAndAssert(suite.Suite, expected_, r.Round(-10.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #76") } { // math_logic/floor_ceil_round.yaml line #78 /* -1000000000.0 */ var expected_ float64 = -1000000000.0 /* r.round(-1000000000.0) */ suite.T().Log("About to run line #78: r.Round(-1000000000.0)") runAndAssert(suite.Suite, expected_, r.Round(-1000000000.0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #78") } { // math_logic/floor_ceil_round.yaml line #80 /* -1e20 */ var expected_ float64 = -1e+20 /* r.round(-1e20) */ suite.T().Log("About to run line #80: r.Round(-1e+20)") runAndAssert(suite.Suite, expected_, r.Round(-1e+20), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #80") } { // math_logic/floor_ceil_round.yaml line #83 /* 0.0 */ var expected_ float64 = 0.0 /* r.round(0.1) */ suite.T().Log("About to run line #83: r.Round(0.1)") runAndAssert(suite.Suite, expected_, r.Round(0.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // math_logic/floor_ceil_round.yaml line #85 /* 1.0 */ var expected_ float64 = 1.0 /* r.round(1.1) */ suite.T().Log("About to run line #85: r.Round(1.1)") runAndAssert(suite.Suite, expected_, r.Round(1.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #85") } { // math_logic/floor_ceil_round.yaml line #87 /* 10.0 */ var expected_ float64 = 10.0 /* r.round(10.1) */ suite.T().Log("About to run line #87: r.Round(10.1)") runAndAssert(suite.Suite, expected_, r.Round(10.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } { // math_logic/floor_ceil_round.yaml line #89 /* 1000000000.0 */ var expected_ float64 = 1000000000.0 /* r.round(1000000000.1) */ suite.T().Log("About to run line #89: r.Round(1000000000.1)") runAndAssert(suite.Suite, expected_, r.Round(1000000000.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #89") } { // math_logic/floor_ceil_round.yaml line #92 /* -1.0 */ var expected_ float64 = -1.0 /* r.round(-1.1) */ suite.T().Log("About to run line #92: r.Round(-1.1)") runAndAssert(suite.Suite, expected_, r.Round(-1.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } { // math_logic/floor_ceil_round.yaml line #94 /* -10.0 */ var expected_ float64 = -10.0 /* r.round(-10.1) */ suite.T().Log("About to run line #94: r.Round(-10.1)") runAndAssert(suite.Suite, expected_, r.Round(-10.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #94") } { // math_logic/floor_ceil_round.yaml line #96 /* -1000000000.0 */ var expected_ float64 = -1000000000.0 /* r.round(-1000000000.1) */ suite.T().Log("About to run line #96: r.Round(-1000000000.1)") runAndAssert(suite.Suite, expected_, r.Round(-1000000000.1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #96") } { // math_logic/floor_ceil_round.yaml line #99 /* 1.0 */ var expected_ float64 = 1.0 /* r.round(0.9) */ suite.T().Log("About to run line #99: r.Round(0.9)") runAndAssert(suite.Suite, expected_, r.Round(0.9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #99") } { // math_logic/floor_ceil_round.yaml line #101 /* 10.0 */ var expected_ float64 = 10.0 /* r.round(9.9) */ suite.T().Log("About to run line #101: r.Round(9.9)") runAndAssert(suite.Suite, expected_, r.Round(9.9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } { // math_logic/floor_ceil_round.yaml line #103 /* 1000000000.0 */ var expected_ float64 = 1000000000.0 /* r.round(999999999.9) */ suite.T().Log("About to run line #103: r.Round(999999999.9)") runAndAssert(suite.Suite, expected_, r.Round(999999999.9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // math_logic/floor_ceil_round.yaml line #106 /* -1.0 */ var expected_ float64 = -1.0 /* r.round(-0.9) */ suite.T().Log("About to run line #106: r.Round(-0.9)") runAndAssert(suite.Suite, expected_, r.Round(-0.9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } { // math_logic/floor_ceil_round.yaml line #108 /* -10.0 */ var expected_ float64 = -10.0 /* r.round(-9.9) */ suite.T().Log("About to run line #108: r.Round(-9.9)") runAndAssert(suite.Suite, expected_, r.Round(-9.9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // math_logic/floor_ceil_round.yaml line #110 /* -1000000000.0 */ var expected_ float64 = -1000000000.0 /* r.round(-999999999.9) */ suite.T().Log("About to run line #110: r.Round(-999999999.9)") runAndAssert(suite.Suite, expected_, r.Round(-999999999.9), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // math_logic/floor_ceil_round.yaml line #113 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('X').round() */ suite.T().Log("About to run line #113: r.Expr('X').Round()") runAndAssert(suite.Suite, expected_, r.Expr("X").Round(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #113") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_logic_test.go000066400000000000000000000473061363464422500303400ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // These tests are aimed at &&, ||, and ! func TestMathLogicLogicSuite(t *testing.T) { suite.Run(t, new(MathLogicLogicSuite)) } type MathLogicLogicSuite struct { suite.Suite session *r.Session } func (suite *MathLogicLogicSuite) SetupTest() { suite.T().Log("Setting up MathLogicLogicSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic2").Exec(suite.session) err = r.DBCreate("db_logic2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic2").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicLogicSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicLogicSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic2").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicLogicSuite) TestCases() { suite.T().Log("Running MathLogicLogicSuite: These tests are aimed at &&, ||, and !") { // math_logic/logic.yaml line #8 /* true */ var expected_ bool = true /* r.expr(true) & true */ suite.T().Log("About to run line #8: r.Expr(true).And(true)") runAndAssert(suite.Suite, expected_, r.Expr(true).And(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/logic.yaml line #9 /* true */ var expected_ bool = true /* true & r.expr(true) */ suite.T().Log("About to run line #9: r.And(true, r.Expr(true))") runAndAssert(suite.Suite, expected_, r.And(true, r.Expr(true)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // math_logic/logic.yaml line #10 /* true */ var expected_ bool = true /* r.and_(true,true) */ suite.T().Log("About to run line #10: r.And(true, true)") runAndAssert(suite.Suite, expected_, r.And(true, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // math_logic/logic.yaml line #11 /* true */ var expected_ bool = true /* r.expr(true).and_(true) */ suite.T().Log("About to run line #11: r.Expr(true).And(true)") runAndAssert(suite.Suite, expected_, r.Expr(true).And(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // math_logic/logic.yaml line #22 /* false */ var expected_ bool = false /* r.expr(true) & false */ suite.T().Log("About to run line #22: r.Expr(true).And(false)") runAndAssert(suite.Suite, expected_, r.Expr(true).And(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // math_logic/logic.yaml line #23 /* false */ var expected_ bool = false /* r.expr(false) & false */ suite.T().Log("About to run line #23: r.Expr(false).And(false)") runAndAssert(suite.Suite, expected_, r.Expr(false).And(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // math_logic/logic.yaml line #24 /* false */ var expected_ bool = false /* true & r.expr(false) */ suite.T().Log("About to run line #24: r.And(true, r.Expr(false))") runAndAssert(suite.Suite, expected_, r.And(true, r.Expr(false)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // math_logic/logic.yaml line #25 /* false */ var expected_ bool = false /* false & r.expr(false) */ suite.T().Log("About to run line #25: r.And(false, r.Expr(false))") runAndAssert(suite.Suite, expected_, r.And(false, r.Expr(false)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // math_logic/logic.yaml line #26 /* false */ var expected_ bool = false /* r.and_(true,false) */ suite.T().Log("About to run line #26: r.And(true, false)") runAndAssert(suite.Suite, expected_, r.And(true, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // math_logic/logic.yaml line #27 /* false */ var expected_ bool = false /* r.and_(false,false) */ suite.T().Log("About to run line #27: r.And(false, false)") runAndAssert(suite.Suite, expected_, r.And(false, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // math_logic/logic.yaml line #28 /* false */ var expected_ bool = false /* r.expr(true).and_(false) */ suite.T().Log("About to run line #28: r.Expr(true).And(false)") runAndAssert(suite.Suite, expected_, r.Expr(true).And(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // math_logic/logic.yaml line #29 /* false */ var expected_ bool = false /* r.expr(false).and_(false) */ suite.T().Log("About to run line #29: r.Expr(false).And(false)") runAndAssert(suite.Suite, expected_, r.Expr(false).And(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // math_logic/logic.yaml line #48 /* true */ var expected_ bool = true /* r.expr(true) | true */ suite.T().Log("About to run line #48: r.Expr(true).Or(true)") runAndAssert(suite.Suite, expected_, r.Expr(true).Or(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #48") } { // math_logic/logic.yaml line #49 /* true */ var expected_ bool = true /* r.expr(true) | false */ suite.T().Log("About to run line #49: r.Expr(true).Or(false)") runAndAssert(suite.Suite, expected_, r.Expr(true).Or(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // math_logic/logic.yaml line #50 /* true */ var expected_ bool = true /* true | r.expr(true) */ suite.T().Log("About to run line #50: r.Or(true, r.Expr(true))") runAndAssert(suite.Suite, expected_, r.Or(true, r.Expr(true)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // math_logic/logic.yaml line #51 /* true */ var expected_ bool = true /* true | r.expr(false) */ suite.T().Log("About to run line #51: r.Or(true, r.Expr(false))") runAndAssert(suite.Suite, expected_, r.Or(true, r.Expr(false)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // math_logic/logic.yaml line #52 /* true */ var expected_ bool = true /* r.or_(true,true) */ suite.T().Log("About to run line #52: r.Or(true, true)") runAndAssert(suite.Suite, expected_, r.Or(true, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // math_logic/logic.yaml line #53 /* true */ var expected_ bool = true /* r.or_(true,false) */ suite.T().Log("About to run line #53: r.Or(true, false)") runAndAssert(suite.Suite, expected_, r.Or(true, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // math_logic/logic.yaml line #54 /* true */ var expected_ bool = true /* r.expr(true).or_(true) */ suite.T().Log("About to run line #54: r.Expr(true).Or(true)") runAndAssert(suite.Suite, expected_, r.Expr(true).Or(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // math_logic/logic.yaml line #55 /* true */ var expected_ bool = true /* r.expr(true).or_(false) */ suite.T().Log("About to run line #55: r.Expr(true).Or(false)") runAndAssert(suite.Suite, expected_, r.Expr(true).Or(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // math_logic/logic.yaml line #72 /* false */ var expected_ bool = false /* r.expr(false) | false */ suite.T().Log("About to run line #72: r.Expr(false).Or(false)") runAndAssert(suite.Suite, expected_, r.Expr(false).Or(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #72") } { // math_logic/logic.yaml line #73 /* false */ var expected_ bool = false /* false | r.expr(false) */ suite.T().Log("About to run line #73: r.Or(false, r.Expr(false))") runAndAssert(suite.Suite, expected_, r.Or(false, r.Expr(false)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // math_logic/logic.yaml line #74 /* false */ var expected_ bool = false /* r.and_(false,false) */ suite.T().Log("About to run line #74: r.And(false, false)") runAndAssert(suite.Suite, expected_, r.And(false, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } { // math_logic/logic.yaml line #75 /* false */ var expected_ bool = false /* r.expr(false).and_(false) */ suite.T().Log("About to run line #75: r.Expr(false).And(false)") runAndAssert(suite.Suite, expected_, r.Expr(false).And(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } { // math_logic/logic.yaml line #88 /* false */ var expected_ bool = false /* ~r.expr(True) */ suite.T().Log("About to run line #88: r.Expr(true).Not()") runAndAssert(suite.Suite, expected_, r.Expr(true).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #88") } { // math_logic/logic.yaml line #89 /* false */ var expected_ bool = false /* r.not_(True) */ suite.T().Log("About to run line #89: r.Not(true)") runAndAssert(suite.Suite, expected_, r.Not(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #89") } { // math_logic/logic.yaml line #93 /* true */ var expected_ bool = true /* ~r.expr(False) */ suite.T().Log("About to run line #93: r.Expr(false).Not()") runAndAssert(suite.Suite, expected_, r.Expr(false).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } { // math_logic/logic.yaml line #94 /* true */ var expected_ bool = true /* r.not_(False) */ suite.T().Log("About to run line #94: r.Not(false)") runAndAssert(suite.Suite, expected_, r.Not(false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #94") } { // math_logic/logic.yaml line #97 /* false */ var expected_ bool = false /* r.expr(True).not_() */ suite.T().Log("About to run line #97: r.Expr(true).Not()") runAndAssert(suite.Suite, expected_, r.Expr(true).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #97") } { // math_logic/logic.yaml line #100 /* true */ var expected_ bool = true /* r.expr(False).not_() */ suite.T().Log("About to run line #100: r.Expr(false).Not()") runAndAssert(suite.Suite, expected_, r.Expr(false).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // math_logic/logic.yaml line #107 /* true */ var expected_ bool = true /* ~r.and_(True, True) == r.or_(~r.expr(True), ~r.expr(True)) */ suite.T().Log("About to run line #107: r.And(true, true).Not().Eq(r.Or(r.Expr(true).Not(), r.Expr(true).Not()))") runAndAssert(suite.Suite, expected_, r.And(true, true).Not().Eq(r.Or(r.Expr(true).Not(), r.Expr(true).Not())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #107") } { // math_logic/logic.yaml line #108 /* true */ var expected_ bool = true /* ~r.and_(True, False) == r.or_(~r.expr(True), ~r.expr(False)) */ suite.T().Log("About to run line #108: r.And(true, false).Not().Eq(r.Or(r.Expr(true).Not(), r.Expr(false).Not()))") runAndAssert(suite.Suite, expected_, r.And(true, false).Not().Eq(r.Or(r.Expr(true).Not(), r.Expr(false).Not())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // math_logic/logic.yaml line #109 /* true */ var expected_ bool = true /* ~r.and_(False, False) == r.or_(~r.expr(False), ~r.expr(False)) */ suite.T().Log("About to run line #109: r.And(false, false).Not().Eq(r.Or(r.Expr(false).Not(), r.Expr(false).Not()))") runAndAssert(suite.Suite, expected_, r.And(false, false).Not().Eq(r.Or(r.Expr(false).Not(), r.Expr(false).Not())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // math_logic/logic.yaml line #110 /* true */ var expected_ bool = true /* ~r.and_(False, True) == r.or_(~r.expr(False), ~r.expr(True)) */ suite.T().Log("About to run line #110: r.And(false, true).Not().Eq(r.Or(r.Expr(false).Not(), r.Expr(true).Not()))") runAndAssert(suite.Suite, expected_, r.And(false, true).Not().Eq(r.Or(r.Expr(false).Not(), r.Expr(true).Not())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // math_logic/logic.yaml line #120 /* true */ var expected_ bool = true /* r.and_(True, True, True, True, True) */ suite.T().Log("About to run line #120: r.And(true, true, true, true, true)") runAndAssert(suite.Suite, expected_, r.And(true, true, true, true, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #120") } { // math_logic/logic.yaml line #123 /* false */ var expected_ bool = false /* r.and_(True, True, True, False, True) */ suite.T().Log("About to run line #123: r.And(true, true, true, false, true)") runAndAssert(suite.Suite, expected_, r.And(true, true, true, false, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } { // math_logic/logic.yaml line #126 /* false */ var expected_ bool = false /* r.and_(True, False, True, False, True) */ suite.T().Log("About to run line #126: r.And(true, false, true, false, true)") runAndAssert(suite.Suite, expected_, r.And(true, false, true, false, true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #126") } { // math_logic/logic.yaml line #129 /* false */ var expected_ bool = false /* r.or_(False, False, False, False, False) */ suite.T().Log("About to run line #129: r.Or(false, false, false, false, false)") runAndAssert(suite.Suite, expected_, r.Or(false, false, false, false, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #129") } { // math_logic/logic.yaml line #132 /* true */ var expected_ bool = true /* r.or_(False, False, False, True, False) */ suite.T().Log("About to run line #132: r.Or(false, false, false, true, false)") runAndAssert(suite.Suite, expected_, r.Or(false, false, false, true, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #132") } { // math_logic/logic.yaml line #135 /* true */ var expected_ bool = true /* r.or_(False, True, False, True, False) */ suite.T().Log("About to run line #135: r.Or(false, true, false, true, false)") runAndAssert(suite.Suite, expected_, r.Or(false, true, false, true, false), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #135") } { // math_logic/logic.yaml line #140 /* err("ReqlQueryLogicError", "Cannot perform bracket on a non-object non-sequence `\"a\"`.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot perform bracket on a non-object non-sequence `\"a\"`.") /* r.expr(r.expr('a')['b']).default(2) */ suite.T().Log("About to run line #140: r.Expr(r.Expr('a').AtIndex('b')).Default(2)") runAndAssert(suite.Suite, expected_, r.Expr(r.Expr("a").AtIndex("b")).Default(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #140") } { // math_logic/logic.yaml line #145 /* False */ var expected_ bool = false /* r.expr(r.and_(True, False) == r.or_(False, True)) */ suite.T().Log("About to run line #145: r.Expr(r.And(true, false).Eq(r.Or(false, true)))") runAndAssert(suite.Suite, expected_, r.Expr(r.And(true, false).Eq(r.Or(false, true))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #145") } { // math_logic/logic.yaml line #151 /* False */ var expected_ bool = false /* r.expr(r.and_(True, False) >= r.or_(False, True)) */ suite.T().Log("About to run line #151: r.Expr(r.And(true, false).Ge(r.Or(false, true)))") runAndAssert(suite.Suite, expected_, r.Expr(r.And(true, false).Ge(r.Or(false, true))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #151") } { // math_logic/logic.yaml line #155 /* true */ var expected_ bool = true /* r.expr(1) & True */ suite.T().Log("About to run line #155: r.Expr(1).And(true)") runAndAssert(suite.Suite, expected_, r.Expr(1).And(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #155") } { // math_logic/logic.yaml line #159 /* ("str") */ var expected_ string = "str" /* r.expr(False) | 'str' */ suite.T().Log("About to run line #159: r.Expr(false).Or('str')") runAndAssert(suite.Suite, expected_, r.Expr(false).Or("str"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // math_logic/logic.yaml line #163 /* false */ var expected_ bool = false /* ~r.expr(1) */ suite.T().Log("About to run line #163: r.Expr(1).Not()") runAndAssert(suite.Suite, expected_, r.Expr(1).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #163") } { // math_logic/logic.yaml line #167 /* true */ var expected_ bool = true /* ~r.expr(null) */ suite.T().Log("About to run line #167: r.Expr(nil).Not()") runAndAssert(suite.Suite, expected_, r.Expr(nil).Not(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #167") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_math_test.go000066400000000000000000000036441363464422500301710ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests of nested arithmetic expressions func TestMathLogicMathSuite(t *testing.T) { suite.Run(t, new(MathLogicMathSuite)) } type MathLogicMathSuite struct { suite.Suite session *r.Session } func (suite *MathLogicMathSuite) SetupTest() { suite.T().Log("Setting up MathLogicMathSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_math").Exec(suite.session) err = r.DBCreate("db_logic_math").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_math").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicMathSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicMathSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_math").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicMathSuite) TestCases() { suite.T().Log("Running MathLogicMathSuite: Tests of nested arithmetic expressions") { // math_logic/math.yaml line #4 /* 1 */ var expected_ int = 1 /* (((4 + 2 * (r.expr(26) % 18)) / 5) - 3) */ suite.T().Log("About to run line #4: r.Add(4, r.Mul(2, r.Expr(26).Mod(18))).Div(5).Sub(3)") runAndAssert(suite.Suite, expected_, r.Add(4, r.Mul(2, r.Expr(26).Mod(18))).Div(5).Sub(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_mod_test.go000066400000000000000000000104361363464422500300140ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests for the basic usage of the mod operation func TestMathLogicModSuite(t *testing.T) { suite.Run(t, new(MathLogicModSuite)) } type MathLogicModSuite struct { suite.Suite session *r.Session } func (suite *MathLogicModSuite) SetupTest() { suite.T().Log("Setting up MathLogicModSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_mod").Exec(suite.session) err = r.DBCreate("db_logic_mod").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_mod").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicModSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicModSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_mod").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicModSuite) TestCases() { suite.T().Log("Running MathLogicModSuite: Tests for the basic usage of the mod operation") { // math_logic/mod.yaml line #6 /* 1 */ var expected_ int = 1 /* r.expr(10) % 3 */ suite.T().Log("About to run line #6: r.Expr(10).Mod(3)") runAndAssert(suite.Suite, expected_, r.Expr(10).Mod(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // math_logic/mod.yaml line #7 /* 1 */ var expected_ int = 1 /* 10 % r.expr(3) */ suite.T().Log("About to run line #7: r.Mod(10, r.Expr(3))") runAndAssert(suite.Suite, expected_, r.Mod(10, r.Expr(3)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // math_logic/mod.yaml line #8 /* 1 */ var expected_ int = 1 /* r.expr(10).mod(3) */ suite.T().Log("About to run line #8: r.Expr(10).Mod(3)") runAndAssert(suite.Suite, expected_, r.Expr(10).Mod(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/mod.yaml line #16 /* -1 */ var expected_ int = -1 /* r.expr(-10) % -3 */ suite.T().Log("About to run line #16: r.Expr(-10).Mod(-3)") runAndAssert(suite.Suite, expected_, r.Expr(-10).Mod(-3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // math_logic/mod.yaml line #22 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr(4) % 'a' */ suite.T().Log("About to run line #22: r.Expr(4).Mod('a')") runAndAssert(suite.Suite, expected_, r.Expr(4).Mod("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // math_logic/mod.yaml line #27 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('a') % 1 */ suite.T().Log("About to run line #27: r.Expr('a').Mod(1)") runAndAssert(suite.Suite, expected_, r.Expr("a").Mod(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // math_logic/mod.yaml line #32 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('a') % 'b' */ suite.T().Log("About to run line #32: r.Expr('a').Mod('b')") runAndAssert(suite.Suite, expected_, r.Expr("a").Mod("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_mul_test.go000066400000000000000000000137061363464422500300350ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests for the basic usage of the multiplication operation func TestMathLogicMulSuite(t *testing.T) { suite.Run(t, new(MathLogicMulSuite)) } type MathLogicMulSuite struct { suite.Suite session *r.Session } func (suite *MathLogicMulSuite) SetupTest() { suite.T().Log("Setting up MathLogicMulSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_mul").Exec(suite.session) err = r.DBCreate("db_logic_mul").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_mul").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicMulSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicMulSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_mul").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicMulSuite) TestCases() { suite.T().Log("Running MathLogicMulSuite: Tests for the basic usage of the multiplication operation") { // math_logic/mul.yaml line #6 /* 2 */ var expected_ int = 2 /* r.expr(1) * 2 */ suite.T().Log("About to run line #6: r.Expr(1).Mul(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Mul(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // math_logic/mul.yaml line #7 /* 2 */ var expected_ int = 2 /* 1 * r.expr(2) */ suite.T().Log("About to run line #7: r.Mul(1, r.Expr(2))") runAndAssert(suite.Suite, expected_, r.Mul(1, r.Expr(2)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // math_logic/mul.yaml line #8 /* 2 */ var expected_ int = 2 /* r.expr(1).mul(2) */ suite.T().Log("About to run line #8: r.Expr(1).Mul(2)") runAndAssert(suite.Suite, expected_, r.Expr(1).Mul(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/mul.yaml line #15 /* 1 */ var expected_ int = 1 /* r.expr(-1) * -1 */ suite.T().Log("About to run line #15: r.Expr(-1).Mul(-1)") runAndAssert(suite.Suite, expected_, r.Expr(-1).Mul(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // math_logic/mul.yaml line #21 /* 6.75 */ var expected_ float64 = 6.75 /* r.expr(1.5) * 4.5 */ suite.T().Log("About to run line #21: r.Expr(1.5).Mul(4.5)") runAndAssert(suite.Suite, expected_, r.Expr(1.5).Mul(4.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // math_logic/mul.yaml line #25 /* [1,2,3,1,2,3,1,2,3] */ var expected_ []interface{} = []interface{}{1, 2, 3, 1, 2, 3, 1, 2, 3} /* r.expr([1,2,3]) * 3 */ suite.T().Log("About to run line #25: r.Expr([]interface{}{1, 2, 3}).Mul(3)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Mul(3), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // math_logic/mul.yaml line #30 /* 120 */ var expected_ int = 120 /* r.expr(1).mul(2,3,4,5) */ suite.T().Log("About to run line #30: r.Expr(1).Mul(2, 3, 4, 5)") runAndAssert(suite.Suite, expected_, r.Expr(1).Mul(2, 3, 4, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // math_logic/mul.yaml line #46 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('a') * 0.8 */ suite.T().Log("About to run line #46: r.Expr('a').Mul(0.8)") runAndAssert(suite.Suite, expected_, r.Expr("a").Mul(0.8), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // math_logic/mul.yaml line #50 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr(1) * 'a' */ suite.T().Log("About to run line #50: r.Expr(1).Mul('a')") runAndAssert(suite.Suite, expected_, r.Expr(1).Mul("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // math_logic/mul.yaml line #54 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('b') * 'a' */ suite.T().Log("About to run line #54: r.Expr('b').Mul('a')") runAndAssert(suite.Suite, expected_, r.Expr("b").Mul("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // math_logic/mul.yaml line #58 /* err('ReqlQueryLogicError', 'Number not an integer: 1.5', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Number not an integer: 1.5") /* r.expr([]) * 1.5 */ suite.T().Log("About to run line #58: r.Expr([]interface{}{}).Mul(1.5)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{}).Mul(1.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_math_logic_sub_test.go000066400000000000000000000120161363464422500300220ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests for basic usage of the subtraction operation func TestMathLogicSubSuite(t *testing.T) { suite.Run(t, new(MathLogicSubSuite)) } type MathLogicSubSuite struct { suite.Suite session *r.Session } func (suite *MathLogicSubSuite) SetupTest() { suite.T().Log("Setting up MathLogicSubSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_logic_sub").Exec(suite.session) err = r.DBCreate("db_logic_sub").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_logic_sub").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MathLogicSubSuite) TearDownSuite() { suite.T().Log("Tearing down MathLogicSubSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_logic_sub").Exec(suite.session) suite.session.Close() } } func (suite *MathLogicSubSuite) TestCases() { suite.T().Log("Running MathLogicSubSuite: Tests for basic usage of the subtraction operation") { // math_logic/sub.yaml line #6 /* 0 */ var expected_ int = 0 /* r.expr(1) - 1 */ suite.T().Log("About to run line #6: r.Expr(1).Sub(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Sub(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // math_logic/sub.yaml line #7 /* 0 */ var expected_ int = 0 /* 1 - r.expr(1) */ suite.T().Log("About to run line #7: r.Sub(1, r.Expr(1))") runAndAssert(suite.Suite, expected_, r.Sub(1, r.Expr(1)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // math_logic/sub.yaml line #8 /* 0 */ var expected_ int = 0 /* r.expr(1).sub(1) */ suite.T().Log("About to run line #8: r.Expr(1).Sub(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Sub(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // math_logic/sub.yaml line #17 /* -2 */ var expected_ int = -2 /* r.expr(-1) - 1 */ suite.T().Log("About to run line #17: r.Expr(-1).Sub(1)") runAndAssert(suite.Suite, expected_, r.Expr(-1).Sub(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } { // math_logic/sub.yaml line #22 /* -6.75 */ var expected_ float64 = -6.75 /* r.expr(1.75) - 8.5 */ suite.T().Log("About to run line #22: r.Expr(1.75).Sub(8.5)") runAndAssert(suite.Suite, expected_, r.Expr(1.75).Sub(8.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // math_logic/sub.yaml line #26 /* -13 */ var expected_ int = -13 /* r.expr(1).sub(2,3,4,5) */ suite.T().Log("About to run line #26: r.Expr(1).Sub(2, 3, 4, 5)") runAndAssert(suite.Suite, expected_, r.Expr(1).Sub(2, 3, 4, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // math_logic/sub.yaml line #30 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('a').sub(0.8) */ suite.T().Log("About to run line #30: r.Expr('a').Sub(0.8)") runAndAssert(suite.Suite, expected_, r.Expr("a").Sub(0.8), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // math_logic/sub.yaml line #33 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [1]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr(1).sub('a') */ suite.T().Log("About to run line #33: r.Expr(1).Sub('a')") runAndAssert(suite.Suite, expected_, r.Expr(1).Sub("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // math_logic/sub.yaml line #36 /* err('ReqlQueryLogicError', 'Expected type NUMBER but found STRING.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.expr('b').sub('a') */ suite.T().Log("About to run line #36: r.Expr('b').Sub('a')") runAndAssert(suite.Suite, expected_, r.Expr("b").Sub("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_meta_composite_test.go000066400000000000000000000076461363464422500300700ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests meta operations in composite queries func TestMetaCompositeSuite(t *testing.T) { suite.Run(t, new(MetaCompositeSuite)) } type MetaCompositeSuite struct { suite.Suite session *r.Session } func (suite *MetaCompositeSuite) SetupTest() { suite.T().Log("Setting up MetaCompositeSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_composite").Exec(suite.session) err = r.DBCreate("db_composite").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_composite").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MetaCompositeSuite) TearDownSuite() { suite.T().Log("Tearing down MetaCompositeSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_composite").Exec(suite.session) suite.session.Close() } } func (suite *MetaCompositeSuite) TestCases() { suite.T().Log("Running MetaCompositeSuite: Tests meta operations in composite queries") { // meta/composite.py.yaml line #4 /* ({'dbs_created':3,'config_changes':arrlen(3)}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dbs_created": 3, "config_changes": arrlen(3)} /* r.expr([1,2,3]).for_each(r.db_create('db_' + r.row.coerce_to('string'))) */ suite.T().Log("About to run line #4: r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBCreate(r.Add('db_', r.Row.CoerceTo('string'))))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBCreate(r.Add("db_", r.Row.CoerceTo("string")))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // meta/composite.py.yaml line #8 /* partial({'tables_created':9}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 9}) /* r.db_list().set_difference(["rethinkdb", "test"]).for_each(lambda db_name: r.expr([1,2,3]).for_each(lambda i: r.db(db_name).table_create('tbl_' + i.coerce_to('string')))) */ suite.T().Log("About to run line #8: r.DBList().SetDifference([]interface{}{'rethinkdb', 'test'}).ForEach(func(db_name r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).ForEach(func(i r.Term) interface{} { return r.DB(db_name).TableCreate(r.Add('tbl_', i.CoerceTo('string')))})})") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach( func(i r.Term) interface{} { return r.Expr([]interface{}{1, 2, 3}).ForEach(func(j r.Term) interface{} { return r.DB(r.Add("db_", i.CoerceTo("string"))).TableCreate(r.Add("tbl_", j.CoerceTo("string"))) }) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // meta/composite.py.yaml line #13 /* partial({'dbs_dropped':3,'tables_dropped':9}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 3, "tables_dropped": 9}) /* r.db_list().set_difference(["rethinkdb", "test"]).for_each(r.db_drop(r.row)) */ suite.T().Log("About to run line #13: r.DBList().SetDifference([]interface{}{'rethinkdb', 'test'}).ForEach(r.DBDrop(r.Row))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).ForEach(r.DBDrop(r.Add("db_", r.Row.CoerceTo("string")))), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_meta_dbs_test.go000066400000000000000000000157501363464422500266310ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests meta queries for databases func TestMetaDbsSuite(t *testing.T) { suite.Run(t, new(MetaDbsSuite)) } type MetaDbsSuite struct { suite.Suite session *r.Session } func (suite *MetaDbsSuite) SetupTest() { suite.T().Log("Setting up MetaDbsSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_dbs").Exec(suite.session) err = r.DBCreate("db_dbs").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_dbs").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MetaDbsSuite) TearDownSuite() { suite.T().Log("Tearing down MetaDbsSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_dbs").Exec(suite.session) suite.session.Close() } } func (suite *MetaDbsSuite) TestCases() { suite.T().Log("Running MetaDbsSuite: Tests meta queries for databases") { // meta/dbs.yaml line #6 /* bag(['rethinkdb', 'test']) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "db_dbs"}) /* r.db_list() */ suite.T().Log("About to run line #6: r.DBList()") runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // meta/dbs.yaml line #11 /* partial({'dbs_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1}) /* r.db_create('a') */ suite.T().Log("About to run line #11: r.DBCreate('a')") runAndAssert(suite.Suite, expected_, r.DBCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // meta/dbs.yaml line #13 /* partial({'dbs_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1}) /* r.db_create('b') */ suite.T().Log("About to run line #13: r.DBCreate('b')") runAndAssert(suite.Suite, expected_, r.DBCreate("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // meta/dbs.yaml line #18 /* bag(['rethinkdb', 'a', 'b', 'test']) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "a", "b", "db_dbs"}) /* r.db_list() */ suite.T().Log("About to run line #18: r.DBList()") runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // meta/dbs.yaml line #23 /* {'name':'a','id':uuid()} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"name": "a", "id": compare.IsUUID()} /* r.db('a').config() */ suite.T().Log("About to run line #23: r.DB('a').Config()") runAndAssert(suite.Suite, expected_, r.DB("a").Config(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // meta/dbs.yaml line #28 /* partial({'dbs_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1}) /* r.db_drop('b') */ suite.T().Log("About to run line #28: r.DBDrop('b')") runAndAssert(suite.Suite, expected_, r.DBDrop("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // meta/dbs.yaml line #31 /* bag(['rethinkdb', 'a', 'test']) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "a", "db_dbs"}) /* r.db_list() */ suite.T().Log("About to run line #31: r.DBList()") runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // meta/dbs.yaml line #34 /* partial({'dbs_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1}) /* r.db_drop('a') */ suite.T().Log("About to run line #34: r.DBDrop('a')") runAndAssert(suite.Suite, expected_, r.DBDrop("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // meta/dbs.yaml line #37 /* bag(['rethinkdb', 'test']) */ var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "db_dbs"}) /* r.db_list() */ suite.T().Log("About to run line #37: r.DBList()") runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // meta/dbs.yaml line #41 /* partial({'dbs_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1}) /* r.db_create('bar') */ suite.T().Log("About to run line #41: r.DBCreate('bar')") runAndAssert(suite.Suite, expected_, r.DBCreate("bar"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #41") } { // meta/dbs.yaml line #44 /* err('ReqlOpFailedError', 'Database `bar` already exists.', [0]) */ var expected_ Err = err("ReqlOpFailedError", "Database `bar` already exists.") /* r.db_create('bar') */ suite.T().Log("About to run line #44: r.DBCreate('bar')") runAndAssert(suite.Suite, expected_, r.DBCreate("bar"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // meta/dbs.yaml line #47 /* partial({'dbs_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1}) /* r.db_drop('bar') */ suite.T().Log("About to run line #47: r.DBDrop('bar')") runAndAssert(suite.Suite, expected_, r.DBDrop("bar"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // meta/dbs.yaml line #50 /* err('ReqlOpFailedError', 'Database `bar` does not exist.', [0]) */ var expected_ Err = err("ReqlOpFailedError", "Database `bar` does not exist.") /* r.db_drop('bar') */ suite.T().Log("About to run line #50: r.DBDrop('bar')") runAndAssert(suite.Suite, expected_, r.DBDrop("bar"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_meta_table_test.go000066400000000000000000001423221363464422500271440ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests meta queries for creating and deleting tables func TestMetaTableSuite(t *testing.T) { suite.Run(t, new(MetaTableSuite)) } type MetaTableSuite struct { suite.Suite session *r.Session } func (suite *MetaTableSuite) SetupTest() { suite.T().Log("Setting up MetaTableSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mtable").Exec(suite.session) err = r.DBCreate("db_mtable").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mtable").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MetaTableSuite) TearDownSuite() { suite.T().Log("Tearing down MetaTableSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_mtable").Exec(suite.session) suite.session.Close() } } func (suite *MetaTableSuite) TestCases() { suite.T().Log("Running MetaTableSuite: Tests meta queries for creating and deleting tables") // meta/table.yaml line #4 // db = r.db('test') suite.T().Log("Possibly executing: var db r.Term = r.DB('test')") db := r.DB("db_mtable") _ = db // Prevent any noused variable errors { // meta/table.yaml line #6 /* [] */ var expected_ []interface{} = []interface{}{} /* db.table_list() */ suite.T().Log("About to run line #6: db.TableList()") runAndAssert(suite.Suite, expected_, db.TableList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // meta/table.yaml line #9 /* ({'type':'DB','name':'rethinkdb','id':null}) */ var expected_ = compare.PartialMatch(map[interface{}]interface{}{"type": "DB", "name": "rethinkdb"}) /* r.db('rethinkdb').info() */ suite.T().Log("About to run line #9: r.DB('rethinkdb').Info()") runAndAssert(suite.Suite, expected_, r.DB("rethinkdb").Info(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // meta/table.yaml line #12 /* partial({'db':{'type':'DB','name':'rethinkdb','id':null}, 'type':'TABLE','id':null,'name':'stats', 'indexes':[],'primary_key':'id'}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"db": map[interface{}]interface{}{"type": "DB", "name": "rethinkdb"}, "type": "TABLE", "name": "stats", "indexes": []interface{}{}, "primary_key": "id"}) /* r.db('rethinkdb').table('stats').info() */ suite.T().Log("About to run line #12: r.DB('rethinkdb').Table('stats').Info()") runAndAssert(suite.Suite, expected_, r.DB("rethinkdb").Table("stats").Info(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // meta/table.yaml line #18 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('a') */ suite.T().Log("About to run line #18: db.TableCreate('a')") runAndAssert(suite.Suite, expected_, db.TableCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // meta/table.yaml line #21 /* ['a'] */ var expected_ []interface{} = []interface{}{"a"} /* db.table_list() */ suite.T().Log("About to run line #21: db.TableList()") runAndAssert(suite.Suite, expected_, db.TableList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // meta/table.yaml line #24 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('b') */ suite.T().Log("About to run line #24: db.TableCreate('b')") runAndAssert(suite.Suite, expected_, db.TableCreate("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // meta/table.yaml line #27 /* bag(['a', 'b']) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{"a", "b"}) /* db.table_list() */ suite.T().Log("About to run line #27: db.TableList()") runAndAssert(suite.Suite, expected_, db.TableList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // meta/table.yaml line #31 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('a') */ suite.T().Log("About to run line #31: db.TableDrop('a')") runAndAssert(suite.Suite, expected_, db.TableDrop("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // meta/table.yaml line #34 /* ['b'] */ var expected_ []interface{} = []interface{}{"b"} /* db.table_list() */ suite.T().Log("About to run line #34: db.TableList()") runAndAssert(suite.Suite, expected_, db.TableList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // meta/table.yaml line #37 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('b') */ suite.T().Log("About to run line #37: db.TableDrop('b')") runAndAssert(suite.Suite, expected_, db.TableDrop("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // meta/table.yaml line #40 /* [] */ var expected_ []interface{} = []interface{}{} /* db.table_list() */ suite.T().Log("About to run line #40: db.TableList()") runAndAssert(suite.Suite, expected_, db.TableList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // meta/table.yaml line #44 /* partial({'tables_created':1,'config_changes':[partial({'new_val':partial({'durability':'soft'})})]}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1, "config_changes": []interface{}{compare.PartialMatch(map[interface{}]interface{}{"new_val": compare.PartialMatch(map[interface{}]interface{}{"durability": "soft"})})}}) /* db.table_create('ab', durability='soft') */ suite.T().Log("About to run line #44: db.TableCreate('ab').OptArgs(r.TableCreateOpts{Durability: 'soft', })") runAndAssert(suite.Suite, expected_, db.TableCreate("ab").OptArgs(r.TableCreateOpts{Durability: "soft"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // meta/table.yaml line #49 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('ab') */ suite.T().Log("About to run line #49: db.TableDrop('ab')") runAndAssert(suite.Suite, expected_, db.TableDrop("ab"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // meta/table.yaml line #52 /* partial({'tables_created':1,'config_changes':[partial({'new_val':partial({'durability':'hard'})})]}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1, "config_changes": []interface{}{compare.PartialMatch(map[interface{}]interface{}{"new_val": compare.PartialMatch(map[interface{}]interface{}{"durability": "hard"})})}}) /* db.table_create('ab', durability='hard') */ suite.T().Log("About to run line #52: db.TableCreate('ab').OptArgs(r.TableCreateOpts{Durability: 'hard', })") runAndAssert(suite.Suite, expected_, db.TableCreate("ab").OptArgs(r.TableCreateOpts{Durability: "hard"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // meta/table.yaml line #57 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('ab') */ suite.T().Log("About to run line #57: db.TableDrop('ab')") runAndAssert(suite.Suite, expected_, db.TableDrop("ab"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // meta/table.yaml line #60 /* err('ReqlQueryLogicError', 'Durability option `fake` unrecognized (options are "hard" and "soft").') */ var expected_ Err = err("ReqlQueryLogicError", "Durability option `fake` unrecognized (options are \"hard\" and \"soft\").") /* db.table_create('ab', durability='fake') */ suite.T().Log("About to run line #60: db.TableCreate('ab').OptArgs(r.TableCreateOpts{Durability: 'fake', })") runAndAssert(suite.Suite, expected_, db.TableCreate("ab").OptArgs(r.TableCreateOpts{Durability: "fake"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // meta/table.yaml line #65 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('ab', primary_key='bar', shards=2, replicas=1) */ suite.T().Log("About to run line #65: db.TableCreate('ab').OptArgs(r.TableCreateOpts{PrimaryKey: 'bar', Shards: 2, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.TableCreate("ab").OptArgs(r.TableCreateOpts{PrimaryKey: "bar", Shards: 2, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // meta/table.yaml line #70 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('ab') */ suite.T().Log("About to run line #70: db.TableDrop('ab')") runAndAssert(suite.Suite, expected_, db.TableDrop("ab"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // meta/table.yaml line #73 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('ab', primary_key='bar', primary_replica_tag='default') */ suite.T().Log("About to run line #73: db.TableCreate('ab').OptArgs(r.TableCreateOpts{PrimaryKey: 'bar', PrimaryReplicaTag: 'default', })") runAndAssert(suite.Suite, expected_, db.TableCreate("ab").OptArgs(r.TableCreateOpts{PrimaryKey: "bar", PrimaryReplicaTag: "default"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // meta/table.yaml line #78 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('ab') */ suite.T().Log("About to run line #78: db.TableDrop('ab')") runAndAssert(suite.Suite, expected_, db.TableDrop("ab"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #78") } { // meta/table.yaml line #81 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('ab', nonvoting_replica_tags=['default']) */ suite.T().Log("About to run line #81: db.TableCreate('ab').OptArgs(r.TableCreateOpts{NonVotingReplicaTags: []interface{}{'default'}, })") runAndAssert(suite.Suite, expected_, db.TableCreate("ab").OptArgs(r.TableCreateOpts{NonVotingReplicaTags: []interface{}{"default"}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #81") } { // meta/table.yaml line #86 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('ab') */ suite.T().Log("About to run line #86: db.TableDrop('ab')") runAndAssert(suite.Suite, expected_, db.TableDrop("ab"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // meta/table.yaml line #90 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('a') */ suite.T().Log("About to run line #90: db.TableCreate('a')") runAndAssert(suite.Suite, expected_, db.TableCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #90") } { // meta/table.yaml line #93 /* partial({'reconfigured':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 1}) /* db.table('a').reconfigure(shards=1, replicas=1) */ suite.T().Log("About to run line #93: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } { // meta/table.yaml line #98 /* partial({'reconfigured':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 1}) /* db.table('a').reconfigure(shards=1, replicas={"default":1}, nonvoting_replica_tags=['default'], primary_replica_tag='default') */ suite.T().Log("About to run line #98: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': 1, }, NonVotingReplicaTags: []interface{}{'default'}, PrimaryReplicaTag: 'default', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": 1}, NonVotingReplicaTags: []interface{}{"default"}, PrimaryReplicaTag: "default"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #98") } { // meta/table.yaml line #103 /* partial({'reconfigured':0}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 0}) /* db.table('a').reconfigure(shards=1, replicas=1, dry_run=True) */ suite.T().Log("About to run line #103: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 1, DryRun: true, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 1, DryRun: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // meta/table.yaml line #108 /* err('ReqlOpFailedError', 'This table doesn\'t need to be repaired.', []) */ var expected_ Err = err("ReqlOpFailedError", "This table doesn't need to be repaired.") /* db.table('a').reconfigure(emergency_repair="unsafe_rollback") */ suite.T().Log("About to run line #108: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: 'unsafe_rollback', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: "unsafe_rollback"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // meta/table.yaml line #113 /* err('ReqlOpFailedError', 'This table doesn\'t need to be repaired.', []) */ var expected_ Err = err("ReqlOpFailedError", "This table doesn't need to be repaired.") /* db.table('a').reconfigure(emergency_repair="unsafe_rollback", dry_run=True) */ suite.T().Log("About to run line #113: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: 'unsafe_rollback', DryRun: true, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: "unsafe_rollback", DryRun: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #113") } { // meta/table.yaml line #118 /* err('ReqlOpFailedError', 'This table doesn\'t need to be repaired.', []) */ var expected_ Err = err("ReqlOpFailedError", "This table doesn't need to be repaired.") /* db.table('a').reconfigure(emergency_repair="unsafe_rollback_or_erase") */ suite.T().Log("About to run line #118: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: 'unsafe_rollback_or_erase', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: "unsafe_rollback_or_erase"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #118") } { // meta/table.yaml line #123 /* partial({'reconfigured':0}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 0}) /* db.table('a').reconfigure(emergency_repair=None, shards=1, replicas=1, dry_run=True) */ suite.T().Log("About to run line #123: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: nil, Shards: 1, Replicas: 1, DryRun: true, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: nil, Shards: 1, Replicas: 1, DryRun: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } { // meta/table.yaml line #128 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('a') */ suite.T().Log("About to run line #128: db.TableDrop('a')") runAndAssert(suite.Suite, expected_, db.TableDrop("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #128") } { // meta/table.yaml line #132 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('foo') */ suite.T().Log("About to run line #132: db.TableCreate('foo')") runAndAssert(suite.Suite, expected_, db.TableCreate("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #132") } { // meta/table.yaml line #135 /* err('ReqlOpFailedError', 'Table `test.foo` already exists.', [0]) */ var expected_ Err = err("ReqlOpFailedError", "Table `db_mtable.foo` already exists.") /* db.table_create('foo') */ suite.T().Log("About to run line #135: db.TableCreate('foo')") runAndAssert(suite.Suite, expected_, db.TableCreate("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #135") } { // meta/table.yaml line #138 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('foo') */ suite.T().Log("About to run line #138: db.TableDrop('foo')") runAndAssert(suite.Suite, expected_, db.TableDrop("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #138") } { // meta/table.yaml line #141 /* err('ReqlOpFailedError', 'Table `test.foo` does not exist.', [0]) */ var expected_ Err = err("ReqlOpFailedError", "Table `db_mtable.foo` does not exist.") /* db.table_drop('foo') */ suite.T().Log("About to run line #141: db.TableDrop('foo')") runAndAssert(suite.Suite, expected_, db.TableDrop("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #141") } { // meta/table.yaml line #158 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create('a') */ suite.T().Log("About to run line #158: db.TableCreate('a')") runAndAssert(suite.Suite, expected_, db.TableCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #158") } { // meta/table.yaml line #161 /* err('ReqlQueryLogicError', 'Every table must have at least one shard.', []) */ var expected_ Err = err("ReqlQueryLogicError", "Every table must have at least one shard.") /* db.table('a').reconfigure(shards=0, replicas=1) */ suite.T().Log("About to run line #161: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 0, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 0, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #161") } { // meta/table.yaml line #166 /* err('ReqlOpFailedError', 'Can\'t use server tag `foo` for primary replicas because you specified no replicas in server tag `foo`.', []) */ var expected_ Err = err("ReqlOpFailedError", "Can't use server tag `foo` for primary replicas because you specified no replicas in server tag `foo`.") /* db.table('a').reconfigure(shards=1, replicas={"default":1}, primary_replica_tag="foo") */ suite.T().Log("About to run line #166: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': 1, }, PrimaryReplicaTag: 'foo', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": 1}, PrimaryReplicaTag: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #166") } { // meta/table.yaml line #171 /* err('ReqlOpFailedError', 'You specified that the replicas in server tag `foo` should be non-voting, but you didn\'t specify a number of replicas in server tag `foo`.', []) */ var expected_ Err = err("ReqlOpFailedError", "You specified that the replicas in server tag `foo` should be non-voting, but you didn't specify a number of replicas in server tag `foo`.") /* db.table('a').reconfigure(shards=1, replicas={"default":1}, primary_replica_tag="default", nonvoting_replica_tags=["foo"]) */ suite.T().Log("About to run line #171: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': 1, }, PrimaryReplicaTag: 'default', NonVotingReplicaTags: []interface{}{'foo'}, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": 1}, PrimaryReplicaTag: "default", NonVotingReplicaTags: []interface{}{"foo"}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #171") } { // meta/table.yaml line #176 /* err('ReqlOpFailedError', 'You must set `replicas` to at least one. `replicas` includes the primary replica; if there are zero replicas, there is nowhere to put the data.', []) */ var expected_ Err = err("ReqlOpFailedError", "You must set `replicas` to at least one. `replicas` includes the primary replica; if there are zero replicas, there is nowhere to put the data.") /* db.table('a').reconfigure(shards=1, replicas={"foo":0}, primary_replica_tag="foo") */ suite.T().Log("About to run line #176: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'foo': 0, }, PrimaryReplicaTag: 'foo', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"foo": 0}, PrimaryReplicaTag: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #176") } { // meta/table.yaml line #181 /* err('ReqlQueryLogicError', '`primary_replica_tag` must be specified when `replicas` is an OBJECT.', []) */ var expected_ Err = err("ReqlQueryLogicError", "`primary_replica_tag` must be specified when `replicas` is an OBJECT.") /* db.table('a').reconfigure(shards=1, replicas={"default":0}) */ suite.T().Log("About to run line #181: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': 0, }, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": 0}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #181") } { // meta/table.yaml line #186 /* err('ReqlQueryLogicError', 'Can\'t have a negative number of replicas', []) */ var expected_ Err = err("ReqlQueryLogicError", "Can't have a negative number of replicas") /* db.table('a').reconfigure(shards=1, replicas={"default":-3}, primary_replica_tag='default') */ suite.T().Log("About to run line #186: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': -3, }, PrimaryReplicaTag: 'default', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": -3}, PrimaryReplicaTag: "default"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #186") } { // meta/table.yaml line #191 /* err('ReqlQueryLogicError', '`replicas` must be an OBJECT if `primary_replica_tag` is specified.', []) */ var expected_ Err = err("ReqlQueryLogicError", "`replicas` must be an OBJECT if `primary_replica_tag` is specified.") /* db.table('a').reconfigure(shards=1, replicas=3, primary_replica_tag='foo') */ suite.T().Log("About to run line #191: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 3, PrimaryReplicaTag: 'foo', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 3, PrimaryReplicaTag: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #191") } { // meta/table.yaml line #196 /* err('ReqlQueryLogicError', '`replicas` must be an OBJECT if `nonvoting_replica_tags` is specified.', []) */ var expected_ Err = err("ReqlQueryLogicError", "`replicas` must be an OBJECT if `nonvoting_replica_tags` is specified.") /* db.table('a').reconfigure(shards=1, replicas=3, nonvoting_replica_tags=['foo']) */ suite.T().Log("About to run line #196: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 3, NonVotingReplicaTags: []interface{}{'foo'}, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 3, NonVotingReplicaTags: []interface{}{"foo"}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #196") } { // meta/table.yaml line #201 /* err('ReqlQueryLogicError', 'Can\'t emergency repair an entire database at once; instead you should run `reconfigure()` on each table individually.') */ var expected_ Err = err("ReqlQueryLogicError", "Can't emergency repair an entire database at once; instead you should run `reconfigure()` on each table individually.") /* db.reconfigure(emergency_repair="unsafe_rollback") */ suite.T().Log("About to run line #201: db.Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: 'unsafe_rollback', })") runAndAssert(suite.Suite, expected_, db.Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: "unsafe_rollback"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #201") } { // meta/table.yaml line #206 /* err('ReqlQueryLogicError', '`emergency_repair` should be "unsafe_rollback" or "unsafe_rollback_or_erase"', []) */ var expected_ Err = err("ReqlQueryLogicError", "`emergency_repair` should be \"unsafe_rollback\" or \"unsafe_rollback_or_erase\"") /* db.table('a').reconfigure(emergency_repair="foo") */ suite.T().Log("About to run line #206: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: 'foo', })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #206") } { // meta/table.yaml line #211 /* err('ReqlQueryLogicError', 'In emergency repair mode, you can\'t specify shards, replicas, etc.') */ var expected_ Err = err("ReqlQueryLogicError", "In emergency repair mode, you can't specify shards, replicas, etc.") /* db.table('a').reconfigure(emergency_repair="unsafe_rollback", shards=1, replicas=1) */ suite.T().Log("About to run line #211: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: 'unsafe_rollback', Shards: 1, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{EmergencyRepair: "unsafe_rollback", Shards: 1, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #211") } { // meta/table.yaml line #217 /* partial({'reconfigured':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 1}) /* db.table('a').reconfigure(shards=2, replicas=1) */ suite.T().Log("About to run line #217: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 2, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 2, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #217") } { // meta/table.yaml line #222 /* {"ready":1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"ready": 1} /* db.table('a').wait(wait_for="all_replicas_ready") */ suite.T().Log("About to run line #222: db.Table('a').Wait().OptArgs(r.WaitOpts{WaitFor: 'all_replicas_ready', })") runAndAssert(suite.Suite, expected_, db.Table("a").Wait().OptArgs(r.WaitOpts{WaitFor: "all_replicas_ready"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #222") } { // meta/table.yaml line #228 /* partial({"inserted":4}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 4}) /* db.table('a').insert([{"id":1}, {"id":2}, {"id":3}, {"id":4}]) */ suite.T().Log("About to run line #228: db.Table('a').Insert([]interface{}{map[interface{}]interface{}{'id': 1, }, map[interface{}]interface{}{'id': 2, }, map[interface{}]interface{}{'id': 3, }, map[interface{}]interface{}{'id': 4, }})") runAndAssert(suite.Suite, expected_, db.Table("a").Insert([]interface{}{map[interface{}]interface{}{"id": 1}, map[interface{}]interface{}{"id": 2}, map[interface{}]interface{}{"id": 3}, map[interface{}]interface{}{"id": 4}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #228") } { // meta/table.yaml line #233 /* partial({'reconfigured':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 1}) /* db.table('a').reconfigure(shards=2, replicas=1) */ suite.T().Log("About to run line #233: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 2, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 2, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #233") } { // meta/table.yaml line #238 /* err('ReqlOpFailedError', 'Can\'t put 2 replicas on servers with the tag `default` because there are only 1 servers with the tag `default`. It\'s impossible to have more replicas of the data than there are servers.', []) */ var expected_ Err = err("ReqlOpFailedError", "Can't put 2 replicas on servers with the tag `default` because there are only 1 servers with the tag `default`. It's impossible to have more replicas of the data than there are servers.") /* db.table('a').reconfigure(shards=1, replicas=2) */ suite.T().Log("About to run line #238: db.Table('a').Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 2, })") runAndAssert(suite.Suite, expected_, db.Table("a").Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #238") } { // meta/table.yaml line #244 /* {"ready":1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"ready": 1} /* db.table('a').wait(wait_for="all_replicas_ready") */ suite.T().Log("About to run line #244: db.Table('a').Wait().OptArgs(r.WaitOpts{WaitFor: 'all_replicas_ready', })") runAndAssert(suite.Suite, expected_, db.Table("a").Wait().OptArgs(r.WaitOpts{WaitFor: "all_replicas_ready"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #244") } { // meta/table.yaml line #248 /* partial({'rebalanced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"rebalanced": 1}) /* db.table('a').rebalance() */ suite.T().Log("About to run line #248: db.Table('a').Rebalance()") runAndAssert(suite.Suite, expected_, db.Table("a").Rebalance(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #248") } { // meta/table.yaml line #251 /* {"ready":1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"ready": 1} /* db.wait(wait_for="all_replicas_ready") */ suite.T().Log("About to run line #251: db.Wait().OptArgs(r.WaitOpts{WaitFor: 'all_replicas_ready', })") runAndAssert(suite.Suite, expected_, db.Wait().OptArgs(r.WaitOpts{WaitFor: "all_replicas_ready"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #251") } { // meta/table.yaml line #255 /* partial({'rebalanced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"rebalanced": 1}) /* db.rebalance() */ suite.T().Log("About to run line #255: db.Rebalance()") runAndAssert(suite.Suite, expected_, db.Rebalance(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #255") } { // meta/table.yaml line #271 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('a') */ suite.T().Log("About to run line #271: db.TableDrop('a')") runAndAssert(suite.Suite, expected_, db.TableDrop("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #271") } { // meta/table.yaml line #275 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* db.table_create('a') */ suite.T().Log("About to run line #275: db.TableCreate('a')") runAndAssert(suite.Suite, expected_, db.TableCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #275") } { // meta/table.yaml line #276 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* db.table_create('b') */ suite.T().Log("About to run line #276: db.TableCreate('b')") runAndAssert(suite.Suite, expected_, db.TableCreate("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #276") } { // meta/table.yaml line #277 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* db.table_create('c') */ suite.T().Log("About to run line #277: db.TableCreate('c')") runAndAssert(suite.Suite, expected_, db.TableCreate("c"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #277") } { // meta/table.yaml line #279 /* err('ReqlQueryLogicError', 'Every table must have at least one shard.', []) */ var expected_ Err = err("ReqlQueryLogicError", "Every table must have at least one shard.") /* db.reconfigure(shards=0, replicas=1) */ suite.T().Log("About to run line #279: db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 0, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 0, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #279") } { // meta/table.yaml line #284 /* err('ReqlQueryLogicError', '`primary_replica_tag` must be specified when `replicas` is an OBJECT.', []) */ var expected_ Err = err("ReqlQueryLogicError", "`primary_replica_tag` must be specified when `replicas` is an OBJECT.") /* db.reconfigure(shards=1, replicas={"default":0}) */ suite.T().Log("About to run line #284: db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': 0, }, })") runAndAssert(suite.Suite, expected_, db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": 0}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #284") } { // meta/table.yaml line #289 /* err('ReqlQueryLogicError', 'Can\'t have a negative number of replicas', []) */ var expected_ Err = err("ReqlQueryLogicError", "Can't have a negative number of replicas") /* db.reconfigure(shards=1, replicas={"default":-3}, primary_replica_tag='default') */ suite.T().Log("About to run line #289: db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{'default': -3, }, PrimaryReplicaTag: 'default', })") runAndAssert(suite.Suite, expected_, db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: map[interface{}]interface{}{"default": -3}, PrimaryReplicaTag: "default"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #289") } { // meta/table.yaml line #294 /* err('ReqlQueryLogicError', '`replicas` must be an OBJECT if `primary_replica_tag` is specified.', []) */ var expected_ Err = err("ReqlQueryLogicError", "`replicas` must be an OBJECT if `primary_replica_tag` is specified.") /* db.reconfigure(shards=1, replicas=3, primary_replica_tag='foo') */ suite.T().Log("About to run line #294: db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 3, PrimaryReplicaTag: 'foo', })") runAndAssert(suite.Suite, expected_, db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 1, Replicas: 3, PrimaryReplicaTag: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #294") } { // meta/table.yaml line #299 /* partial({'reconfigured':3}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"reconfigured": 3}) /* db.reconfigure(shards=2, replicas=1) */ suite.T().Log("About to run line #299: db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 2, Replicas: 1, })") runAndAssert(suite.Suite, expected_, db.Reconfigure().OptArgs(r.ReconfigureOpts{Shards: 2, Replicas: 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #299") } { // meta/table.yaml line #304 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('a') */ suite.T().Log("About to run line #304: db.TableDrop('a')") runAndAssert(suite.Suite, expected_, db.TableDrop("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #304") } { // meta/table.yaml line #306 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('b') */ suite.T().Log("About to run line #306: db.TableDrop('b')") runAndAssert(suite.Suite, expected_, db.TableDrop("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #306") } { // meta/table.yaml line #308 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('c') */ suite.T().Log("About to run line #308: db.TableDrop('c')") runAndAssert(suite.Suite, expected_, db.TableDrop("c"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #308") } { // meta/table.yaml line #312 /* partial({'dbs_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1}) /* r.db_create("test2") */ suite.T().Log("About to run line #312: r.DBCreate('test2')") runAndAssert(suite.Suite, expected_, r.DBCreate("test2"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #312") } // meta/table.yaml line #315 // db2 = r.db("test2") suite.T().Log("Possibly executing: var db2 r.Term = r.DB('test2')") db2 := r.DB("test2") _ = db2 // Prevent any noused variable errors { // meta/table.yaml line #317 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create("testA") */ suite.T().Log("About to run line #317: db.TableCreate('testA')") runAndAssert(suite.Suite, expected_, db.TableCreate("testA"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #317") } { // meta/table.yaml line #319 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db.table_create("testB") */ suite.T().Log("About to run line #319: db.TableCreate('testB')") runAndAssert(suite.Suite, expected_, db.TableCreate("testB"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #319") } { // meta/table.yaml line #321 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* db2.table_create("test2B") */ suite.T().Log("About to run line #321: db2.TableCreate('test2B')") runAndAssert(suite.Suite, expected_, db2.TableCreate("test2B"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #321") } { // meta/table.yaml line #324 /* {'db':'test','name':'testA'} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"db": "db_mtable", "name": "testA"} /* r.table('testA').config().pluck('db','name') */ suite.T().Log("About to run line #324: r.Table('testA').Config().Pluck('db', 'name')") runAndAssert(suite.Suite, expected_, db.Table("testA").Config().Pluck("db", "name"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #324") } { // meta/table.yaml line #327 /* err('ReqlOpFailedError', 'Table `test.doesntexist` does not exist.', []) */ var expected_ Err = err("ReqlOpFailedError", "Table `test.doesntexist` does not exist.") /* r.table('doesntexist').config() */ suite.T().Log("About to run line #327: r.Table('doesntexist').Config()") runAndAssert(suite.Suite, expected_, r.Table("doesntexist").Config(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #327") } { // meta/table.yaml line #330 /* err('ReqlOpFailedError', 'Table `test.test2B` does not exist.', []) */ var expected_ Err = err("ReqlOpFailedError", "Table `test.test2B` does not exist.") /* r.table('test2B').config() */ suite.T().Log("About to run line #330: r.Table('test2B').Config()") runAndAssert(suite.Suite, expected_, r.Table("test2B").Config(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #330") } { // meta/table.yaml line #333 /* True */ var expected_ bool = true /* r.db('rethinkdb').table('table_config').filter({'name':'testA'}).nth(0).eq(r.table('testA').config()) */ suite.T().Log("About to run line #333: r.DB('rethinkdb').Table('table_config').Filter(map[interface{}]interface{}{'name': 'testA', }).Nth(0).Eq(r.Table('testA').Config())") runAndAssert(suite.Suite, expected_, r.DB("rethinkdb").Table("table_config").Filter(map[interface{}]interface{}{"name": "testA"}).Nth(0).Eq(db.Table("testA").Config()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #333") } { // meta/table.yaml line #336 /* True */ var expected_ bool = true /* r.db('rethinkdb').table('table_status').filter({'name':'testA'}).nth(0).eq(r.table('testA').status()) */ suite.T().Log("About to run line #336: r.DB('rethinkdb').Table('table_status').Filter(map[interface{}]interface{}{'name': 'testA', }).Nth(0).Eq(r.Table('testA').Status())") runAndAssert(suite.Suite, expected_, r.DB("rethinkdb").Table("table_status").Filter(map[interface{}]interface{}{"name": "testA"}).Nth(0).Eq(db.Table("testA").Status()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #336") } { // meta/table.yaml line #339 /* uuid() */ var expected_ compare.Regex = compare.IsUUID() /* r.db('rethinkdb').table('table_config', identifier_format='uuid').nth(0)["db"] */ suite.T().Log("About to run line #339: r.DB('rethinkdb').Table('table_config').OptArgs(r.TableOpts{IdentifierFormat: 'uuid', }).Nth(0).AtIndex('db')") runAndAssert(suite.Suite, expected_, r.DB("rethinkdb").Table("table_config").OptArgs(r.TableOpts{IdentifierFormat: "uuid"}).Nth(0).AtIndex("db"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #339") } { // meta/table.yaml line #344 /* 0 */ var expected_ int = 0 /* r.table('testA', identifier_format='uuid').count() */ suite.T().Log("About to run line #344: r.Table('testA').OptArgs(r.TableOpts{IdentifierFormat: 'uuid', }).Count()") runAndAssert(suite.Suite, expected_, db.Table("testA").OptArgs(r.TableOpts{IdentifierFormat: "uuid"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #344") } { // meta/table.yaml line #358 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('testA') */ suite.T().Log("About to run line #358: db.TableDrop('testA')") runAndAssert(suite.Suite, expected_, db.TableDrop("testA"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #358") } { // meta/table.yaml line #361 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* db.table_drop('testB') */ suite.T().Log("About to run line #361: db.TableDrop('testB')") runAndAssert(suite.Suite, expected_, db.TableDrop("testB"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #361") } { // meta/table.yaml line #364 /* partial({'dbs_dropped':1,'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1, "tables_dropped": 1}) /* r.db_drop('test2') */ suite.T().Log("About to run line #364: r.DBDrop('test2')") runAndAssert(suite.Suite, expected_, r.DBDrop("test2"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #364") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_mutation_atomic_get_set_test.go000066400000000000000000000457541363464422500317700ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests replacement of selections func TestMutationAtomicGetSetSuite(t *testing.T) { suite.Run(t, new(MutationAtomicGetSetSuite)) } type MutationAtomicGetSetSuite struct { suite.Suite session *r.Session } func (suite *MutationAtomicGetSetSuite) SetupTest() { suite.T().Log("Setting up MutationAtomicGetSetSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mut_atom").Exec(suite.session) err = r.DBCreate("db_mut_atom").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_atom").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_mut_atom").TableDrop("table_test_mutation_atom").Exec(suite.session) err = r.DB("db_mut_atom").TableCreate("table_test_mutation_atom").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_atom").Table("table_test_mutation_atom").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MutationAtomicGetSetSuite) TearDownSuite() { suite.T().Log("Tearing down MutationAtomicGetSetSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_mut_atom").TableDrop("table_test_mutation_atom").Exec(suite.session) r.DBDrop("db_mut_atom").Exec(suite.session) suite.session.Close() } } func (suite *MutationAtomicGetSetSuite) TestCases() { suite.T().Log("Running MutationAtomicGetSetSuite: Tests replacement of selections") table_test_mutation_atom := r.DB("db_mut_atom").Table("table_test_mutation_atom") _ = table_test_mutation_atom // Prevent any noused variable errors { // mutation/atomic_get_set.yaml line #12 /* ({'changes':[{'old_val':null,'new_val':{'id':0}}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 0}}}} /* table_test_mutation_atom.insert({'id':0}, return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #12: table_test_mutation_atom.Insert(map[interface{}]interface{}{'id': 0, }).OptArgs(r.InsertOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Insert(map[interface{}]interface{}{"id": 0}).OptArgs(r.InsertOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // mutation/atomic_get_set.yaml line #16 /* ({'changes':[], 'first_error':"Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}"}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{}, "first_error": "Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}"} /* table_test_mutation_atom.insert({'id':0}, return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #16: table_test_mutation_atom.Insert(map[interface{}]interface{}{'id': 0, }).OptArgs(r.InsertOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Insert(map[interface{}]interface{}{"id": 0}).OptArgs(r.InsertOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // mutation/atomic_get_set.yaml line #20 /* ({'first_error':"Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}",'changes':[{'old_val':{'id':0},'new_val':{'id':0},'error':"Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}"}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}", "changes": []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 0}, "new_val": map[interface{}]interface{}{"id": 0}, "error": "Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}"}}} /* table_test_mutation_atom.insert({'id':0}, return_changes='always').pluck('changes', 'first_error') */ suite.T().Log("About to run line #20: table_test_mutation_atom.Insert(map[interface{}]interface{}{'id': 0, }).OptArgs(r.InsertOpts{ReturnChanges: 'always', }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Insert(map[interface{}]interface{}{"id": 0}).OptArgs(r.InsertOpts{ReturnChanges: "always"}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #20") } { // mutation/atomic_get_set.yaml line #24 /* ({'changes':[{'new_val':{'id':1},'old_val':null}], 'errors':0, 'deleted':0, 'unchanged':0, 'skipped':0, 'replaced':0, 'inserted':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}, "old_val": nil}}, "errors": 0, "deleted": 0, "unchanged": 0, "skipped": 0, "replaced": 0, "inserted": 1} /* table_test_mutation_atom.insert([{'id':1}], return_changes=True) */ suite.T().Log("About to run line #24: table_test_mutation_atom.Insert([]interface{}{map[interface{}]interface{}{'id': 1, }}).OptArgs(r.InsertOpts{ReturnChanges: true, })") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Insert([]interface{}{map[interface{}]interface{}{"id": 1}}).OptArgs(r.InsertOpts{ReturnChanges: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // mutation/atomic_get_set.yaml line #28 /* ({'changes':[],'first_error':"Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}"}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{}, "first_error": "Duplicate primary key `id`:\n{\n\t\"id\":\t0\n}\n{\n\t\"id\":\t0\n}"} /* table_test_mutation_atom.insert([{'id':0}], return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #28: table_test_mutation_atom.Insert([]interface{}{map[interface{}]interface{}{'id': 0, }}).OptArgs(r.InsertOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Insert([]interface{}{map[interface{}]interface{}{"id": 0}}).OptArgs(r.InsertOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // mutation/atomic_get_set.yaml line #33 /* ({'changes':[{'old_val':{'id':0},'new_val':{'id':0,'x':1}}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 0}, "new_val": map[interface{}]interface{}{"id": 0, "x": 1}}}} /* table_test_mutation_atom.get(0).update({'x':1}, return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #33: table_test_mutation_atom.Get(0).Update(map[interface{}]interface{}{'x': 1, }).OptArgs(r.UpdateOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Get(0).Update(map[interface{}]interface{}{"x": 1}).OptArgs(r.UpdateOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // mutation/atomic_get_set.yaml line #37 /* ({'changes':[],'first_error':'a'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{}, "first_error": "a"} /* table_test_mutation_atom.get(0).update({'x':r.error("a")}, return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #37: table_test_mutation_atom.Get(0).Update(map[interface{}]interface{}{'x': r.Error('a'), }).OptArgs(r.UpdateOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Get(0).Update(map[interface{}]interface{}{"x": r.Error("a")}).OptArgs(r.UpdateOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // mutation/atomic_get_set.yaml line #41 /* ({'changes':[{'old_val':{'id':0, 'x':1},'new_val':{'id':0, 'x':3}}, {'old_val':{'id':1},'new_val':{'id':1, 'x':3}}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 0, "x": 1}, "new_val": map[interface{}]interface{}{"id": 0, "x": 3}}, map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "x": 3}}}} /* table_test_mutation_atom.update({'x':3}, return_changes=True).pluck('changes', 'first_error').do(lambda d:d.merge({'changes':d['changes'].order_by(lambda a:a['old_val']['id'])})) */ suite.T().Log("About to run line #41: table_test_mutation_atom.Update(map[interface{}]interface{}{'x': 3, }).OptArgs(r.UpdateOpts{ReturnChanges: true, }).Pluck('changes', 'first_error').Do(func(d r.Term) interface{} { return d.Merge(map[interface{}]interface{}{'changes': d.AtIndex('changes').OrderBy(func(a r.Term) interface{} { return a.AtIndex('old_val').AtIndex('id')}), })})") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Update(map[interface{}]interface{}{"x": 3}).OptArgs(r.UpdateOpts{ReturnChanges: true}).Pluck("changes", "first_error").Do(func(d r.Term) interface{} { return d.Merge(map[interface{}]interface{}{"changes": d.AtIndex("changes").OrderBy(func(a r.Term) interface{} { return a.AtIndex("old_val").AtIndex("id") })}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #41") } { // mutation/atomic_get_set.yaml line #46 /* ({'changes':[{'old_val':{'id':0,'x':3},'new_val':{'id':0,'x':2}}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 0, "x": 3}, "new_val": map[interface{}]interface{}{"id": 0, "x": 2}}}} /* table_test_mutation_atom.get(0).replace({'id':0,'x':2}, return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #46: table_test_mutation_atom.Get(0).Replace(map[interface{}]interface{}{'id': 0, 'x': 2, }).OptArgs(r.ReplaceOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Get(0).Replace(map[interface{}]interface{}{"id": 0, "x": 2}).OptArgs(r.ReplaceOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // mutation/atomic_get_set.yaml line #50 /* ({'changes':[],'first_error':'a'}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{}, "first_error": "a"} /* table_test_mutation_atom.get(0).replace(lambda y:{'x':r.error('a')}, return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #50: table_test_mutation_atom.Get(0).Replace(func(y r.Term) interface{} { return map[interface{}]interface{}{'x': r.Error('a'), }}).OptArgs(r.ReplaceOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Get(0).Replace(func(y r.Term) interface{} { return map[interface{}]interface{}{"x": r.Error("a")} }).OptArgs(r.ReplaceOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // mutation/atomic_get_set.yaml line #54 /* ({'first_error':'a','changes':[{'old_val':{'id':0,'x':2},'new_val':{'id':0,'x':2},'error':'a'}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "a", "changes": []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 0, "x": 2}, "new_val": map[interface{}]interface{}{"id": 0, "x": 2}, "error": "a"}}} /* table_test_mutation_atom.get(0).replace(lambda y:{'x':r.error('a')}, return_changes='always').pluck('changes', 'first_error') */ suite.T().Log("About to run line #54: table_test_mutation_atom.Get(0).Replace(func(y r.Term) interface{} { return map[interface{}]interface{}{'x': r.Error('a'), }}).OptArgs(r.ReplaceOpts{ReturnChanges: 'always', }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Get(0).Replace(func(y r.Term) interface{} { return map[interface{}]interface{}{"x": r.Error("a")} }).OptArgs(r.ReplaceOpts{ReturnChanges: "always"}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // mutation/atomic_get_set.yaml line #58 /* ({'changes':[{'new_val':{'id':0},'old_val':{'id':0, 'x':2}}, {'new_val':{'id':1},'old_val':{'id':1,'x':3}}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 0}, "old_val": map[interface{}]interface{}{"id": 0, "x": 2}}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}, "old_val": map[interface{}]interface{}{"id": 1, "x": 3}}}} /* table_test_mutation_atom.replace(lambda y:y.without('x'), return_changes=True).pluck('changes', 'first_error').do(lambda d:d.merge({'changes':d['changes'].order_by(lambda a:a['old_val']['id'])})) */ suite.T().Log("About to run line #58: table_test_mutation_atom.Replace(func(y r.Term) interface{} { return y.Without('x')}).OptArgs(r.ReplaceOpts{ReturnChanges: true, }).Pluck('changes', 'first_error').Do(func(d r.Term) interface{} { return d.Merge(map[interface{}]interface{}{'changes': d.AtIndex('changes').OrderBy(func(a r.Term) interface{} { return a.AtIndex('old_val').AtIndex('id')}), })})") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Replace(func(y r.Term) interface{} { return y.Without("x") }).OptArgs(r.ReplaceOpts{ReturnChanges: true}).Pluck("changes", "first_error").Do(func(d r.Term) interface{} { return d.Merge(map[interface{}]interface{}{"changes": d.AtIndex("changes").OrderBy(func(a r.Term) interface{} { return a.AtIndex("old_val").AtIndex("id") })}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // mutation/atomic_get_set.yaml line #62 /* ({'first_error':"Inserted object must have primary key `id`:\n{\n\t\"x\":\t1\n}", 'changes':[{'new_val':{'id':0},'old_val':{'id':0}, 'error':"Inserted object must have primary key `id`:\n{\n\t\"x\":\t1\n}"}, {'new_val':{'id':1},'old_val':{'id':1},'error':"Inserted object must have primary key `id`:\n{\n\t\"x\":\t1\n}"}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Inserted object must have primary key `id`:\n{\n\t\"x\":\t1\n}", "changes": []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 0}, "old_val": map[interface{}]interface{}{"id": 0}, "error": "Inserted object must have primary key `id`:\n{\n\t\"x\":\t1\n}"}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 1}, "old_val": map[interface{}]interface{}{"id": 1}, "error": "Inserted object must have primary key `id`:\n{\n\t\"x\":\t1\n}"}}} /* table_test_mutation_atom.replace({'x':1}, return_changes='always').pluck('changes', 'first_error').do(lambda d:d.merge({'changes':d['changes'].order_by(lambda a:a['old_val']['id'])})) */ suite.T().Log("About to run line #62: table_test_mutation_atom.Replace(map[interface{}]interface{}{'x': 1, }).OptArgs(r.ReplaceOpts{ReturnChanges: 'always', }).Pluck('changes', 'first_error').Do(func(d r.Term) interface{} { return d.Merge(map[interface{}]interface{}{'changes': d.AtIndex('changes').OrderBy(func(a r.Term) interface{} { return a.AtIndex('old_val').AtIndex('id')}), })})") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Replace(map[interface{}]interface{}{"x": 1}).OptArgs(r.ReplaceOpts{ReturnChanges: "always"}).Pluck("changes", "first_error").Do(func(d r.Term) interface{} { return d.Merge(map[interface{}]interface{}{"changes": d.AtIndex("changes").OrderBy(func(a r.Term) interface{} { return a.AtIndex("old_val").AtIndex("id") })}) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // mutation/atomic_get_set.yaml line #86 /* ({'changes':[{'old_val':{'id':0},'new_val':null}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 0}, "new_val": nil}}} /* table_test_mutation_atom.get(0).delete(return_changes=True).pluck('changes', 'first_error') */ suite.T().Log("About to run line #86: table_test_mutation_atom.Get(0).Delete().OptArgs(r.DeleteOpts{ReturnChanges: true, }).Pluck('changes', 'first_error')") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Get(0).Delete().OptArgs(r.DeleteOpts{ReturnChanges: true}).Pluck("changes", "first_error"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // mutation/atomic_get_set.yaml line #90 /* ({'deleted':1,'errors':0,'inserted':0,'replaced':0,'skipped':0,'unchanged':0,'changes':[{'new_val':null, 'old_val':{'id':1}}]}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 1, "errors": 0, "inserted": 0, "replaced": 0, "skipped": 0, "unchanged": 0, "changes": []interface{}{map[interface{}]interface{}{"new_val": nil, "old_val": map[interface{}]interface{}{"id": 1}}}} /* table_test_mutation_atom.delete(return_changes=True) */ suite.T().Log("About to run line #90: table_test_mutation_atom.Delete().OptArgs(r.DeleteOpts{ReturnChanges: true, })") runAndAssert(suite.Suite, expected_, table_test_mutation_atom.Delete().OptArgs(r.DeleteOpts{ReturnChanges: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #90") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_mutation_delete_test.go000066400000000000000000000154271363464422500302360ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests deletes of selections func TestMutationDeleteSuite(t *testing.T) { suite.Run(t, new(MutationDeleteSuite)) } type MutationDeleteSuite struct { suite.Suite session *r.Session } func (suite *MutationDeleteSuite) SetupTest() { suite.T().Log("Setting up MutationDeleteSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mut_del").Exec(suite.session) err = r.DBCreate("db_mut_del").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_del").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_mut_del").TableDrop("table_test_mutation_delete").Exec(suite.session) err = r.DB("db_mut_del").TableCreate("table_test_mutation_delete").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_del").Table("table_test_mutation_delete").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MutationDeleteSuite) TearDownSuite() { suite.T().Log("Tearing down MutationDeleteSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_mut_del").TableDrop("table_test_mutation_delete").Exec(suite.session) r.DBDrop("db_mut_del").Exec(suite.session) suite.session.Close() } } func (suite *MutationDeleteSuite) TestCases() { suite.T().Log("Running MutationDeleteSuite: Tests deletes of selections") table_test_mutation_delete := r.DB("db_mut_del").Table("table_test_mutation_delete") _ = table_test_mutation_delete // Prevent any noused variable errors { // mutation/delete.yaml line #7 /* ({'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':100}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 100} /* table_test_mutation_delete.insert([{'id':i} for i in xrange(100)]) */ suite.T().Log("About to run line #7: table_test_mutation_delete.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_mutation_delete.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i}) } return res }())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // mutation/delete.yaml line #19 /* 100 */ var expected_ int = 100 /* table_test_mutation_delete.count() */ suite.T().Log("About to run line #19: table_test_mutation_delete.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_delete.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // mutation/delete.yaml line #24 /* ({'deleted':1,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 1, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0} /* table_test_mutation_delete.get(12).delete() */ suite.T().Log("About to run line #24: table_test_mutation_delete.Get(12).Delete()") runAndAssert(suite.Suite, expected_, table_test_mutation_delete.Get(12).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // mutation/delete.yaml line #31 /* err('ReqlQueryLogicError', 'Durability option `wrong` unrecognized (options are "hard" and "soft").', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Durability option `wrong` unrecognized (options are \"hard\" and \"soft\").") /* table_test_mutation_delete.skip(50).delete(durability='wrong') */ suite.T().Log("About to run line #31: table_test_mutation_delete.Skip(50).Delete().OptArgs(r.DeleteOpts{Durability: 'wrong', })") runAndAssert(suite.Suite, expected_, table_test_mutation_delete.Skip(50).Delete().OptArgs(r.DeleteOpts{Durability: "wrong"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // mutation/delete.yaml line #38 /* ({'deleted':49,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 49, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0} /* table_test_mutation_delete.skip(50).delete(durability='soft') */ suite.T().Log("About to run line #38: table_test_mutation_delete.Skip(50).Delete().OptArgs(r.DeleteOpts{Durability: 'soft', })") runAndAssert(suite.Suite, expected_, table_test_mutation_delete.Skip(50).Delete().OptArgs(r.DeleteOpts{Durability: "soft"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // mutation/delete.yaml line #45 /* ({'deleted':50,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 50, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0} /* table_test_mutation_delete.delete(durability='hard') */ suite.T().Log("About to run line #45: table_test_mutation_delete.Delete().OptArgs(r.DeleteOpts{Durability: 'hard', })") runAndAssert(suite.Suite, expected_, table_test_mutation_delete.Delete().OptArgs(r.DeleteOpts{Durability: "hard"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #45") } { // mutation/delete.yaml line #49 /* err('ReqlQueryLogicError', 'Expected type SELECTION but found DATUM:', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type SELECTION but found DATUM:") /* r.expr([1, 2]).delete() */ suite.T().Log("About to run line #49: r.Expr([]interface{}{1, 2}).Delete()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2}).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_mutation_insert_test.go000066400000000000000000001420561363464422500302770ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests insertion into tables func TestMutationInsertSuite(t *testing.T) { suite.Run(t, new(MutationInsertSuite)) } type MutationInsertSuite struct { suite.Suite session *r.Session } func (suite *MutationInsertSuite) SetupTest() { suite.T().Log("Setting up MutationInsertSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mut_ins").Exec(suite.session) err = r.DBCreate("db_mut_ins").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_ins").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_mut_ins").TableDrop("table_test_mutation_insert").Exec(suite.session) err = r.DB("db_mut_ins").TableCreate("table_test_mutation_insert").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_ins").Table("table_test_mutation_insert").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MutationInsertSuite) TearDownSuite() { suite.T().Log("Tearing down MutationInsertSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_mut_ins").TableDrop("table_test_mutation_insert").Exec(suite.session) r.DBDrop("db_mut_ins").Exec(suite.session) suite.session.Close() } } func (suite *MutationInsertSuite) TestCases() { suite.T().Log("Running MutationInsertSuite: Tests insertion into tables") table_test_mutation_insert := r.DB("db_mut_ins").Table("table_test_mutation_insert") _ = table_test_mutation_insert // Prevent any noused variable errors { // mutation/insert.yaml line #6 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.db('test').table_create('table_test2_mutation') */ suite.T().Log("About to run line #6: r.DB('test').TableCreate('table_test2_mutation')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableCreate("table_test2_mutation"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } // mutation/insert.yaml line #9 // table_test_mutation_insert2 = r.db('test').table('table_test2_mutation') suite.T().Log("Possibly executing: var table_test_mutation_insert2 r.Term = r.DB('test').Table('table_test2_mutation')") table_test_mutation_insert2 := r.DB("db_mut_ins").Table("table_test2_mutation") _ = table_test_mutation_insert2 // Prevent any noused variable errors { // mutation/insert.yaml line #12 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insert.insert({'id':0,'a':0}) */ suite.T().Log("About to run line #12: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 0, 'a': 0, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 0, "a": 0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // mutation/insert.yaml line #14 /* 1 */ var expected_ int = 1 /* table_test_mutation_insert.count() */ suite.T().Log("About to run line #14: table_test_mutation_insert.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // mutation/insert.yaml line #18 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insert.insert({'id':1, 'a':1}, durability='hard') */ suite.T().Log("About to run line #18: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 1, 'a': 1, }).OptArgs(r.InsertOpts{Durability: 'hard', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 1, "a": 1}).OptArgs(r.InsertOpts{Durability: "hard"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // mutation/insert.yaml line #22 /* 2 */ var expected_ int = 2 /* table_test_mutation_insert.count() */ suite.T().Log("About to run line #22: table_test_mutation_insert.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // mutation/insert.yaml line #26 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insert.insert({'id':2, 'a':2}, durability='soft') */ suite.T().Log("About to run line #26: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'a': 2, }).OptArgs(r.InsertOpts{Durability: 'soft', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "a": 2}).OptArgs(r.InsertOpts{Durability: "soft"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // mutation/insert.yaml line #30 /* 3 */ var expected_ int = 3 /* table_test_mutation_insert.count() */ suite.T().Log("About to run line #30: table_test_mutation_insert.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // mutation/insert.yaml line #34 /* err('ReqlQueryLogicError', 'Durability option `wrong` unrecognized (options are "hard" and "soft").', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Durability option `wrong` unrecognized (options are \"hard\" and \"soft\").") /* table_test_mutation_insert.insert({'id':3, 'a':3}, durability='wrong') */ suite.T().Log("About to run line #34: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 3, 'a': 3, }).OptArgs(r.InsertOpts{Durability: 'wrong', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 3, "a": 3}).OptArgs(r.InsertOpts{Durability: "wrong"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // mutation/insert.yaml line #38 /* 3 */ var expected_ int = 3 /* table_test_mutation_insert.count() */ suite.T().Log("About to run line #38: table_test_mutation_insert.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // mutation/insert.yaml line #42 /* {'deleted':1,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 1, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0} /* table_test_mutation_insert.get(2).delete() */ suite.T().Log("About to run line #42: table_test_mutation_insert.Get(2).Delete()") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(2).Delete(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #42") } { // mutation/insert.yaml line #46 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':2} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 2} /* table_test_mutation_insert.insert([{'id':2,'a':2}, {'id':3,'a':3}]) */ suite.T().Log("About to run line #46: table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{'id': 2, 'a': 2, }, map[interface{}]interface{}{'id': 3, 'a': 3, }})") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{"id": 2, "a": 2}, map[interface{}]interface{}{"id": 3, "a": 3}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // mutation/insert.yaml line #50 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':4} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 4} /* table_test_mutation_insert2.insert(table_test_mutation_insert) */ suite.T().Log("About to run line #50: table_test_mutation_insert2.Insert(table_test_mutation_insert)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert2.Insert(table_test_mutation_insert), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // mutation/insert.yaml line #54 /* {'first_error':"Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}",'deleted':0,'replaced':0,'unchanged':0,'errors':1,'skipped':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}", "deleted": 0, "replaced": 0, "unchanged": 0, "errors": 1, "skipped": 0, "inserted": 0} /* table_test_mutation_insert.insert({'id':2,'b':20}) */ suite.T().Log("About to run line #54: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'b': 20, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "b": 20}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // mutation/insert.yaml line #58 /* {'first_error':"Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}",'deleted':0,'replaced':0,'unchanged':0,'errors':1,'skipped':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}", "deleted": 0, "replaced": 0, "unchanged": 0, "errors": 1, "skipped": 0, "inserted": 0} /* table_test_mutation_insert.insert({'id':2,'b':20}, conflict='error') */ suite.T().Log("About to run line #58: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'error', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "b": 20}).OptArgs(r.InsertOpts{Conflict: "error"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // mutation/insert.yaml line #64 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insert.insert({'id':15,'b':20}, conflict='error') */ suite.T().Log("About to run line #64: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 15, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'error', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 15, "b": 20}).OptArgs(r.InsertOpts{Conflict: "error"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #64") } { // mutation/insert.yaml line #69 /* {'id':15,'b':20} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 15, "b": 20} /* table_test_mutation_insert.get(15) */ suite.T().Log("About to run line #69: table_test_mutation_insert.Get(15)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(15), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } { // mutation/insert.yaml line #73 /* {'deleted':0,'replaced':1,'unchanged':0,'errors':0,'skipped':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 1, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0} /* table_test_mutation_insert.insert({'id':2,'b':20}, conflict='replace') */ suite.T().Log("About to run line #73: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'replace', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "b": 20}).OptArgs(r.InsertOpts{Conflict: "replace"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // mutation/insert.yaml line #78 /* {'id':2,'b':20} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 2, "b": 20} /* table_test_mutation_insert.get(2) */ suite.T().Log("About to run line #78: table_test_mutation_insert.Get(2)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #78") } { // mutation/insert.yaml line #82 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insert.insert({'id':20,'b':20}, conflict='replace') */ suite.T().Log("About to run line #82: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 20, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'replace', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 20, "b": 20}).OptArgs(r.InsertOpts{Conflict: "replace"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // mutation/insert.yaml line #87 /* {'id':20,'b':20} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 20, "b": 20} /* table_test_mutation_insert.get(20) */ suite.T().Log("About to run line #87: table_test_mutation_insert.Get(20)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(20), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } { // mutation/insert.yaml line #91 /* {'deleted':0,'replaced':1,'unchanged':0,'errors':0,'skipped':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 1, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0} /* table_test_mutation_insert.insert({'id':2,'c':30}, conflict='update') */ suite.T().Log("About to run line #91: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'c': 30, }).OptArgs(r.InsertOpts{Conflict: 'update', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "c": 30}).OptArgs(r.InsertOpts{Conflict: "update"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // mutation/insert.yaml line #96 /* {'id':2, 'b':20, 'c':30} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 2, "b": 20, "c": 30} /* table_test_mutation_insert.get(2) */ suite.T().Log("About to run line #96: table_test_mutation_insert.Get(2)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #96") } { // mutation/insert.yaml line #100 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insert.insert({'id':30,'b':20}, conflict='update') */ suite.T().Log("About to run line #100: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 30, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'update', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 30, "b": 20}).OptArgs(r.InsertOpts{Conflict: "update"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // mutation/insert.yaml line #105 /* {'id':30,'b':20} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 30, "b": 20} /* table_test_mutation_insert.get(30) */ suite.T().Log("About to run line #105: table_test_mutation_insert.Get(30)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(30), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #105") } { // mutation/insert.yaml line #109 /* err('ReqlQueryLogicError', 'Conflict option `wrong` unrecognized (options are "error", "replace" and "update").', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Conflict option `wrong` unrecognized (options are \"error\", \"replace\" and \"update\").") /* table_test_mutation_insert.insert({'id':3, 'a':3}, conflict='wrong') */ suite.T().Log("About to run line #109: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 3, 'a': 3, }).OptArgs(r.InsertOpts{Conflict: 'wrong', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 3, "a": 3}).OptArgs(r.InsertOpts{Conflict: "wrong"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } // mutation/insert.yaml line #120 // table_test_mutation_insertpkey = r.db('test').table('testpkey_mutation_insert') suite.T().Log("Possibly executing: var table_test_mutation_insertpkey r.Term = r.DB('test').Table('testpkey_mutation_insert')") table_test_mutation_insertpkey := r.DB("db_mut_ins").Table("testpkey_mutation_insert") _ = table_test_mutation_insertpkey // Prevent any noused variable errors { // mutation/insert.yaml line #115 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.db('test').table_create('testpkey_mutation_insert', primary_key='foo') */ suite.T().Log("About to run line #115: r.DB('test').TableCreate('testpkey_mutation_insert').OptArgs(r.TableCreateOpts{PrimaryKey: 'foo', })") runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableCreate("testpkey_mutation_insert").OptArgs(r.TableCreateOpts{PrimaryKey: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #115") } { // mutation/insert.yaml line #122 /* {'deleted':0,'replaced':0,'generated_keys':arrlen(1,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insertpkey.insert({}) */ suite.T().Log("About to run line #122: table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{})") runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // mutation/insert.yaml line #125 /* [{'foo':uuid()}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"foo": compare.IsUUID()}} /* table_test_mutation_insertpkey */ suite.T().Log("About to run line #125: table_test_mutation_insertpkey") runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // mutation/insert.yaml line #129 /* {'deleted':0,'replaced':0,'generated_keys':arrlen(1,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insertpkey.insert({'b':20}, conflict='replace') */ suite.T().Log("About to run line #129: table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'replace', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{"b": 20}).OptArgs(r.InsertOpts{Conflict: "replace"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #129") } { // mutation/insert.yaml line #135 /* {'deleted':0,'replaced':0,'generated_keys':arrlen(1,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1} /* table_test_mutation_insertpkey.insert({'b':20}, conflict='update') */ suite.T().Log("About to run line #135: table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'update', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{"b": 20}).OptArgs(r.InsertOpts{Conflict: "update"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #135") } { // mutation/insert.yaml line #140 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* r.db('test').table_drop('testpkey_mutation_insert') */ suite.T().Log("About to run line #140: r.DB('test').TableDrop('testpkey_mutation_insert')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableDrop("testpkey_mutation_insert"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #140") } { // mutation/insert.yaml line #144 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':7} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 7} /* table_test_mutation_insert.for_each(lambda row: table_test_mutation_insert2.insert(row.merge({'id':row['id'] + 100 })) ) */ suite.T().Log("About to run line #144: table_test_mutation_insert.ForEach(func(row r.Term) interface{} { return table_test_mutation_insert2.Insert(row.Merge(map[interface{}]interface{}{'id': row.AtIndex('id').Add(100), }))})") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.ForEach(func(row r.Term) interface{} { return table_test_mutation_insert2.Insert(row.Merge(map[interface{}]interface{}{"id": row.AtIndex("id").Add(100)})) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #144") } { // mutation/insert.yaml line #150 /* partial({'errors':1,'first_error':'`r.minval` and `r.maxval` cannot be written to disk.'}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 1, "first_error": "`r.minval` and `r.maxval` cannot be written to disk."}) /* table_test_mutation_insert.insert({'value':r.minval}) */ suite.T().Log("About to run line #150: table_test_mutation_insert.Insert(map[interface{}]interface{}{'value': r.MinVal, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"value": r.MinVal}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #150") } { // mutation/insert.yaml line #154 /* partial({'errors':1,'first_error':'`r.minval` and `r.maxval` cannot be written to disk.'}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 1, "first_error": "`r.minval` and `r.maxval` cannot be written to disk."}) /* table_test_mutation_insert.insert({'value':r.maxval}) */ suite.T().Log("About to run line #154: table_test_mutation_insert.Insert(map[interface{}]interface{}{'value': r.MaxVal, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"value": r.MaxVal}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #154") } { // mutation/insert.yaml line #159 /* {'changes': [{'new_val': {'id': 666}, 'old_val': None},{'error': 'Duplicate primary key `id`:\n{\n\t"id":\t666\n}\n{\n\t"id":\t666\n}','new_val': {'id': 666},'old_val': {'id': 666}}],'deleted': 0,'errors': 1,'first_error': 'Duplicate primary key `id`:\n{\n\t"id":\t666\n}\n{\n\t"id":\t666\n}','inserted': 1,'replaced': 0,'skipped': 0,'unchanged': 0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 666}, "old_val": nil}, map[interface{}]interface{}{"error": "Duplicate primary key `id`:\n{\n\t\"id\":\t666\n}\n{\n\t\"id\":\t666\n}", "new_val": map[interface{}]interface{}{"id": 666}, "old_val": map[interface{}]interface{}{"id": 666}}}, "deleted": 0, "errors": 1, "first_error": "Duplicate primary key `id`:\n{\n\t\"id\":\t666\n}\n{\n\t\"id\":\t666\n}", "inserted": 1, "replaced": 0, "skipped": 0, "unchanged": 0} /* table_test_mutation_insert.insert([{'id':666}, {'id':666}], return_changes="always") */ suite.T().Log("About to run line #159: table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{'id': 666, }, map[interface{}]interface{}{'id': 666, }}).OptArgs(r.InsertOpts{ReturnChanges: 'always', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{"id": 666}, map[interface{}]interface{}{"id": 666}}).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // mutation/insert.yaml line #163 /* partial({'changes':[{'old_val': None, 'new_val': {'id': 100+i, 'ordered-num': i}} for i in range(1,100)] }) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 100 + i, "ordered-num": i}}) } return res }())}) /* table_test_mutation_insert.insert([{'id':100+i, 'ordered-num':i} for i in range(1,100)], return_changes="always") */ suite.T().Log("About to run line #163: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': r.Add(100, i), 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: 'always', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": r.Add(100, i), "ordered-num": i}) } return res }())).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #163") } { // mutation/insert.yaml line #167 /* partial({'changes':[{'old_val': None, 'new_val': {'id': [1,"blah", 200+i], 'ordered-num': i}} for i in range(1,100)] }) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": []interface{}{1, "blah", 200 + i}, "ordered-num": i}}) } return res }())}) /* table_test_mutation_insert.insert([{'id':[1, "blah", 200+i], 'ordered-num':i} for i in range(1,100)], return_changes="always") */ suite.T().Log("About to run line #167: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': []interface{}{1, 'blah', r.Add(200, i)}, 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: 'always', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": []interface{}{1, "blah", r.Add(200, i)}, "ordered-num": i}) } return res }())).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #167") } { // mutation/insert.yaml line #171 /* partial({'changes':[{'old_val': None, 'new_val': {'id': [1,"blah", 300+i], 'ordered-num': i}} for i in range(1,100)] }) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": []interface{}{1, "blah", 300 + i}, "ordered-num": i}}) } return res }())}) /* table_test_mutation_insert.insert([{'id':[1, "blah", 300+i], 'ordered-num':i} for i in range(1,100)], return_changes=true) */ suite.T().Log("About to run line #171: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': []interface{}{1, 'blah', r.Add(300, i)}, 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: true, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": []interface{}{1, "blah", r.Add(300, i)}, "ordered-num": i}) } return res }())).OptArgs(r.InsertOpts{ReturnChanges: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #171") } { // mutation/insert.yaml line #175 /* partial({'changes':[{'old_val': {'id':100+i, 'ordered-num':i}, 'new_val': {'id':100+i, 'ordered-num':i}, 'error':'Duplicate primary key `id`:\n{\n\t"id":\t'+str(100+i)+',\n\t"ordered-num":\t'+str(i)+'\n}\n{\n\t"id":\t'+str(100+i)+',\n\t"ordered-num":\t'+str(i)+'\n}'} for i in range(1,100)]}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 100 + i, "ordered-num": i}, "new_val": map[interface{}]interface{}{"id": 100 + i, "ordered-num": i}, "error": "Duplicate primary key `id`:\n{\n\t\"id\":\t" + str(100+i) + ",\n\t\"ordered-num\":\t" + str(i) + "\n}\n{\n\t\"id\":\t" + str(100+i) + ",\n\t\"ordered-num\":\t" + str(i) + "\n}"}) } return res }())}) /* table_test_mutation_insert.insert([{'id':100 + i, 'ordered-num':i} for i in range(1,100)], return_changes="always") */ suite.T().Log("About to run line #175: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': r.Add(100, i), 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: 'always', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": r.Add(100, i), "ordered-num": i}) } return res }())).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #175") } { // mutation/insert.yaml line #179 /* {'changes': [{'error': 'Duplicate primary key `id`:\n{\n\t"id":\t123,\n\t"ordered-num":\t23\n}\n{\n\t"id":\t123\n}', 'new_val': {'id': 123, 'ordered-num': 23}, 'old_val': {'id': 123, 'ordered-num': 23}}, {'error': 'Primary key too long (max 127 characters): "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"', 'new_val': None, 'old_val': None}, {'new_val': {'id': 321}, 'old_val': None}], 'deleted': 0, 'errors': 2, 'first_error': 'Primary key too long (max 127 characters): "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"', 'inserted': 1, 'replaced': 0, 'skipped': 0, 'unchanged': 0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"error": "Duplicate primary key `id`:\n{\n\t\"id\":\t123,\n\t\"ordered-num\":\t23\n}\n{\n\t\"id\":\t123\n}", "new_val": map[interface{}]interface{}{"id": 123, "ordered-num": 23}, "old_val": map[interface{}]interface{}{"id": 123, "ordered-num": 23}}, map[interface{}]interface{}{"error": "Primary key too long (max 127 characters): \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"", "new_val": nil, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 321}, "old_val": nil}}, "deleted": 0, "errors": 2, "first_error": "Primary key too long (max 127 characters): \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"", "inserted": 1, "replaced": 0, "skipped": 0, "unchanged": 0} /* table_test_mutation_insert.insert([{'id':123}, {'id':'a'*500}, {'id':321}], return_changes="always") */ suite.T().Log("About to run line #179: table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{'id': 123, }, map[interface{}]interface{}{'id': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', }, map[interface{}]interface{}{'id': 321, }}).OptArgs(r.InsertOpts{ReturnChanges: 'always', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{"id": 123}, map[interface{}]interface{}{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, map[interface{}]interface{}{"id": 321}}).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #179") } { // mutation/insert.yaml line #183 /* partial({'changes':[]}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": []interface{}{}}) /* table_test_mutation_insert.insert([{'id':100 + i, 'ordered-num':i} for i in range(1,100)], return_changes=true) */ suite.T().Log("About to run line #183: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': r.Add(100, i), 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: true, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 1; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": r.Add(100, i), "ordered-num": i}) } return res }())).OptArgs(r.InsertOpts{ReturnChanges: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #183") } { // mutation/insert.yaml line #186 /* partial({'changes': [{'old_val': None, 'new_val': None, 'error': '`r.minval` and `r.maxval` cannot be written to disk.'}]}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": nil, "error": "`r.minval` and `r.maxval` cannot be written to disk."}}}) /* table_test_mutation_insert.insert({'a':r.minval}, return_changes="always") */ suite.T().Log("About to run line #186: table_test_mutation_insert.Insert(map[interface{}]interface{}{'a': r.MinVal, }).OptArgs(r.InsertOpts{ReturnChanges: 'always', })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"a": r.MinVal}).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #186") } { // mutation/insert.yaml line #192 /* partial({'inserted':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 1}) /* table_test_mutation_insert.insert({'id':42, 'foo':1, 'bar':1}) */ suite.T().Log("About to run line #192: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, 'foo': 1, 'bar': 1, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42, "foo": 1, "bar": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #192") } { // mutation/insert.yaml line #194 /* partial({'replaced':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"replaced": 1}) /* table_test_mutation_insert.insert({'id':42, 'foo':5, 'bar':5}, conflict=lambda id, old_row, new_row: old_row.merge(new_row.pluck("bar"))) */ suite.T().Log("About to run line #194: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, 'foo': 5, 'bar': 5, }).OptArgs(r.InsertOpts{Conflict: func(id r.Term, old_row r.Term, new_row r.Term) interface{} { return old_row.Merge(new_row.Pluck('bar'))}, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42, "foo": 5, "bar": 5}).OptArgs(r.InsertOpts{Conflict: func(id r.Term, old_row r.Term, new_row r.Term) interface{} { return old_row.Merge(new_row.Pluck("bar")) }}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #194") } { // mutation/insert.yaml line #196 /* {'id':42, 'foo':1, 'bar':5} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 42, "foo": 1, "bar": 5} /* table_test_mutation_insert.get(42) */ suite.T().Log("About to run line #196: table_test_mutation_insert.Get(42)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(42), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #196") } { // mutation/insert.yaml line #214 /* partial({'first_error': 'Inserted value must be an OBJECT (got NUMBER):\n2'}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"first_error": "Inserted value must be an OBJECT (got NUMBER):\n2"}) /* table_test_mutation_insert.insert({'id':42, 'foo':1, 'bar':1}, conflict=lambda a,b,c: 2) */ suite.T().Log("About to run line #214: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, 'foo': 1, 'bar': 1, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return 2}, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42, "foo": 1, "bar": 1}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return 2 }}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #214") } { // mutation/insert.yaml line #218 /* err("ReqlQueryLogicError", "The conflict function passed to `insert` should expect 3 arguments.") */ var expected_ Err = err("ReqlQueryLogicError", "The conflict function passed to `insert` should expect 3 arguments.") /* table_test_mutation_insert.insert({'id':42}, conflict=lambda a,b: a) */ suite.T().Log("About to run line #218: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term) interface{} { return a}, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term) interface{} { return a }}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #218") } { // mutation/insert.yaml line #222 /* err("ReqlQueryLogicError", "The conflict function passed to `insert` must be deterministic.") */ var expected_ Err = err("ReqlQueryLogicError", "The conflict function passed to `insert` must be deterministic.") /* table_test_mutation_insert.insert({'id':42}, conflict=lambda a,b,c: table_test_mutation_insert.get(42)) */ suite.T().Log("About to run line #222: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return table_test_mutation_insert.Get(42)}, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return table_test_mutation_insert.Get(42) }}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #222") } { // mutation/insert.yaml line #225 /* partial({'replaced': 1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"replaced": 1}) /* table_test_mutation_insert.insert({'id':42}, conflict=lambda a,b,c: {'id':42, 'num':'424'}) */ suite.T().Log("About to run line #225: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return map[interface{}]interface{}{'id': 42, 'num': '424', }}, })") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return map[interface{}]interface{}{"id": 42, "num": "424"} }}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #225") } { // mutation/insert.yaml line #227 /* {'id':42, 'num':'424'} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 42, "num": "424"} /* table_test_mutation_insert.get(42) */ suite.T().Log("About to run line #227: table_test_mutation_insert.Get(42)") runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(42), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #227") } { // mutation/insert.yaml line #231 /* err('ReqlQueryLogicError','Cannot convert `r.minval` to JSON.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.minval` to JSON.") /* r.minval */ suite.T().Log("About to run line #231: r.MinVal") runAndAssert(suite.Suite, expected_, r.MinVal, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #231") } { // mutation/insert.yaml line #234 /* err('ReqlQueryLogicError','Cannot convert `r.maxval` to JSON.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.maxval` to JSON.") /* r.maxval */ suite.T().Log("About to run line #234: r.MaxVal") runAndAssert(suite.Suite, expected_, r.MaxVal, suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #234") } { // mutation/insert.yaml line #238 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* r.db('test').table_drop('table_test2_mutation') */ suite.T().Log("About to run line #238: r.DB('test').TableDrop('table_test2_mutation')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableDrop("table_test2_mutation"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #238") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_mutation_replace_test.go000066400000000000000000000402651363464422500304050ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests replacement of selections func TestMutationReplaceSuite(t *testing.T) { suite.Run(t, new(MutationReplaceSuite)) } type MutationReplaceSuite struct { suite.Suite session *r.Session } func (suite *MutationReplaceSuite) SetupTest() { suite.T().Log("Setting up MutationReplaceSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mut_rep").Exec(suite.session) err = r.DBCreate("db_mut_rep").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_rep").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_mut_rep").TableDrop("table_test_mutation_replace").Exec(suite.session) err = r.DB("db_mut_rep").TableCreate("table_test_mutation_replace").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_rep").Table("table_test_mutation_replace").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MutationReplaceSuite) TearDownSuite() { suite.T().Log("Tearing down MutationReplaceSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_mut_rep").TableDrop("table_test_mutation_replace").Exec(suite.session) r.DBDrop("db_mut_rep").Exec(suite.session) suite.session.Close() } } func (suite *MutationReplaceSuite) TestCases() { suite.T().Log("Running MutationReplaceSuite: Tests replacement of selections") table_test_mutation_replace := r.DB("db_mut_rep").Table("table_test_mutation_replace") _ = table_test_mutation_replace // Prevent any noused variable errors { // mutation/replace.yaml line #7 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* table_test_mutation_replace.insert([{'id':i} for i in xrange(100)]) */ suite.T().Log("About to run line #7: table_test_mutation_replace.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i}) } return res }())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // mutation/replace.yaml line #19 /* 100 */ var expected_ int = 100 /* table_test_mutation_replace.count() */ suite.T().Log("About to run line #19: table_test_mutation_replace.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // mutation/replace.yaml line #24 /* ({'deleted':0.0,'replaced':0.0,'unchanged':1,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 1, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(12).replace(lambda row:{'id':row['id']}) */ suite.T().Log("About to run line #24: table_test_mutation_replace.Get(12).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{'id': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(12).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{"id": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // mutation/replace.yaml line #31 /* ({'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(12).replace(lambda row:{'id':row['id'], 'a':row['id']}) */ suite.T().Log("About to run line #31: table_test_mutation_replace.Get(12).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{'id': row.AtIndex('id'), 'a': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(12).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{"id": row.AtIndex("id"), "a": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // mutation/replace.yaml line #36 /* ({'deleted':1,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 1, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(13).replace(lambda row:null) */ suite.T().Log("About to run line #36: table_test_mutation_replace.Get(13).Replace(func(row r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(13).Replace(func(row r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // mutation/replace.yaml line #43 /* ({'first_error':'Inserted object must have primary key `id`:\n{\n\t\"a\":\t1\n}','deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':10,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Inserted object must have primary key `id`:\n{\n\t\"a\":\t1\n}", "deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 10, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.between(10, 20, right_bound='closed').replace(lambda row:{'a':1}) */ suite.T().Log("About to run line #43: table_test_mutation_replace.Between(10, 20).OptArgs(r.BetweenOpts{RightBound: 'closed', }).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': 1, }})") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Between(10, 20).OptArgs(r.BetweenOpts{RightBound: "closed"}).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": 1} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // mutation/replace.yaml line #47 /* ({'deleted':0.0,'replaced':8,'unchanged':1,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 8, "unchanged": 1, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.filter(lambda row:(row['id'] >= 10) & (row['id'] < 20)).replace(lambda row:{'id':row['id'], 'a':row['id']}) */ suite.T().Log("About to run line #47: table_test_mutation_replace.Filter(func(row r.Term) interface{} { return row.AtIndex('id').Ge(10).And(row.AtIndex('id').Lt(20))}).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{'id': row.AtIndex('id'), 'a': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Filter(func(row r.Term) interface{} { return row.AtIndex("id").Ge(10).And(row.AtIndex("id").Lt(20)) }).Replace(func(row r.Term) interface{} { return map[interface{}]interface{}{"id": row.AtIndex("id"), "a": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // mutation/replace.yaml line #56 /* ({'first_error':"Primary key `id` cannot be changed (`{\n\t\"id\":\t1\n}` -> `{\n\t\"a\":\t1,\n\t\"id\":\t2\n}`).",'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':1,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Primary key `id` cannot be changed (`{\n\t\"id\":\t1\n}` -> `{\n\t\"a\":\t1,\n\t\"id\":\t2\n}`).", "deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 1, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(1).replace({'id':2,'a':1}) */ suite.T().Log("About to run line #56: table_test_mutation_replace.Get(1).Replace(map[interface{}]interface{}{'id': 2, 'a': 1, })") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(map[interface{}]interface{}{"id": 2, "a": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #56") } { // mutation/replace.yaml line #61 /* ({'first_error':"Inserted object must have primary key `id`:\n{\n\t\"a\":\t1\n}",'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':1,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Inserted object must have primary key `id`:\n{\n\t\"a\":\t1\n}", "deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 1, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(1).replace({'a':1}) */ suite.T().Log("About to run line #61: table_test_mutation_replace.Get(1).Replace(map[interface{}]interface{}{'a': 1, })") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(map[interface{}]interface{}{"a": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #61") } { // mutation/replace.yaml line #65 /* ({'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(1).replace({'id':r.row['id'],'a':'b'}) */ suite.T().Log("About to run line #65: table_test_mutation_replace.Get(1).Replace(map[interface{}]interface{}{'id': r.Row.AtIndex('id'), 'a': 'b', })") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(map[interface{}]interface{}{"id": r.Row.AtIndex("id"), "a": "b"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // mutation/replace.yaml line #70 /* ({'deleted':0.0,'replaced':0.0,'unchanged':1,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 1, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(1).replace(r.row.merge({'a':'b'})) */ suite.T().Log("About to run line #70: table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{'a': 'b', }))") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{"a": "b"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // mutation/replace.yaml line #75 /* err('ReqlQueryLogicError', 'Could not prove argument deterministic. Maybe you want to use the non_atomic flag?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Could not prove argument deterministic. Maybe you want to use the non_atomic flag?") /* table_test_mutation_replace.get(1).replace(r.row.merge({'c':r.js('5')})) */ suite.T().Log("About to run line #75: table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{'c': r.JS('5'), }))") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{"c": r.JS("5")})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } { // mutation/replace.yaml line #79 /* err('ReqlQueryLogicError', 'Could not prove argument deterministic. Maybe you want to use the non_atomic flag?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Could not prove argument deterministic. Maybe you want to use the non_atomic flag?") /* table_test_mutation_replace.get(1).replace(r.row.merge({'c':table_test_mutation_replace.nth(0)})) */ suite.T().Log("About to run line #79: table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{'c': table_test_mutation_replace.Nth(0), }))") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{"c": table_test_mutation_replace.Nth(0)})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #79") } { // mutation/replace.yaml line #83 /* ({'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.get(1).replace(r.row.merge({'c':r.js('5')}), non_atomic=True) */ suite.T().Log("About to run line #83: table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{'c': r.JS('5'), })).OptArgs(r.ReplaceOpts{NonAtomic: true, })") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get(1).Replace(r.Row.Merge(map[interface{}]interface{}{"c": r.JS("5")})).OptArgs(r.ReplaceOpts{NonAtomic: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // mutation/replace.yaml line #99 /* ({'deleted':99,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 99, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_replace.replace(lambda row:null) */ suite.T().Log("About to run line #99: table_test_mutation_replace.Replace(func(row r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Replace(func(row r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #99") } { // mutation/replace.yaml line #104 /* 1 */ var expected_ int = 1 /* table_test_mutation_replace.get('sdfjk').replace({'id':'sdfjk'})['inserted'] */ suite.T().Log("About to run line #104: table_test_mutation_replace.Get('sdfjk').Replace(map[interface{}]interface{}{'id': 'sdfjk', }).AtIndex('inserted')") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get("sdfjk").Replace(map[interface{}]interface{}{"id": "sdfjk"}).AtIndex("inserted"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #104") } { // mutation/replace.yaml line #107 /* 1 */ var expected_ int = 1 /* table_test_mutation_replace.get('sdfjki').replace({'id':'sdfjk'})['errors'] */ suite.T().Log("About to run line #107: table_test_mutation_replace.Get('sdfjki').Replace(map[interface{}]interface{}{'id': 'sdfjk', }).AtIndex('errors')") runAndAssert(suite.Suite, expected_, table_test_mutation_replace.Get("sdfjki").Replace(map[interface{}]interface{}{"id": "sdfjk"}).AtIndex("errors"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #107") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_mutation_sync_test.go000066400000000000000000000165051363464422500277460ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests syncing tables func TestMutationSyncSuite(t *testing.T) { suite.Run(t, new(MutationSyncSuite)) } type MutationSyncSuite struct { suite.Suite session *r.Session } func (suite *MutationSyncSuite) SetupTest() { suite.T().Log("Setting up MutationSyncSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mut_sync").Exec(suite.session) err = r.DBCreate("db_mut_sync").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_sync").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MutationSyncSuite) TearDownSuite() { suite.T().Log("Tearing down MutationSyncSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_mut_sync").Exec(suite.session) suite.session.Close() } } func (suite *MutationSyncSuite) TestCases() { suite.T().Log("Running MutationSyncSuite: Tests syncing tables") { // mutation/sync.yaml line #5 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.db('test').table_create('test1') */ suite.T().Log("About to run line #5: r.DB('test').TableCreate('test1')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_sync").TableCreate("test1"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // mutation/sync.yaml line #7 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.db('test').table_create('test1soft') */ suite.T().Log("About to run line #7: r.DB('test').TableCreate('test1soft')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_sync").TableCreate("test1soft"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // mutation/sync.yaml line #9 /* {'skipped':0, 'deleted':0, 'unchanged':0, 'errors':0, 'replaced':1, 'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"skipped": 0, "deleted": 0, "unchanged": 0, "errors": 0, "replaced": 1, "inserted": 0} /* r.db('test').table('test1soft').config().update({'durability':'soft'}) */ suite.T().Log("About to run line #9: r.DB('test').Table('test1soft').Config().Update(map[interface{}]interface{}{'durability': 'soft', })") runAndAssert(suite.Suite, expected_, r.DB("db_mut_sync").Table("test1soft").Config().Update(map[interface{}]interface{}{"durability": "soft"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } // mutation/sync.yaml line #11 // tbl = r.db('test').table('test1') suite.T().Log("Possibly executing: var tbl r.Term = r.DB('test').Table('test1')") tbl := r.DB("db_mut_sync").Table("test1") _ = tbl // Prevent any noused variable errors // mutation/sync.yaml line #12 // tbl_soft = r.db('test').table('test1soft') suite.T().Log("Possibly executing: var tbl_soft r.Term = r.DB('test').Table('test1soft')") tbl_soft := r.DB("db_mut_sync").Table("test1soft") _ = tbl_soft // Prevent any noused variable errors { // mutation/sync.yaml line #13 /* partial({'created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"created": 1}) /* tbl.index_create('x') */ suite.T().Log("About to run line #13: tbl.IndexCreate('x')") runAndAssert(suite.Suite, expected_, tbl.IndexCreate("x"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // mutation/sync.yaml line #15 /* [{'ready':True, 'index':'x'}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"ready": true, "index": "x"}} /* tbl.index_wait('x').pluck('index', 'ready') */ suite.T().Log("About to run line #15: tbl.IndexWait('x').Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, tbl.IndexWait("x").Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // mutation/sync.yaml line #19 /* {'synced':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"synced": 1} /* tbl.sync() */ suite.T().Log("About to run line #19: tbl.Sync()") runAndAssert(suite.Suite, expected_, tbl.Sync(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // mutation/sync.yaml line #21 /* {'synced':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"synced": 1} /* tbl_soft.sync() */ suite.T().Log("About to run line #21: tbl_soft.Sync()") runAndAssert(suite.Suite, expected_, tbl_soft.Sync(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // mutation/sync.yaml line #23 /* {'synced':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"synced": 1} /* tbl.sync() */ suite.T().Log("About to run line #23: tbl.Sync()") runAndAssert(suite.Suite, expected_, tbl.Sync(), suite.session, r.RunOpts{ Durability: "soft", GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // mutation/sync.yaml line #27 /* {'synced':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"synced": 1} /* tbl.sync() */ suite.T().Log("About to run line #27: tbl.Sync()") runAndAssert(suite.Suite, expected_, tbl.Sync(), suite.session, r.RunOpts{ Durability: "hard", GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // mutation/sync.yaml line #48 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* r.db('test').table_drop('test1') */ suite.T().Log("About to run line #48: r.DB('test').TableDrop('test1')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_sync").TableDrop("test1"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #48") } { // mutation/sync.yaml line #50 /* partial({'tables_dropped':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) /* r.db('test').table_drop('test1soft') */ suite.T().Log("About to run line #50: r.DB('test').TableDrop('test1soft')") runAndAssert(suite.Suite, expected_, r.DB("db_mut_sync").TableDrop("test1soft"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_mutation_update_test.go000066400000000000000000000675341363464422500302640ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests updates of selections func TestMutationUpdateSuite(t *testing.T) { suite.Run(t, new(MutationUpdateSuite)) } type MutationUpdateSuite struct { suite.Suite session *r.Session } func (suite *MutationUpdateSuite) SetupTest() { suite.T().Log("Setting up MutationUpdateSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_mut_upd").Exec(suite.session) err = r.DBCreate("db_mut_upd").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_upd").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_mut_upd").TableDrop("table_test_mutation_update").Exec(suite.session) err = r.DB("db_mut_upd").TableCreate("table_test_mutation_update").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_upd").Table("table_test_mutation_update").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_mut_upd").TableDrop("table_test_mutation_update2").Exec(suite.session) err = r.DB("db_mut_upd").TableCreate("table_test_mutation_update2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_mut_upd").Table("table_test_mutation_update2").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *MutationUpdateSuite) TearDownSuite() { suite.T().Log("Tearing down MutationUpdateSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_mut_upd").TableDrop("table_test_mutation_update").Exec(suite.session) r.DB("db_mut_upd").TableDrop("table_test_mutation_update2").Exec(suite.session) r.DBDrop("db_mut_upd").Exec(suite.session) suite.session.Close() } } func (suite *MutationUpdateSuite) TestCases() { suite.T().Log("Running MutationUpdateSuite: Tests updates of selections") table_test_mutation_update := r.DB("db_mut_upd").Table("table_test_mutation_update") _ = table_test_mutation_update // Prevent any noused variable errors table_test_mutation_update2 := r.DB("db_mut_upd").Table("table_test_mutation_update2") _ = table_test_mutation_update2 // Prevent any noused variable errors { // mutation/update.yaml line #6 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* table_test_mutation_update.insert([{'id':i} for i in xrange(100)]) */ suite.T().Log("About to run line #6: table_test_mutation_update.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i}) } return res }())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // mutation/update.yaml line #18 /* 100 */ var expected_ int = 100 /* table_test_mutation_update.count() */ suite.T().Log("About to run line #18: table_test_mutation_update.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // mutation/update.yaml line #21 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* table_test_mutation_update2.insert([{'id':i, 'foo':{'bar':i}} for i in xrange(100)]) */ suite.T().Log("About to run line #21: table_test_mutation_update2.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, 'foo': map[interface{}]interface{}{'bar': i, }, })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i, "foo": map[interface{}]interface{}{"bar": i}}) } return res }())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // mutation/update.yaml line #33 /* 100 */ var expected_ int = 100 /* table_test_mutation_update2.count() */ suite.T().Log("About to run line #33: table_test_mutation_update2.Count()") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // mutation/update.yaml line #37 /* {'deleted':0.0,'replaced':0.0,'unchanged':1,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 1, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(12).update(lambda row:row) */ suite.T().Log("About to run line #37: table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return row})") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return row }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // mutation/update.yaml line #43 /* {'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(12).update(lambda row:{'a':row['id'] + 1}, durability='soft') */ suite.T().Log("About to run line #43: table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id').Add(1), }}).OptArgs(r.UpdateOpts{Durability: 'soft', })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id").Add(1)} }).OptArgs(r.UpdateOpts{Durability: "soft"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // mutation/update.yaml line #48 /* {'id':12, 'a':13} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 12, "a": 13} /* table_test_mutation_update.get(12) */ suite.T().Log("About to run line #48: table_test_mutation_update.Get(12)") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #48") } { // mutation/update.yaml line #52 /* {'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(12).update(lambda row:{'a':row['id'] + 2}, durability='hard') */ suite.T().Log("About to run line #52: table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id').Add(2), }}).OptArgs(r.UpdateOpts{Durability: 'hard', })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id").Add(2)} }).OptArgs(r.UpdateOpts{Durability: "hard"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // mutation/update.yaml line #57 /* {'id':12, 'a':14} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 12, "a": 14} /* table_test_mutation_update.get(12) */ suite.T().Log("About to run line #57: table_test_mutation_update.Get(12)") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // mutation/update.yaml line #61 /* err('ReqlQueryLogicError', 'Durability option `wrong` unrecognized (options are "hard" and "soft").', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Durability option `wrong` unrecognized (options are \"hard\" and \"soft\").") /* table_test_mutation_update.get(12).update(lambda row:{'a':row['id'] + 3}, durability='wrong') */ suite.T().Log("About to run line #61: table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id').Add(3), }}).OptArgs(r.UpdateOpts{Durability: 'wrong', })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id").Add(3)} }).OptArgs(r.UpdateOpts{Durability: "wrong"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #61") } { // mutation/update.yaml line #66 /* {'id':12, 'a':14} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 12, "a": 14} /* table_test_mutation_update.get(12) */ suite.T().Log("About to run line #66: table_test_mutation_update.Get(12)") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } { // mutation/update.yaml line #70 /* {'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(12).update(lambda row:{'a':row['id']}) */ suite.T().Log("About to run line #70: table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // mutation/update.yaml line #75 /* {'id':12, 'a':12} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 12, "a": 12} /* table_test_mutation_update.get(12) */ suite.T().Log("About to run line #75: table_test_mutation_update.Get(12)") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #75") } { // mutation/update.yaml line #79 /* {'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(12).update({'a':r.literal()}) */ suite.T().Log("About to run line #79: table_test_mutation_update.Get(12).Update(map[interface{}]interface{}{'a': r.Literal(), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(12).Update(map[interface{}]interface{}{"a": r.Literal()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #79") } { // mutation/update.yaml line #84 /* {'deleted':0.0,'replaced':10,'unchanged':0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 10, "unchanged": 0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.between(10, 20).update(lambda row:{'a':row['id']}) */ suite.T().Log("About to run line #84: table_test_mutation_update.Between(10, 20).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Between(10, 20).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // mutation/update.yaml line #89 /* {'deleted':0.0,'replaced':0.0,'unchanged':10,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 10, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.filter(lambda row:(row['id'] >= 10) & (row['id'] < 20)).update(lambda row:{'a':row['id']}) */ suite.T().Log("About to run line #89: table_test_mutation_update.Filter(func(row r.Term) interface{} { return row.AtIndex('id').Ge(10).And(row.AtIndex('id').Lt(20))}).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Filter(func(row r.Term) interface{} { return row.AtIndex("id").Ge(10).And(row.AtIndex("id").Lt(20)) }).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #89") } { // mutation/update.yaml line #94 /* {'deleted':0.0,'replaced':10,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 10, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.filter(lambda row:(row['id'] >= 10) & (row['id'] < 20)).update(lambda row:{'b':row['id']}) */ suite.T().Log("About to run line #94: table_test_mutation_update.Filter(func(row r.Term) interface{} { return row.AtIndex('id').Ge(10).And(row.AtIndex('id').Lt(20))}).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'b': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Filter(func(row r.Term) interface{} { return row.AtIndex("id").Ge(10).And(row.AtIndex("id").Lt(20)) }).Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"b": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #94") } { // mutation/update.yaml line #100 /* {'deleted':0.0,'replaced':10,'unchanged':0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 10, "unchanged": 0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.between(10, 20).update({'a':r.literal()}) */ suite.T().Log("About to run line #100: table_test_mutation_update.Between(10, 20).Update(map[interface{}]interface{}{'a': r.Literal(), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Between(10, 20).Update(map[interface{}]interface{}{"a": r.Literal()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // mutation/update.yaml line #104 /* {'first_error':"Primary key `id` cannot be changed (`{\n\t\"id\":\t1\n}` -> `{\n\t\"d\":\t1,\n\t\"id\":\t2\n}`).",'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':1,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Primary key `id` cannot be changed (`{\n\t\"id\":\t1\n}` -> `{\n\t\"d\":\t1,\n\t\"id\":\t2\n}`).", "deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 1, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(1).update({'id':2,'d':1}) */ suite.T().Log("About to run line #104: table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{'id': 2, 'd': 1, })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{"id": 2, "d": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #104") } { // mutation/update.yaml line #108 /* {'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(1).update({'id':r.row['id'],'d':'b'}) */ suite.T().Log("About to run line #108: table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{'id': r.Row.AtIndex('id'), 'd': 'b', })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{"id": r.Row.AtIndex("id"), "d": "b"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #108") } { // mutation/update.yaml line #114 /* {'deleted':0.0,'replaced':0.0,'unchanged':1,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 1, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(1).update(r.row.merge({'d':'b'})) */ suite.T().Log("About to run line #114: table_test_mutation_update.Get(1).Update(r.Row.Merge(map[interface{}]interface{}{'d': 'b', }))") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(1).Update(r.Row.Merge(map[interface{}]interface{}{"d": "b"})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #114") } { // mutation/update.yaml line #119 /* err('ReqlQueryLogicError', 'Could not prove argument deterministic. Maybe you want to use the non_atomic flag?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Could not prove argument deterministic. Maybe you want to use the non_atomic flag?") /* table_test_mutation_update.get(1).update({'d':r.js('5')}) */ suite.T().Log("About to run line #119: table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{'d': r.JS('5'), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{"d": r.JS("5")}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #119") } { // mutation/update.yaml line #122 /* err('ReqlQueryLogicError', 'Could not prove argument deterministic. Maybe you want to use the non_atomic flag?', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Could not prove argument deterministic. Maybe you want to use the non_atomic flag?") /* table_test_mutation_update.get(1).update({'d':table_test_mutation_update.nth(0)}) */ suite.T().Log("About to run line #122: table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{'d': table_test_mutation_update.Nth(0), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{"d": table_test_mutation_update.Nth(0)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // mutation/update.yaml line #125 /* {'deleted':0.0,'replaced':1,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 1, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.get(1).update({'d':r.js('5')}, non_atomic=True) */ suite.T().Log("About to run line #125: table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{'d': r.JS('5'), }).OptArgs(r.UpdateOpts{NonAtomic: true, })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Get(1).Update(map[interface{}]interface{}{"d": r.JS("5")}).OptArgs(r.UpdateOpts{NonAtomic: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // mutation/update.yaml line #137 /* {'deleted':0.0,'replaced':100,'unchanged':0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 100, "unchanged": 0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.update(lambda row:{'a':row['id']}) */ suite.T().Log("About to run line #137: table_test_mutation_update.Update(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': row.AtIndex('id'), }})") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Update(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": row.AtIndex("id")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #137") } { // mutation/update.yaml line #143 /* {'deleted':0.0,'replaced':100,'unchanged':0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 100, "unchanged": 0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update.update({'a':r.literal()}) */ suite.T().Log("About to run line #143: table_test_mutation_update.Update(map[interface{}]interface{}{'a': r.Literal(), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update.Update(map[interface{}]interface{}{"a": r.Literal()}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #143") } { // mutation/update.yaml line #147 /* {'deleted':0.0,'replaced':99,'unchanged':1,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 99, "unchanged": 1, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update2.update({'foo':{'bar':2}}) */ suite.T().Log("About to run line #147: table_test_mutation_update2.Update(map[interface{}]interface{}{'foo': map[interface{}]interface{}{'bar': 2, }, })") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.Update(map[interface{}]interface{}{"foo": map[interface{}]interface{}{"bar": 2}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #147") } { // mutation/update.yaml line #150 /* {'deleted':0.0,'replaced':0,'unchanged':100,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0, "unchanged": 100, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update2.update({'foo':r.literal({'bar':2})}) */ suite.T().Log("About to run line #150: table_test_mutation_update2.Update(map[interface{}]interface{}{'foo': r.Literal(map[interface{}]interface{}{'bar': 2, }), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.Update(map[interface{}]interface{}{"foo": r.Literal(map[interface{}]interface{}{"bar": 2})}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #150") } { // mutation/update.yaml line #156 /* {'id':0,'foo':{'bar':2}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "foo": map[interface{}]interface{}{"bar": 2}} /* table_test_mutation_update2.order_by('id').nth(0) */ suite.T().Log("About to run line #156: table_test_mutation_update2.OrderBy('id').Nth(0)") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.OrderBy("id").Nth(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #156") } { // mutation/update.yaml line #159 /* {'deleted':0.0,'replaced':100,'unchanged':0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 100, "unchanged": 0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update2.update({'foo':{'buzz':2}}) */ suite.T().Log("About to run line #159: table_test_mutation_update2.Update(map[interface{}]interface{}{'foo': map[interface{}]interface{}{'buzz': 2, }, })") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.Update(map[interface{}]interface{}{"foo": map[interface{}]interface{}{"buzz": 2}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // mutation/update.yaml line #162 /* {'id':0,'foo':{'bar':2,'buzz':2}} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "foo": map[interface{}]interface{}{"bar": 2, "buzz": 2}} /* table_test_mutation_update2.order_by('id').nth(0) */ suite.T().Log("About to run line #162: table_test_mutation_update2.OrderBy('id').Nth(0)") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.OrderBy("id").Nth(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #162") } { // mutation/update.yaml line #165 /* {'deleted':0.0,'replaced':100,'unchanged':0,'errors':0.0,'skipped':0.0,'inserted':0.0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 100, "unchanged": 0, "errors": 0.0, "skipped": 0.0, "inserted": 0.0} /* table_test_mutation_update2.update({'foo':r.literal(1)}) */ suite.T().Log("About to run line #165: table_test_mutation_update2.Update(map[interface{}]interface{}{'foo': r.Literal(1), })") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.Update(map[interface{}]interface{}{"foo": r.Literal(1)}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #165") } { // mutation/update.yaml line #168 /* {'id':0,'foo':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "foo": 1} /* table_test_mutation_update2.order_by('id').nth(0) */ suite.T().Log("About to run line #168: table_test_mutation_update2.OrderBy('id').Nth(0)") runAndAssert(suite.Suite, expected_, table_test_mutation_update2.OrderBy("id").Nth(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #168") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_polymorphism_test.go000066400000000000000000000137271363464422500276170ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests that manipulation data in tables func TestPolymorphismSuite(t *testing.T) { suite.Run(t, new(PolymorphismSuite)) } type PolymorphismSuite struct { suite.Suite session *r.Session } func (suite *PolymorphismSuite) SetupTest() { suite.T().Log("Setting up PolymorphismSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_poly").Exec(suite.session) err = r.DBCreate("db_poly").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_poly").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_poly").TableDrop("table_test_poly").Exec(suite.session) err = r.DB("db_poly").TableCreate("table_test_poly").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_poly").Table("table_test_poly").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *PolymorphismSuite) TearDownSuite() { suite.T().Log("Tearing down PolymorphismSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_poly").TableDrop("table_test_poly").Exec(suite.session) r.DBDrop("db_poly").Exec(suite.session) suite.session.Close() } } func (suite *PolymorphismSuite) TestCases() { suite.T().Log("Running PolymorphismSuite: Tests that manipulation data in tables") table_test_poly := r.DB("db_poly").Table("table_test_poly") _ = table_test_poly // Prevent any noused variable errors // polymorphism.yaml line #5 // obj = r.expr({'id':0,'a':0}) suite.T().Log("Possibly executing: var obj r.Term = r.Expr(map[interface{}]interface{}{'id': 0, 'a': 0, })") obj := r.Expr(map[interface{}]interface{}{"id": 0, "a": 0}) _ = obj // Prevent any noused variable errors { // polymorphism.yaml line #7 /* ({'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':3}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 3} /* table_test_poly.insert([{'id':i, 'a':i} for i in xrange(3)]) */ suite.T().Log("About to run line #7: table_test_poly.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 3; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, 'a': i, })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_poly.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 3; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i, "a": i}) } return res }())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // polymorphism.yaml line #21 /* ({'id':0,'c':1,'a':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "c": 1, "a": 0} /* table_test_poly.merge({'c':1}).nth(0) */ suite.T().Log("About to run line #21: table_test_poly.Merge(map[interface{}]interface{}{'c': 1, }).Nth(0)") runAndAssert(suite.Suite, expected_, table_test_poly.Merge(map[interface{}]interface{}{"c": 1}).Nth(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // polymorphism.yaml line #22 /* ({'id':0,'c':1,'a':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "c": 1, "a": 0} /* obj.merge({'c':1}) */ suite.T().Log("About to run line #22: obj.Merge(map[interface{}]interface{}{'c': 1, })") runAndAssert(suite.Suite, expected_, obj.Merge(map[interface{}]interface{}{"c": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // polymorphism.yaml line #26 /* ({'id':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0} /* table_test_poly.without('a').nth(0) */ suite.T().Log("About to run line #26: table_test_poly.Without('a').Nth(0)") runAndAssert(suite.Suite, expected_, table_test_poly.Without("a").Nth(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // polymorphism.yaml line #27 /* ({'id':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0} /* obj.without('a') */ suite.T().Log("About to run line #27: obj.Without('a')") runAndAssert(suite.Suite, expected_, obj.Without("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // polymorphism.yaml line #31 /* ({'a':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0} /* table_test_poly.pluck('a').nth(0) */ suite.T().Log("About to run line #31: table_test_poly.Pluck('a').Nth(0)") runAndAssert(suite.Suite, expected_, table_test_poly.Pluck("a").Nth(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // polymorphism.yaml line #32 /* ({'a':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0} /* obj.pluck('a') */ suite.T().Log("About to run line #32: obj.Pluck('a')") runAndAssert(suite.Suite, expected_, obj.Pluck("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_random_test.go000066400000000000000000001143351363464422500263320ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests randomization functions func TestRandomSuite(t *testing.T) { suite.Run(t, new(RandomSuite)) } type RandomSuite struct { suite.Suite session *r.Session } func (suite *RandomSuite) SetupTest() { suite.T().Log("Setting up RandomSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_rand").Exec(suite.session) err = r.DBCreate("db_rand").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_rand").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *RandomSuite) TearDownSuite() { suite.T().Log("Tearing down RandomSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_rand").Exec(suite.session) suite.session.Close() } } func (suite *RandomSuite) TestCases() { suite.T().Log("Running RandomSuite: Tests randomization functions") { // random.yaml line #5 /* 3 */ var expected_ int = 3 /* r.expr([1,2,3]).sample(3).distinct().count() */ suite.T().Log("About to run line #5: r.Expr([]interface{}{1, 2, 3}).Sample(3).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(3).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // random.yaml line #7 /* 3 */ var expected_ int = 3 /* r.expr([1,2,3]).sample(3).count() */ suite.T().Log("About to run line #7: r.Expr([]interface{}{1, 2, 3}).Sample(3).Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(3).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // random.yaml line #9 /* 3 */ var expected_ int = 3 /* r.expr([1,2,3,4,5,6]).sample(3).distinct().count() */ suite.T().Log("About to run line #9: r.Expr([]interface{}{1, 2, 3, 4, 5, 6}).Sample(3).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4, 5, 6}).Sample(3).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // random.yaml line #11 /* 3 */ var expected_ int = 3 /* r.expr([1,2,3]).sample(4).distinct().count() */ suite.T().Log("About to run line #11: r.Expr([]interface{}{1, 2, 3}).Sample(4).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(4).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // random.yaml line #15 /* err('ReqlQueryLogicError', 'Number of items to sample must be non-negative, got `-1`.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Number of items to sample must be non-negative, got `-1`.") /* r.expr([1,2,3]).sample(-1) */ suite.T().Log("About to run line #15: r.Expr([]interface{}{1, 2, 3}).Sample(-1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Sample(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // random.yaml line #17 /* err('ReqlQueryLogicError', 'Cannot convert NUMBER to SEQUENCE', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert NUMBER to SEQUENCE") /* r.expr(1).sample(1) */ suite.T().Log("About to run line #17: r.Expr(1).Sample(1)") runAndAssert(suite.Suite, expected_, r.Expr(1).Sample(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } { // random.yaml line #19 /* err('ReqlQueryLogicError', 'Cannot convert OBJECT to SEQUENCE', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot convert OBJECT to SEQUENCE") /* r.expr({}).sample(1) */ suite.T().Log("About to run line #19: r.Expr(map[interface{}]interface{}{}).Sample(1)") runAndAssert(suite.Suite, expected_, r.Expr(map[interface{}]interface{}{}).Sample(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #19") } { // random.yaml line #25 /* True */ var expected_ bool = true /* r.random().do(lambda x:r.and_(x.ge(0), x.lt(1))) */ suite.T().Log("About to run line #25: r.Random().Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1))})") runAndAssert(suite.Suite, expected_, r.Random().Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // random.yaml line #26 /* True */ var expected_ bool = true /* r.random(1, float=True).do(lambda x:r.and_(x.ge(0), x.lt(1))) */ suite.T().Log("About to run line #26: r.Random(1).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1))})") runAndAssert(suite.Suite, expected_, r.Random(1).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // random.yaml line #27 /* True */ var expected_ bool = true /* r.random(0, 1, float=True).do(lambda x:r.and_(x.ge(0), x.lt(1))) */ suite.T().Log("About to run line #27: r.Random(0, 1).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1))})") runAndAssert(suite.Suite, expected_, r.Random(0, 1).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #27") } { // random.yaml line #28 /* True */ var expected_ bool = true /* r.random(1, 0, float=True).do(lambda x:r.and_(x.le(1), x.gt(0))) */ suite.T().Log("About to run line #28: r.Random(1, 0).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(1), x.Gt(0))})") runAndAssert(suite.Suite, expected_, r.Random(1, 0).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(1), x.Gt(0)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // random.yaml line #29 /* True */ var expected_ bool = true /* r.random(r.expr(0), 1, float=True).do(lambda x:r.and_(x.ge(0), x.lt(1))) */ suite.T().Log("About to run line #29: r.Random(r.Expr(0), 1).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1))})") runAndAssert(suite.Suite, expected_, r.Random(r.Expr(0), 1).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // random.yaml line #30 /* True */ var expected_ bool = true /* r.random(1, r.expr(0), float=True).do(lambda x:r.and_(x.le(1), x.gt(0))) */ suite.T().Log("About to run line #30: r.Random(1, r.Expr(0)).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(1), x.Gt(0))})") runAndAssert(suite.Suite, expected_, r.Random(1, r.Expr(0)).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(1), x.Gt(0)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // random.yaml line #31 /* True */ var expected_ bool = true /* r.random(r.expr(1), r.expr(0), float=True).do(lambda x:r.and_(x.le(1), x.gt(0))) */ suite.T().Log("About to run line #31: r.Random(r.Expr(1), r.Expr(0)).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(1), x.Gt(0))})") runAndAssert(suite.Suite, expected_, r.Random(r.Expr(1), r.Expr(0)).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(1), x.Gt(0)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // random.yaml line #36 /* True */ var expected_ bool = true /* r.random(0.495, float=True).do(lambda x:r.and_(x.ge(0), x.lt(0.495))) */ suite.T().Log("About to run line #36: r.Random(0.495).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(0.495))})") runAndAssert(suite.Suite, expected_, r.Random(0.495).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(0.495)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // random.yaml line #37 /* True */ var expected_ bool = true /* r.random(-0.495, float=True).do(lambda x:r.and_(x.le(0), x.gt(-0.495))) */ suite.T().Log("About to run line #37: r.Random(-0.495).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(0), x.Gt(-0.495))})") runAndAssert(suite.Suite, expected_, r.Random(-0.495).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(0), x.Gt(-0.495)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // random.yaml line #38 /* True */ var expected_ bool = true /* r.random(1823756.24, float=True).do(lambda x:r.and_(x.ge(0), x.lt(1823756.24))) */ suite.T().Log("About to run line #38: r.Random(1823756.24).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1823756.24))})") runAndAssert(suite.Suite, expected_, r.Random(1823756.24).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(1823756.24)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #38") } { // random.yaml line #39 /* True */ var expected_ bool = true /* r.random(-1823756.24, float=True).do(lambda x:r.and_(x.le(0), x.gt(-1823756.24))) */ suite.T().Log("About to run line #39: r.Random(-1823756.24).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(0), x.Gt(-1823756.24))})") runAndAssert(suite.Suite, expected_, r.Random(-1823756.24).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(0), x.Gt(-1823756.24)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // random.yaml line #44 /* True */ var expected_ bool = true /* r.random(10.5, 20.153, float=True).do(lambda x:r.and_(x.ge(10.5), x.lt(20.153))) */ suite.T().Log("About to run line #44: r.Random(10.5, 20.153).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(10.5), x.Lt(20.153))})") runAndAssert(suite.Suite, expected_, r.Random(10.5, 20.153).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(10.5), x.Lt(20.153)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // random.yaml line #45 /* True */ var expected_ bool = true /* r.random(20.153, 10.5, float=True).do(lambda x:r.and_(x.le(20.153), x.gt(10.5))) */ suite.T().Log("About to run line #45: r.Random(20.153, 10.5).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(20.153), x.Gt(10.5))})") runAndAssert(suite.Suite, expected_, r.Random(20.153, 10.5).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(20.153), x.Gt(10.5)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #45") } { // random.yaml line #46 /* True */ var expected_ bool = true /* r.random(31415926.1, 31415926, float=True).do(lambda x:r.and_(x.le(31415926.1), x.gt(31415926))) */ suite.T().Log("About to run line #46: r.Random(31415926.1, 31415926).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(31415926.1), x.Gt(31415926))})") runAndAssert(suite.Suite, expected_, r.Random(31415926.1, 31415926).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(31415926.1), x.Gt(31415926)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // random.yaml line #51 /* True */ var expected_ bool = true /* r.random(-10.5, 20.153, float=True).do(lambda x:r.and_(x.ge(-10.5), x.lt(20.153))) */ suite.T().Log("About to run line #51: r.Random(-10.5, 20.153).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(-10.5), x.Lt(20.153))})") runAndAssert(suite.Suite, expected_, r.Random(-10.5, 20.153).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(-10.5), x.Lt(20.153)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // random.yaml line #52 /* True */ var expected_ bool = true /* r.random(-20.153, -10.5, float=True).do(lambda x:r.and_(x.ge(-20.153), x.lt(-10.5))) */ suite.T().Log("About to run line #52: r.Random(-20.153, -10.5).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(-20.153), x.Lt(-10.5))})") runAndAssert(suite.Suite, expected_, r.Random(-20.153, -10.5).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(-20.153), x.Lt(-10.5)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // random.yaml line #53 /* True */ var expected_ bool = true /* r.random(-31415926, -31415926.1, float=True).do(lambda x:r.and_(x.le(-31415926), x.gt(-31415926.1))) */ suite.T().Log("About to run line #53: r.Random(-31415926, -31415926.1).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(-31415926), x.Gt(-31415926.1))})") runAndAssert(suite.Suite, expected_, r.Random(-31415926, -31415926.1).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(-31415926), x.Gt(-31415926.1)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // random.yaml line #58 /* 2 */ var expected_ int = 2 /* r.expr([r.random(), r.random()]).distinct().count() */ suite.T().Log("About to run line #58: r.Expr([]interface{}{r.Random(), r.Random()}).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Random(), r.Random()}).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // random.yaml line #59 /* 2 */ var expected_ int = 2 /* r.expr([r.random(1, float=True), r.random(1, float=True)]).distinct().count() */ suite.T().Log("About to run line #59: r.Expr([]interface{}{r.Random(1).OptArgs(r.RandomOpts{Float: true, }), r.Random(1).OptArgs(r.RandomOpts{Float: true, })}).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Random(1).OptArgs(r.RandomOpts{Float: true}), r.Random(1).OptArgs(r.RandomOpts{Float: true})}).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #59") } { // random.yaml line #60 /* 2 */ var expected_ int = 2 /* r.expr([r.random(0, 1, float=True), r.random(0, 1, float=True)]).distinct().count() */ suite.T().Log("About to run line #60: r.Expr([]interface{}{r.Random(0, 1).OptArgs(r.RandomOpts{Float: true, }), r.Random(0, 1).OptArgs(r.RandomOpts{Float: true, })}).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Random(0, 1).OptArgs(r.RandomOpts{Float: true}), r.Random(0, 1).OptArgs(r.RandomOpts{Float: true})}).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // random.yaml line #65 /* True */ var expected_ bool = true /* r.random(0, float=True).eq(0) */ suite.T().Log("About to run line #65: r.Random(0).OptArgs(r.RandomOpts{Float: true, }).Eq(0)") runAndAssert(suite.Suite, expected_, r.Random(0).OptArgs(r.RandomOpts{Float: true}).Eq(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #65") } { // random.yaml line #66 /* True */ var expected_ bool = true /* r.random(5, 5, float=True).eq(5) */ suite.T().Log("About to run line #66: r.Random(5, 5).OptArgs(r.RandomOpts{Float: true, }).Eq(5)") runAndAssert(suite.Suite, expected_, r.Random(5, 5).OptArgs(r.RandomOpts{Float: true}).Eq(5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } { // random.yaml line #67 /* True */ var expected_ bool = true /* r.random(-499384756758, -499384756758, float=True).eq(-499384756758) */ suite.T().Log("About to run line #67: r.Random(-499384756758, -499384756758).OptArgs(r.RandomOpts{Float: true, }).Eq(-499384756758)") runAndAssert(suite.Suite, expected_, r.Random(-499384756758, -499384756758).OptArgs(r.RandomOpts{Float: true}).Eq(-499384756758), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #67") } { // random.yaml line #68 /* True */ var expected_ bool = true /* r.random(-93.94757, -93.94757, float=True).eq(-93.94757) */ suite.T().Log("About to run line #68: r.Random(-93.94757, -93.94757).OptArgs(r.RandomOpts{Float: true, }).Eq(-93.94757)") runAndAssert(suite.Suite, expected_, r.Random(-93.94757, -93.94757).OptArgs(r.RandomOpts{Float: true}).Eq(-93.94757), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #68") } { // random.yaml line #69 /* True */ var expected_ bool = true /* r.random(294.69148, 294.69148, float=True).eq(294.69148) */ suite.T().Log("About to run line #69: r.Random(294.69148, 294.69148).OptArgs(r.RandomOpts{Float: true, }).Eq(294.69148)") runAndAssert(suite.Suite, expected_, r.Random(294.69148, 294.69148).OptArgs(r.RandomOpts{Float: true}).Eq(294.69148), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #69") } // random.yaml line #74 // float_max = sys.float_info.max suite.T().Log("Possibly executing: var float_max float64 = sys.FloatInfo.Max") float_max := sys.FloatInfo.Max _ = float_max // Prevent any noused variable errors // random.yaml line #78 // float_min = sys.float_info.min suite.T().Log("Possibly executing: var float_min float64 = sys.FloatInfo.Min") float_min := sys.FloatInfo.Min _ = float_min // Prevent any noused variable errors { // random.yaml line #82 /* True */ var expected_ bool = true /* r.random(-float_max, float_max, float=True).do(lambda x:r.and_(x.ge(-float_max), x.lt(float_max))) */ suite.T().Log("About to run line #82: r.Random(-float_max, float_max).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(-float_max), x.Lt(float_max))})") runAndAssert(suite.Suite, expected_, r.Random(-float_max, float_max).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(-float_max), x.Lt(float_max)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // random.yaml line #83 /* True */ var expected_ bool = true /* r.random(float_max, -float_max, float=True).do(lambda x:r.and_(x.le(float_max), x.gt(-float_max))) */ suite.T().Log("About to run line #83: r.Random(float_max, -float_max).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(float_max), x.Gt(-float_max))})") runAndAssert(suite.Suite, expected_, r.Random(float_max, -float_max).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(float_max), x.Gt(-float_max)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // random.yaml line #84 /* True */ var expected_ bool = true /* r.random(float_min, float_max, float=True).do(lambda x:r.and_(x.ge(float_min), x.lt(float_max))) */ suite.T().Log("About to run line #84: r.Random(float_min, float_max).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(float_min), x.Lt(float_max))})") runAndAssert(suite.Suite, expected_, r.Random(float_min, float_max).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(float_min), x.Lt(float_max)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #84") } { // random.yaml line #85 /* True */ var expected_ bool = true /* r.random(float_min, -float_max, float=True).do(lambda x:r.and_(x.le(float_min), x.gt(-float_max))) */ suite.T().Log("About to run line #85: r.Random(float_min, -float_max).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(float_min), x.Gt(-float_max))})") runAndAssert(suite.Suite, expected_, r.Random(float_min, -float_max).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(float_min), x.Gt(-float_max)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #85") } { // random.yaml line #86 /* True */ var expected_ bool = true /* r.random(-float_min, float_max, float=True).do(lambda x:r.and_(x.ge(-float_min), x.lt(float_max))) */ suite.T().Log("About to run line #86: r.Random(-float_min, float_max).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Ge(-float_min), x.Lt(float_max))})") runAndAssert(suite.Suite, expected_, r.Random(-float_min, float_max).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Ge(-float_min), x.Lt(float_max)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // random.yaml line #87 /* True */ var expected_ bool = true /* r.random(-float_min, -float_max, float=True).do(lambda x:r.and_(x.le(-float_min), x.gt(-float_max))) */ suite.T().Log("About to run line #87: r.Random(-float_min, -float_max).OptArgs(r.RandomOpts{Float: true, }).Do(func(x r.Term) interface{} { return r.And(x.Le(-float_min), x.Gt(-float_max))})") runAndAssert(suite.Suite, expected_, r.Random(-float_min, -float_max).OptArgs(r.RandomOpts{Float: true}).Do(func(x r.Term) interface{} { return r.And(x.Le(-float_min), x.Gt(-float_max)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } // random.yaml line #92 // upper_limit = 2**53 - 1 suite.T().Log("Possibly executing: var upper_limit int = 2<<52 - 1") upper_limit := 2<<52 - 1 _ = upper_limit // Prevent any noused variable errors // random.yaml line #96 // lower_limit = 1 - (2**53) suite.T().Log("Possibly executing: var lower_limit int = 1 - 2<<52") lower_limit := 1 - 2<<52 _ = lower_limit // Prevent any noused variable errors { // random.yaml line #101 /* True */ var expected_ bool = true /* r.random(256).do(lambda x:r.and_(x.ge(0), x.lt(256))) */ suite.T().Log("About to run line #101: r.Random(256).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256))})") runAndAssert(suite.Suite, expected_, r.Random(256).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } { // random.yaml line #102 /* True */ var expected_ bool = true /* r.random(0, 256).do(lambda x:r.and_(x.ge(0), x.lt(256))) */ suite.T().Log("About to run line #102: r.Random(0, 256).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256))})") runAndAssert(suite.Suite, expected_, r.Random(0, 256).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } { // random.yaml line #103 /* True */ var expected_ bool = true /* r.random(r.expr(256)).do(lambda x:r.and_(x.ge(0), x.lt(256))) */ suite.T().Log("About to run line #103: r.Random(r.Expr(256)).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256))})") runAndAssert(suite.Suite, expected_, r.Random(r.Expr(256)).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // random.yaml line #104 /* True */ var expected_ bool = true /* r.random(r.expr(0), 256).do(lambda x:r.and_(x.ge(0), x.lt(256))) */ suite.T().Log("About to run line #104: r.Random(r.Expr(0), 256).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256))})") runAndAssert(suite.Suite, expected_, r.Random(r.Expr(0), 256).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #104") } { // random.yaml line #105 /* True */ var expected_ bool = true /* r.random(0, r.expr(256)).do(lambda x:r.and_(x.ge(0), x.lt(256))) */ suite.T().Log("About to run line #105: r.Random(0, r.Expr(256)).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256))})") runAndAssert(suite.Suite, expected_, r.Random(0, r.Expr(256)).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #105") } { // random.yaml line #106 /* True */ var expected_ bool = true /* r.random(r.expr(0), r.expr(256)).do(lambda x:r.and_(x.ge(0), x.lt(256))) */ suite.T().Log("About to run line #106: r.Random(r.Expr(0), r.Expr(256)).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256))})") runAndAssert(suite.Suite, expected_, r.Random(r.Expr(0), r.Expr(256)).Do(func(x r.Term) interface{} { return r.And(x.Ge(0), x.Lt(256)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #106") } { // random.yaml line #111 /* True */ var expected_ bool = true /* r.random(10, 20).do(lambda x:r.and_(x.ge(10), x.lt(20))) */ suite.T().Log("About to run line #111: r.Random(10, 20).Do(func(x r.Term) interface{} { return r.And(x.Ge(10), x.Lt(20))})") runAndAssert(suite.Suite, expected_, r.Random(10, 20).Do(func(x r.Term) interface{} { return r.And(x.Ge(10), x.Lt(20)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // random.yaml line #112 /* True */ var expected_ bool = true /* r.random(9347849, 120937493).do(lambda x:r.and_(x.ge(9347849), x.lt(120937493))) */ suite.T().Log("About to run line #112: r.Random(9347849, 120937493).Do(func(x r.Term) interface{} { return r.And(x.Ge(9347849), x.Lt(120937493))})") runAndAssert(suite.Suite, expected_, r.Random(9347849, 120937493).Do(func(x r.Term) interface{} { return r.And(x.Ge(9347849), x.Lt(120937493)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #112") } { // random.yaml line #123 /* True */ var expected_ bool = true /* r.random(-10, 20).do(lambda x:r.and_(x.ge(-10), x.lt(20))) */ suite.T().Log("About to run line #123: r.Random(-10, 20).Do(func(x r.Term) interface{} { return r.And(x.Ge(-10), x.Lt(20))})") runAndAssert(suite.Suite, expected_, r.Random(-10, 20).Do(func(x r.Term) interface{} { return r.And(x.Ge(-10), x.Lt(20)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #123") } { // random.yaml line #124 /* True */ var expected_ bool = true /* r.random(-20, -10).do(lambda x:r.and_(x.ge(-20), x.lt(-10))) */ suite.T().Log("About to run line #124: r.Random(-20, -10).Do(func(x r.Term) interface{} { return r.And(x.Ge(-20), x.Lt(-10))})") runAndAssert(suite.Suite, expected_, r.Random(-20, -10).Do(func(x r.Term) interface{} { return r.And(x.Ge(-20), x.Lt(-10)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #124") } { // random.yaml line #125 /* True */ var expected_ bool = true /* r.random(-120937493, -9347849).do(lambda x:r.and_(x.ge(-120937493), x.lt(-9347849))) */ suite.T().Log("About to run line #125: r.Random(-120937493, -9347849).Do(func(x r.Term) interface{} { return r.And(x.Ge(-120937493), x.Lt(-9347849))})") runAndAssert(suite.Suite, expected_, r.Random(-120937493, -9347849).Do(func(x r.Term) interface{} { return r.And(x.Ge(-120937493), x.Lt(-9347849)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // random.yaml line #137 /* 2 */ var expected_ int = 2 /* r.expr([r.random(upper_limit), r.random(upper_limit)]).distinct().count() */ suite.T().Log("About to run line #137: r.Expr([]interface{}{r.Random(upper_limit), r.Random(upper_limit)}).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{r.Random(upper_limit), r.Random(upper_limit)}).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #137") } { // random.yaml line #139 /* 2 */ var expected_ int = 2 /* r.expr([upper_limit,upper_limit]).map(lambda x:r.random(x)).distinct().count() */ suite.T().Log("About to run line #139: r.Expr([]interface{}{upper_limit, upper_limit}).Map(func(x r.Term) interface{} { return r.Random(x)}).Distinct().Count()") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{upper_limit, upper_limit}).Map(func(x r.Term) interface{} { return r.Random(x) }).Distinct().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #139") } { // random.yaml line #147 /* err("ReqlQueryLogicError", "Upper bound (-0.5) could not be safely converted to an integer.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Upper bound (-0.5) could not be safely converted to an integer.") /* r.random(-0.5) */ suite.T().Log("About to run line #147: r.Random(-0.5)") runAndAssert(suite.Suite, expected_, r.Random(-0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #147") } { // random.yaml line #149 /* err("ReqlQueryLogicError", "Upper bound (0.25) could not be safely converted to an integer.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Upper bound (0.25) could not be safely converted to an integer.") /* r.random(0.25) */ suite.T().Log("About to run line #149: r.Random(0.25)") runAndAssert(suite.Suite, expected_, r.Random(0.25), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #149") } { // random.yaml line #151 /* err("ReqlQueryLogicError", "Upper bound (0.75) could not be safely converted to an integer.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Upper bound (0.75) could not be safely converted to an integer.") /* r.random(-10, 0.75) */ suite.T().Log("About to run line #151: r.Random(-10, 0.75)") runAndAssert(suite.Suite, expected_, r.Random(-10, 0.75), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #151") } { // random.yaml line #153 /* err("ReqlQueryLogicError", "Lower bound (-120549.25) could not be safely converted to an integer.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (-120549.25) could not be safely converted to an integer.") /* r.random(-120549.25, 39458) */ suite.T().Log("About to run line #153: r.Random(-120549.25, 39458)") runAndAssert(suite.Suite, expected_, r.Random(-120549.25, 39458), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #153") } { // random.yaml line #155 /* err("ReqlQueryLogicError", "Lower bound (-6.5) could not be safely converted to an integer.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (-6.5) could not be safely converted to an integer.") /* r.random(-6.5, 8.125) */ suite.T().Log("About to run line #155: r.Random(-6.5, 8.125)") runAndAssert(suite.Suite, expected_, r.Random(-6.5, 8.125), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #155") } { // random.yaml line #159 /* err("ReqlQueryLogicError", "Generating a random integer requires one or two bounds.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Generating a random integer requires one or two bounds.") /* r.random(float=False) */ suite.T().Log("About to run line #159: r.Random().OptArgs(r.RandomOpts{Float: false, })") runAndAssert(suite.Suite, expected_, r.Random().OptArgs(r.RandomOpts{Float: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // random.yaml line #165 /* err("ReqlQueryLogicError", "Lower bound (0) is not less than upper bound (0).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (0) is not less than upper bound (0).") /* r.random(0) */ suite.T().Log("About to run line #165: r.Random(0)") runAndAssert(suite.Suite, expected_, r.Random(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #165") } { // random.yaml line #167 /* err("ReqlQueryLogicError", "Lower bound (0) is not less than upper bound (0).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (0) is not less than upper bound (0).") /* r.random(0, 0) */ suite.T().Log("About to run line #167: r.Random(0, 0)") runAndAssert(suite.Suite, expected_, r.Random(0, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #167") } { // random.yaml line #169 /* err("ReqlQueryLogicError", "Lower bound (515) is not less than upper bound (515).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (515) is not less than upper bound (515).") /* r.random(515, 515) */ suite.T().Log("About to run line #169: r.Random(515, 515)") runAndAssert(suite.Suite, expected_, r.Random(515, 515), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #169") } { // random.yaml line #171 /* err("ReqlQueryLogicError", "Lower bound (-956) is not less than upper bound (-956).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (-956) is not less than upper bound (-956).") /* r.random(-956, -956) */ suite.T().Log("About to run line #171: r.Random(-956, -956)") runAndAssert(suite.Suite, expected_, r.Random(-956, -956), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #171") } { // random.yaml line #173 /* err("ReqlQueryLogicError", "Lower bound (0) is not less than upper bound (-10).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (0) is not less than upper bound (-10).") /* r.random(-10) */ suite.T().Log("About to run line #173: r.Random(-10)") runAndAssert(suite.Suite, expected_, r.Random(-10), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #173") } { // random.yaml line #175 /* err("ReqlQueryLogicError", "Lower bound (20) is not less than upper bound (2).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (20) is not less than upper bound (2).") /* r.random(20, 2) */ suite.T().Log("About to run line #175: r.Random(20, 2)") runAndAssert(suite.Suite, expected_, r.Random(20, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #175") } { // random.yaml line #177 /* err("ReqlQueryLogicError", "Lower bound (2) is not less than upper bound (-20).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (2) is not less than upper bound (-20).") /* r.random(2, -20) */ suite.T().Log("About to run line #177: r.Random(2, -20)") runAndAssert(suite.Suite, expected_, r.Random(2, -20), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #177") } { // random.yaml line #179 /* err("ReqlQueryLogicError", "Lower bound (1456) is not less than upper bound (0).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Lower bound (1456) is not less than upper bound (0).") /* r.random(1456, 0) */ suite.T().Log("About to run line #179: r.Random(1456, 0)") runAndAssert(suite.Suite, expected_, r.Random(1456, 0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #179") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_range_test.go000066400000000000000000000207051363464422500261430ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests RQL range generation func TestRangeSuite(t *testing.T) { suite.Run(t, new(RangeSuite)) } type RangeSuite struct { suite.Suite session *r.Session } func (suite *RangeSuite) SetupTest() { suite.T().Log("Setting up RangeSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_range").Exec(suite.session) err = r.DBCreate("db_range").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_range").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *RangeSuite) TearDownSuite() { suite.T().Log("Tearing down RangeSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_range").Exec(suite.session) suite.session.Close() } } func (suite *RangeSuite) TestCases() { suite.T().Log("Running RangeSuite: Tests RQL range generation") { // range.yaml line #3 /* 'STREAM' */ var expected_ string = "STREAM" /* r.range().type_of() */ suite.T().Log("About to run line #3: r.Range().TypeOf()") runAndAssert(suite.Suite, expected_, r.Range().TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #3") } { // range.yaml line #6 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* r.range().limit(4) */ suite.T().Log("About to run line #6: r.Range().Limit(4)") runAndAssert(suite.Suite, expected_, r.Range().Limit(4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // range.yaml line #9 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* r.range(4) */ suite.T().Log("About to run line #9: r.Range(4)") runAndAssert(suite.Suite, expected_, r.Range(4), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // range.yaml line #12 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* r.range(2, 5) */ suite.T().Log("About to run line #12: r.Range(2, 5)") runAndAssert(suite.Suite, expected_, r.Range(2, 5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // range.yaml line #15 /* [] */ var expected_ []interface{} = []interface{}{} /* r.range(0) */ suite.T().Log("About to run line #15: r.Range(0)") runAndAssert(suite.Suite, expected_, r.Range(0), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #15") } { // range.yaml line #18 /* [] */ var expected_ []interface{} = []interface{}{} /* r.range(5, 2) */ suite.T().Log("About to run line #18: r.Range(5, 2)") runAndAssert(suite.Suite, expected_, r.Range(5, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // range.yaml line #21 /* [-5, -4, -3] */ var expected_ []interface{} = []interface{}{-5, -4, -3} /* r.range(-5, -2) */ suite.T().Log("About to run line #21: r.Range(-5, -2)") runAndAssert(suite.Suite, expected_, r.Range(-5, -2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // range.yaml line #24 /* [-5, -4, -3, -2, -1, 0, 1] */ var expected_ []interface{} = []interface{}{-5, -4, -3, -2, -1, 0, 1} /* r.range(-5, 2) */ suite.T().Log("About to run line #24: r.Range(-5, 2)") runAndAssert(suite.Suite, expected_, r.Range(-5, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #24") } { // range.yaml line #30 /* err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type NUMBER but found STRING.") /* r.range("foo") */ suite.T().Log("About to run line #30: r.Range('foo')") runAndAssert(suite.Suite, expected_, r.Range("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #30") } { // range.yaml line #34 /* err_regex("ReqlQueryLogicError", "Number not an integer \\(>2\\^53\\). 9007199254740994", []) */ var expected_ Err = err_regex("ReqlQueryLogicError", "Number not an integer \\(>2\\^53\\). 9007199254740994") /* r.range(9007199254740994) */ suite.T().Log("About to run line #34: r.Range(9007199254740994)") runAndAssert(suite.Suite, expected_, r.Range(9007199254740994), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // range.yaml line #37 /* err_regex("ReqlQueryLogicError", "Number not an integer \\(<-2\\^53\\). -9007199254740994", []) */ var expected_ Err = err_regex("ReqlQueryLogicError", "Number not an integer \\(<-2\\^53\\). -9007199254740994") /* r.range(-9007199254740994) */ suite.T().Log("About to run line #37: r.Range(-9007199254740994)") runAndAssert(suite.Suite, expected_, r.Range(-9007199254740994), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // range.yaml line #40 /* err_regex("ReqlQueryLogicError", "Number not an integer. 0\\.5", []) */ var expected_ Err = err_regex("ReqlQueryLogicError", "Number not an integer. 0\\.5") /* r.range(0.5) */ suite.T().Log("About to run line #40: r.Range(0.5)") runAndAssert(suite.Suite, expected_, r.Range(0.5), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // range.yaml line #43 /* err("ReqlQueryLogicError", "Cannot use an infinite stream with an aggregation function (`reduce`, `count`, etc.) or coerce it to an array.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use an infinite stream with an aggregation function (`reduce`, `count`, etc.) or coerce it to an array.") /* r.range().count() */ suite.T().Log("About to run line #43: r.Range().Count()") runAndAssert(suite.Suite, expected_, r.Range().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // range.yaml line #46 /* err("ReqlQueryLogicError", "Cannot use an infinite stream with an aggregation function (`reduce`, `count`, etc.) or coerce it to an array.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use an infinite stream with an aggregation function (`reduce`, `count`, etc.) or coerce it to an array.") /* r.range().coerce_to("ARRAY") */ suite.T().Log("About to run line #46: r.Range().CoerceTo('ARRAY')") runAndAssert(suite.Suite, expected_, r.Range().CoerceTo("ARRAY"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // range.yaml line #49 /* err("ReqlQueryLogicError", "Cannot use an infinite stream with an aggregation function (`reduce`, `count`, etc.) or coerce it to an array.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use an infinite stream with an aggregation function (`reduce`, `count`, etc.) or coerce it to an array.") /* r.range().coerce_to("OBJECT") */ suite.T().Log("About to run line #49: r.Range().CoerceTo('OBJECT')") runAndAssert(suite.Suite, expected_, r.Range().CoerceTo("OBJECT"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // range.yaml line #52 /* 4 */ var expected_ int = 4 /* r.range(4).count() */ suite.T().Log("About to run line #52: r.Range(4).Count()") runAndAssert(suite.Suite, expected_, r.Range(4).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_selection_test.go000066400000000000000000001325201363464422500270330ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests that manipulation data in tables func TestSelectionSuite(t *testing.T) { suite.Run(t, new(SelectionSuite)) } type SelectionSuite struct { suite.Suite session *r.Session } func (suite *SelectionSuite) SetupTest() { suite.T().Log("Setting up SelectionSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_sele").Exec(suite.session) err = r.DBCreate("db_sele").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sele").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_sele").TableDrop("table_test_selection").Exec(suite.session) err = r.DB("db_sele").TableCreate("table_test_selection").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sele").Table("table_test_selection").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_sele").TableDrop("table_test_selection2").Exec(suite.session) err = r.DB("db_sele").TableCreate("table_test_selection2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sele").Table("table_test_selection2").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_sele").TableDrop("table_test_selection3").Exec(suite.session) err = r.DB("db_sele").TableCreate("table_test_selection3").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sele").Table("table_test_selection3").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *SelectionSuite) TearDownSuite() { suite.T().Log("Tearing down SelectionSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_sele").TableDrop("table_test_selection").Exec(suite.session) r.DB("db_sele").TableDrop("table_test_selection2").Exec(suite.session) r.DB("db_sele").TableDrop("table_test_selection3").Exec(suite.session) r.DBDrop("db_sele").Exec(suite.session) suite.session.Close() } } func (suite *SelectionSuite) TestCases() { suite.T().Log("Running SelectionSuite: Tests that manipulation data in tables") table_test_selection := r.DB("db_sele").Table("table_test_selection") _ = table_test_selection // Prevent any noused variable errors table_test_selection2 := r.DB("db_sele").Table("table_test_selection2") _ = table_test_selection2 // Prevent any noused variable errors table_test_selection3 := r.DB("db_sele").Table("table_test_selection3") _ = table_test_selection3 // Prevent any noused variable errors { // selection.yaml line #6 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* table_test_selection.insert([{'id':i, 'a':i%4} for i in xrange(100)]) */ suite.T().Log("About to run line #6: table_test_selection.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, 'a': r.Mod(i, 4), })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_selection.Insert(func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i, "a": r.Mod(i, 4)}) } return res }()), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // selection.yaml line #18 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':100}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 100} /* table_test_selection2.insert([{'id':i, 'b':i%4} for i in xrange(100)]) */ suite.T().Log("About to run line #18: table_test_selection2.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, 'b': r.Mod(i, 4), })\n }\n return res\n}()))") runAndAssert(suite.Suite, expected_, table_test_selection2.Insert((func() []interface{} { res := []interface{}{} for iterator_ := 0; iterator_ < 100; iterator_++ { i := iterator_ res = append(res, map[interface{}]interface{}{"id": i, "b": r.Mod(i, 4)}) } return res }())), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // selection.yaml line #31 /* 'TABLE' */ var expected_ string = "TABLE" /* table_test_selection.type_of() */ suite.T().Log("About to run line #31: table_test_selection.TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // selection.yaml line #35 /* err("ReqlOpFailedError", 'Database `missing` does not exist.', [0]) */ var expected_ Err = err("ReqlOpFailedError", "Database `missing` does not exist.") /* r.db('missing').table('bar') */ suite.T().Log("About to run line #35: r.DB('missing').Table('bar')") runAndAssert(suite.Suite, expected_, r.DB("missing").Table("bar"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #35") } { // selection.yaml line #39 /* err("ReqlOpFailedError", 'Table `test.missing` does not exist.', [0]) */ var expected_ Err = err("ReqlOpFailedError", "Table `db_sele.missing` does not exist.") /* r.db('test').table('missing') */ suite.T().Log("About to run line #39: r.DB('test').Table('missing')") runAndAssert(suite.Suite, expected_, r.DB("db_sele").Table("missing"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #39") } { // selection.yaml line #43 /* ({"errors":1,"inserted":0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"errors": 1, "inserted": 0} /* table_test_selection.insert({"id":"\x00"}).pluck("errors","inserted") */ suite.T().Log("About to run line #43: table_test_selection.Insert(map[interface{}]interface{}{'id': '\\u0000', }).Pluck('errors', 'inserted')") runAndAssert(suite.Suite, expected_, table_test_selection.Insert(map[interface{}]interface{}{"id": "\u0000"}).Pluck("errors", "inserted"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // selection.yaml line #46 /* ({"errors":1,"inserted":0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"errors": 1, "inserted": 0} /* table_test_selection.insert({"id":["embedded",["null\x00"]]}).pluck("errors","inserted") */ suite.T().Log("About to run line #46: table_test_selection.Insert(map[interface{}]interface{}{'id': []interface{}{'embedded', []interface{}{'null\\u0000'}}, }).Pluck('errors', 'inserted')") runAndAssert(suite.Suite, expected_, table_test_selection.Insert(map[interface{}]interface{}{"id": []interface{}{"embedded", []interface{}{"null\u0000"}}}).Pluck("errors", "inserted"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #46") } { // selection.yaml line #51 /* ({'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 1} /* table_test_selection3.insert({'id':u'Здравствуй','value':u'Земля!'}) */ suite.T().Log("About to run line #51: table_test_selection3.Insert(map[interface{}]interface{}{'id': 'Здравствуй', 'value': 'Земля!', })") runAndAssert(suite.Suite, expected_, table_test_selection3.Insert(map[interface{}]interface{}{"id": "Здравствуй", "value": "Земля!"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #51") } { // selection.yaml line #60 /* {u'id':u'Здравствуй',u'value':u'Земля!'} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": "Здравствуй", "value": "Земля!"} /* table_test_selection3.get('Здравствуй') */ suite.T().Log("About to run line #60: table_test_selection3.Get('Здравствуй')") runAndAssert(suite.Suite, expected_, table_test_selection3.Get("Здравствуй"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // selection.yaml line #73 /* [{u'id':u'Здравствуй',u'value':u'Земля!'}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": "Здравствуй", "value": "Земля!"}} /* table_test_selection3.filter({'value':'Земля!'}) */ suite.T().Log("About to run line #73: table_test_selection3.Filter(map[interface{}]interface{}{'value': 'Земля!', })") runAndAssert(suite.Suite, expected_, table_test_selection3.Filter(map[interface{}]interface{}{"value": "Земля!"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #73") } { // selection.yaml line #86 /* err("ReqlQueryLogicError", 'Database name `%` invalid (Use A-Za-z0-9_ only).', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Database name `%` invalid (Use A-Z, a-z, 0-9, _ and - only).") /* r.db('%') */ suite.T().Log("About to run line #86: r.DB('%')") runAndAssert(suite.Suite, expected_, r.DB("%"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #86") } { // selection.yaml line #89 /* err("ReqlQueryLogicError", 'Table name `%` invalid (Use A-Za-z0-9_ only).', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Table name `%` invalid (Use A-Z, a-z, 0-9, _ and - only).") /* r.db('test').table('%') */ suite.T().Log("About to run line #89: r.DB('test').Table('%')") runAndAssert(suite.Suite, expected_, r.DB("db_sele").Table("%"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #89") } { // selection.yaml line #93 /* 100 */ var expected_ int = 100 /* table_test_selection.count() */ suite.T().Log("About to run line #93: table_test_selection.Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } // selection.yaml line #97 // table_test_selection2Name = table_test_selection2.info().get_field('name') suite.T().Log("Possibly executing: var table_test_selection2Name r.Term = table_test_selection2.Info().Field('name')") table_test_selection2Name := table_test_selection2.Info().Field("name") _ = table_test_selection2Name // Prevent any noused variable errors // selection.yaml line #98 // table_test_selection2DbName = table_test_selection2.info().get_field('db').get_field('name') suite.T().Log("Possibly executing: var table_test_selection2DbName r.Term = table_test_selection2.Info().Field('db').Field('name')") table_test_selection2DbName := table_test_selection2.Info().Field("db").Field("name") _ = table_test_selection2DbName // Prevent any noused variable errors { // selection.yaml line #101 /* 100 */ var expected_ int = 100 /* r.db(table_test_selection2DbName).table(table_test_selection2Name, read_mode='outdated').count() */ suite.T().Log("About to run line #101: r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: 'outdated', }).Count()") runAndAssert(suite.Suite, expected_, r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: "outdated"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } { // selection.yaml line #102 /* 100 */ var expected_ int = 100 /* r.db(table_test_selection2DbName).table(table_test_selection2Name, read_mode='single').count() */ suite.T().Log("About to run line #102: r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: 'single', }).Count()") runAndAssert(suite.Suite, expected_, r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: "single"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #102") } { // selection.yaml line #103 /* 100 */ var expected_ int = 100 /* r.db(table_test_selection2DbName).table(table_test_selection2Name, read_mode='majority').count() */ suite.T().Log("About to run line #103: r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: 'majority', }).Count()") runAndAssert(suite.Suite, expected_, r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: "majority"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // selection.yaml line #120 /* err("ReqlQueryLogicError", 'Expected type STRING but found BOOL.') */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found BOOL.") /* r.db(table_test_selection2DbName).table(table_test_selection2Name, read_mode=true).count() */ suite.T().Log("About to run line #120: r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: true, }).Count()") runAndAssert(suite.Suite, expected_, r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: true}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #120") } { // selection.yaml line #125 /* err("ReqlQueryLogicError", 'Read mode `fake` unrecognized (options are "majority", "single", and "outdated").') */ var expected_ Err = err("ReqlQueryLogicError", "Read mode `fake` unrecognized (options are \"majority\", \"single\", and \"outdated\").") /* r.db(table_test_selection2DbName).table(table_test_selection2Name, read_mode='fake').count() */ suite.T().Log("About to run line #125: r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: 'fake', }).Count()") runAndAssert(suite.Suite, expected_, r.DB(table_test_selection2DbName).Table(table_test_selection2Name).OptArgs(r.TableOpts{ReadMode: "fake"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // selection.yaml line #130 /* 2 */ var expected_ int = 2 /* table_test_selection.get(20).count() */ suite.T().Log("About to run line #130: table_test_selection.Get(20).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Get(20).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #130") } { // selection.yaml line #134 /* {'id':20,'a':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 20, "a": 0} /* table_test_selection.get(20) */ suite.T().Log("About to run line #134: table_test_selection.Get(20)") runAndAssert(suite.Suite, expected_, table_test_selection.Get(20), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #134") } { // selection.yaml line #138 /* null */ var expected_ interface{} = nil /* table_test_selection.get(2000) */ suite.T().Log("About to run line #138: table_test_selection.Get(2000)") runAndAssert(suite.Suite, expected_, table_test_selection.Get(2000), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #138") } // selection.yaml line #153 // table_test_selectionpkey = r.db('test').table('testpkey_selection') suite.T().Log("Possibly executing: var table_test_selectionpkey r.Term = r.DB('test').Table('testpkey_selection')") table_test_selectionpkey := r.DB("db_sele").Table("testpkey_selection") _ = table_test_selectionpkey // Prevent any noused variable errors { // selection.yaml line #149 /* partial({'tables_created':1}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) /* r.db('test').table_create('testpkey_selection', primary_key='foo') */ suite.T().Log("About to run line #149: r.DB('test').TableCreate('testpkey_selection').OptArgs(r.TableCreateOpts{PrimaryKey: 'foo', })") runAndAssert(suite.Suite, expected_, r.DB("db_sele").TableCreate("testpkey_selection").OptArgs(r.TableCreateOpts{PrimaryKey: "foo"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #149") } { // selection.yaml line #155 /* {'deleted':0.0,'replaced':0.0,'unchanged':0.0,'errors':0.0,'skipped':0.0,'inserted':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0.0, "replaced": 0.0, "unchanged": 0.0, "errors": 0.0, "skipped": 0.0, "inserted": 1} /* table_test_selectionpkey.insert({'foo':10,'a':10}) */ suite.T().Log("About to run line #155: table_test_selectionpkey.Insert(map[interface{}]interface{}{'foo': 10, 'a': 10, })") runAndAssert(suite.Suite, expected_, table_test_selectionpkey.Insert(map[interface{}]interface{}{"foo": 10, "a": 10}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #155") } { // selection.yaml line #159 /* {'foo':10,'a':10} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"foo": 10, "a": 10} /* table_test_selectionpkey.get(10) */ suite.T().Log("About to run line #159: table_test_selectionpkey.Get(10)") runAndAssert(suite.Suite, expected_, table_test_selectionpkey.Get(10), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // selection.yaml line #163 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_selection.get_all() */ suite.T().Log("About to run line #163: table_test_selection.GetAll()") runAndAssert(suite.Suite, expected_, table_test_selection.GetAll(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #163") } { // selection.yaml line #165 /* [{"id":20,"a":0}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 20, "a": 0}} /* table_test_selection.get_all(20) */ suite.T().Log("About to run line #165: table_test_selection.GetAll(20)") runAndAssert(suite.Suite, expected_, table_test_selection.GetAll(20), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #165") } { // selection.yaml line #167 /* "SELECTION" */ var expected_ string = "SELECTION" /* table_test_selection.get_all().type_of() */ suite.T().Log("About to run line #167: table_test_selection.GetAll().TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.GetAll().TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #167") } { // selection.yaml line #169 /* "SELECTION" */ var expected_ string = "SELECTION" /* table_test_selection.get_all(20).type_of() */ suite.T().Log("About to run line #169: table_test_selection.GetAll(20).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.GetAll(20).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #169") } { // selection.yaml line #173 /* 'TABLE_SLICE' */ var expected_ string = "TABLE_SLICE" /* table_test_selection.between(2, 1).type_of() */ suite.T().Log("About to run line #173: table_test_selection.Between(2, 1).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(2, 1).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #173") } { // selection.yaml line #175 /* 'TABLE_SLICE' */ var expected_ string = "TABLE_SLICE" /* table_test_selection.between(1, 2).type_of() */ suite.T().Log("About to run line #175: table_test_selection.Between(1, 2).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(1, 2).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #175") } { // selection.yaml line #177 /* 'TABLE_SLICE' */ var expected_ string = "TABLE_SLICE" /* table_test_selection.between(1, 2, index='id').type_of() */ suite.T().Log("About to run line #177: table_test_selection.Between(1, 2).OptArgs(r.BetweenOpts{Index: 'id', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(1, 2).OptArgs(r.BetweenOpts{Index: "id"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #177") } { // selection.yaml line #181 /* 'TABLE_SLICE' */ var expected_ string = "TABLE_SLICE" /* table_test_selection.between(1, 1, right_bound='closed').type_of() */ suite.T().Log("About to run line #181: table_test_selection.Between(1, 1).OptArgs(r.BetweenOpts{RightBound: 'closed', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(1, 1).OptArgs(r.BetweenOpts{RightBound: "closed"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #181") } { // selection.yaml line #185 /* 'TABLE_SLICE' */ var expected_ string = "TABLE_SLICE" /* table_test_selection.between(2, 1).type_of() */ suite.T().Log("About to run line #185: table_test_selection.Between(2, 1).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(2, 1).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #185") } { // selection.yaml line #187 /* 'TABLE_SLICE' */ var expected_ string = "TABLE_SLICE" /* table_test_selection.between(2, 1, index='id').type_of() */ suite.T().Log("About to run line #187: table_test_selection.Between(2, 1).OptArgs(r.BetweenOpts{Index: 'id', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(2, 1).OptArgs(r.BetweenOpts{Index: "id"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #187") } { // selection.yaml line #192 /* 0 */ var expected_ int = 0 /* table_test_selection.between(21, 20).count() */ suite.T().Log("About to run line #192: table_test_selection.Between(21, 20).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(21, 20).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #192") } { // selection.yaml line #194 /* 9 */ var expected_ int = 9 /* table_test_selection.between(20, 29).count() */ suite.T().Log("About to run line #194: table_test_selection.Between(20, 29).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(20, 29).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #194") } { // selection.yaml line #196 /* 9 */ var expected_ int = 9 /* table_test_selection.between(-10, 9).count() */ suite.T().Log("About to run line #196: table_test_selection.Between(-10, 9).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(-10, 9).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #196") } { // selection.yaml line #198 /* 20 */ var expected_ int = 20 /* table_test_selection.between(80, 2000).count() */ suite.T().Log("About to run line #198: table_test_selection.Between(80, 2000).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(80, 2000).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #198") } { // selection.yaml line #200 /* 100 */ var expected_ int = 100 /* table_test_selection.between(-2000, 2000).count() */ suite.T().Log("About to run line #200: table_test_selection.Between(-2000, 2000).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(-2000, 2000).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #200") } { // selection.yaml line #205 /* 10 */ var expected_ int = 10 /* table_test_selection.between(20, 29, right_bound='closed').count() */ suite.T().Log("About to run line #205: table_test_selection.Between(20, 29).OptArgs(r.BetweenOpts{RightBound: 'closed', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(20, 29).OptArgs(r.BetweenOpts{RightBound: "closed"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #205") } { // selection.yaml line #209 /* 10 */ var expected_ int = 10 /* table_test_selection.between(-10, 9, right_bound='closed').count() */ suite.T().Log("About to run line #209: table_test_selection.Between(-10, 9).OptArgs(r.BetweenOpts{RightBound: 'closed', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(-10, 9).OptArgs(r.BetweenOpts{RightBound: "closed"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #209") } { // selection.yaml line #213 /* 20 */ var expected_ int = 20 /* table_test_selection.between(80, 2000, right_bound='closed').count() */ suite.T().Log("About to run line #213: table_test_selection.Between(80, 2000).OptArgs(r.BetweenOpts{RightBound: 'closed', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(80, 2000).OptArgs(r.BetweenOpts{RightBound: "closed"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #213") } { // selection.yaml line #217 /* 100 */ var expected_ int = 100 /* table_test_selection.between(-2000, 2000, right_bound='closed').count() */ suite.T().Log("About to run line #217: table_test_selection.Between(-2000, 2000).OptArgs(r.BetweenOpts{RightBound: 'closed', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(-2000, 2000).OptArgs(r.BetweenOpts{RightBound: "closed"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #217") } { // selection.yaml line #223 /* 8 */ var expected_ int = 8 /* table_test_selection.between(20, 29, left_bound='open').count() */ suite.T().Log("About to run line #223: table_test_selection.Between(20, 29).OptArgs(r.BetweenOpts{LeftBound: 'open', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(20, 29).OptArgs(r.BetweenOpts{LeftBound: "open"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #223") } { // selection.yaml line #227 /* 9 */ var expected_ int = 9 /* table_test_selection.between(-10, 9, left_bound='open').count() */ suite.T().Log("About to run line #227: table_test_selection.Between(-10, 9).OptArgs(r.BetweenOpts{LeftBound: 'open', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(-10, 9).OptArgs(r.BetweenOpts{LeftBound: "open"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #227") } { // selection.yaml line #231 /* 19 */ var expected_ int = 19 /* table_test_selection.between(80, 2000, left_bound='open').count() */ suite.T().Log("About to run line #231: table_test_selection.Between(80, 2000).OptArgs(r.BetweenOpts{LeftBound: 'open', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(80, 2000).OptArgs(r.BetweenOpts{LeftBound: "open"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #231") } { // selection.yaml line #235 /* 100 */ var expected_ int = 100 /* table_test_selection.between(-2000, 2000, left_bound='open').count() */ suite.T().Log("About to run line #235: table_test_selection.Between(-2000, 2000).OptArgs(r.BetweenOpts{LeftBound: 'open', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(-2000, 2000).OptArgs(r.BetweenOpts{LeftBound: "open"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #235") } { // selection.yaml line #240 /* err('ReqlQueryLogicError', 'Expected type TABLE_SLICE but found DATUM:', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type TABLE_SLICE but found DATUM:") /* r.expr([1, 2, 3]).between(-1, 2) */ suite.T().Log("About to run line #240: r.Expr([]interface{}{1, 2, 3}).Between(-1, 2)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3}).Between(-1, 2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #240") } { // selection.yaml line #244 /* 2 */ var expected_ int = 2 /* table_test_selection.between(r.minval, 2).count() */ suite.T().Log("About to run line #244: table_test_selection.Between(r.MinVal, 2).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(r.MinVal, 2).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #244") } { // selection.yaml line #247 /* 3 */ var expected_ int = 3 /* table_test_selection.between(r.minval, 2, right_bound='closed').count() */ suite.T().Log("About to run line #247: table_test_selection.Between(r.MinVal, 2).OptArgs(r.BetweenOpts{RightBound: 'closed', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(r.MinVal, 2).OptArgs(r.BetweenOpts{RightBound: "closed"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #247") } { // selection.yaml line #251 /* 2 */ var expected_ int = 2 /* table_test_selection.between(r.minval, 2, left_bound='open').count() */ suite.T().Log("About to run line #251: table_test_selection.Between(r.MinVal, 2).OptArgs(r.BetweenOpts{LeftBound: 'open', }).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(r.MinVal, 2).OptArgs(r.BetweenOpts{LeftBound: "open"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #251") } { // selection.yaml line #255 /* 98 */ var expected_ int = 98 /* table_test_selection.between(2, r.maxval).count() */ suite.T().Log("About to run line #255: table_test_selection.Between(2, r.MaxVal).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(2, r.MaxVal).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #255") } { // selection.yaml line #265 /* err('ReqlQueryLogicError', 'Cannot use `nu' + 'll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use `nu"+"ll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.") /* table_test_selection.between(null, 2).count() */ suite.T().Log("About to run line #265: table_test_selection.Between(nil, 2).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(nil, 2).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #265") } { // selection.yaml line #266 /* err('ReqlQueryLogicError', 'Cannot use `nu' + 'll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use `nu"+"ll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.") /* table_test_selection.between(2, null).count() */ suite.T().Log("About to run line #266: table_test_selection.Between(2, nil).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(2, nil).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #266") } { // selection.yaml line #267 /* err('ReqlQueryLogicError', 'Cannot use `nu' + 'll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use `nu"+"ll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.") /* table_test_selection.between(null, null).count() */ suite.T().Log("About to run line #267: table_test_selection.Between(nil, nil).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Between(nil, nil).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #267") } { // selection.yaml line #271 /* 1 */ var expected_ int = 1 /* table_test_selectionpkey.between(9, 11).count() */ suite.T().Log("About to run line #271: table_test_selectionpkey.Between(9, 11).Count()") runAndAssert(suite.Suite, expected_, table_test_selectionpkey.Between(9, 11).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #271") } { // selection.yaml line #274 /* 0 */ var expected_ int = 0 /* table_test_selectionpkey.between(11, 12).count() */ suite.T().Log("About to run line #274: table_test_selectionpkey.Between(11, 12).Count()") runAndAssert(suite.Suite, expected_, table_test_selectionpkey.Between(11, 12).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #274") } { // selection.yaml line #278 /* 25 */ var expected_ int = 25 /* table_test_selection.filter(lambda row:row['a'] > 2).count() */ suite.T().Log("About to run line #278: table_test_selection.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Gt(2)}).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Gt(2) }).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #278") } { // selection.yaml line #284 /* 100 */ var expected_ int = 100 /* table_test_selection.filter(lambda row: 1).count() */ suite.T().Log("About to run line #284: table_test_selection.Filter(func(row r.Term) interface{} { return 1}).Count()") runAndAssert(suite.Suite, expected_, table_test_selection.Filter(func(row r.Term) interface{} { return 1 }).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #284") } { // selection.yaml line #290 /* [4, 5] */ var expected_ []interface{} = []interface{}{4, 5} /* r.expr([1, 2, 3, 4, 5]).filter(r.row > 2).filter(r.row > 3) */ suite.T().Log("About to run line #290: r.Expr([]interface{}{1, 2, 3, 4, 5}).Filter(r.Row.Gt(2)).Filter(r.Row.Gt(3))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 4, 5}).Filter(r.Row.Gt(2)).Filter(r.Row.Gt(3)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #290") } // selection.yaml line #296 // nested = r.expr([[1, 2], [3, 4], [5, 6]]) suite.T().Log("Possibly executing: var nested r.Term = r.Expr([]interface{}{[]interface{}{1, 2}, []interface{}{3, 4}, []interface{}{5, 6}})") nested := r.Expr([]interface{}{[]interface{}{1, 2}, []interface{}{3, 4}, []interface{}{5, 6}}) _ = nested // Prevent any noused variable errors { // selection.yaml line #298 /* [[3, 4], [5, 6]] */ var expected_ []interface{} = []interface{}{[]interface{}{3, 4}, []interface{}{5, 6}} /* nested.filter(lambda x: x.filter(lambda y: y >= 4).count() > 0) */ suite.T().Log("About to run line #298: nested.Filter(func(x r.Term) interface{} { return x.Filter(func(y r.Term) interface{} { return r.Ge(y, 4)}).Count().Gt(0)})") runAndAssert(suite.Suite, expected_, nested.Filter(func(x r.Term) interface{} { return x.Filter(func(y r.Term) interface{} { return r.Ge(y, 4) }).Count().Gt(0) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #298") } { // selection.yaml line #303 /* ([[3, 4], [5, 6]]) */ var expected_ []interface{} = []interface{}{[]interface{}{3, 4}, []interface{}{5, 6}} /* nested.filter(r.row.filter(lambda y: y >= 4).count() > 0) */ suite.T().Log("About to run line #303: nested.Filter(r.Row.Filter(func(y r.Term) interface{} { return r.Ge(y, 4)}).Count().Gt(0))") runAndAssert(suite.Suite, expected_, nested.Filter(r.Row.Filter(func(y r.Term) interface{} { return r.Ge(y, 4) }).Count().Gt(0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #303") } { // selection.yaml line #307 /* err("ReqlCompileError", 'Cannot use r.row in nested queries. Use functions instead.', [0]) */ var expected_ Err = err("ReqlCompileError", "Cannot use r.row in nested queries. Use functions instead.") /* nested.filter(lambda x: x.filter(r.row >= 4).count() > 0) */ suite.T().Log("About to run line #307: nested.Filter(func(x r.Term) interface{} { return x.Filter(r.Row.Ge(4)).Count().Gt(0)})") runAndAssert(suite.Suite, expected_, nested.Filter(func(x r.Term) interface{} { return x.Filter(r.Row.Ge(4)).Count().Gt(0) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #307") } { // selection.yaml line #311 /* err("ReqlCompileError", 'Cannot use r.row in nested queries. Use functions instead.', [0]) */ var expected_ Err = err("ReqlCompileError", "Cannot use r.row in nested queries. Use functions instead.") /* r.expr([[1, 2], [3, 4], [5, 6]]).filter(r.row.filter(r.row >= 4).count() > 0) */ suite.T().Log("About to run line #311: r.Expr([]interface{}{[]interface{}{1, 2}, []interface{}{3, 4}, []interface{}{5, 6}}).Filter(r.Row.Filter(r.Row.Ge(4)).Count().Gt(0))") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{[]interface{}{1, 2}, []interface{}{3, 4}, []interface{}{5, 6}}).Filter(r.Row.Filter(r.Row.Ge(4)).Count().Gt(0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #311") } { // selection.yaml line #316 /* [{'a':1,'b':2,'c':3}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1, "b": 2, "c": 3}} /* r.expr([{'a':1,'b':1,'c':3},{'a':1,'b':2,'c':3}]).filter({'a':1,'b':2}) */ suite.T().Log("About to run line #316: r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, 'b': 1, 'c': 3, }, map[interface{}]interface{}{'a': 1, 'b': 2, 'c': 3, }}).Filter(map[interface{}]interface{}{'a': 1, 'b': 2, })") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{map[interface{}]interface{}{"a": 1, "b": 1, "c": 3}, map[interface{}]interface{}{"a": 1, "b": 2, "c": 3}}).Filter(map[interface{}]interface{}{"a": 1, "b": 2}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #316") } { // selection.yaml line #319 /* [{'a':1,'b':1,'c':3},{'a':1,'b':2,'c':3}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1, "b": 1, "c": 3}, map[interface{}]interface{}{"a": 1, "b": 2, "c": 3}} /* r.expr([{'a':1,'b':1,'c':3},{'a':1,'b':2,'c':3}]).filter({'a':1}) */ suite.T().Log("About to run line #319: r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, 'b': 1, 'c': 3, }, map[interface{}]interface{}{'a': 1, 'b': 2, 'c': 3, }}).Filter(map[interface{}]interface{}{'a': 1, })") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{map[interface{}]interface{}{"a": 1, "b": 1, "c": 3}, map[interface{}]interface{}{"a": 1, "b": 2, "c": 3}}).Filter(map[interface{}]interface{}{"a": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #319") } { // selection.yaml line #323 /* [{'a':1,'b':1,'c':3}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1, "b": 1, "c": 3}} /* r.expr([{'a':1,'b':1,'c':3},{'a':1,'b':2,'c':3}]).filter({'a':r.row['b']}) */ suite.T().Log("About to run line #323: r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, 'b': 1, 'c': 3, }, map[interface{}]interface{}{'a': 1, 'b': 2, 'c': 3, }}).Filter(map[interface{}]interface{}{'a': r.Row.AtIndex('b'), })") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{map[interface{}]interface{}{"a": 1, "b": 1, "c": 3}, map[interface{}]interface{}{"a": 1, "b": 2, "c": 3}}).Filter(map[interface{}]interface{}{"a": r.Row.AtIndex("b")}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #323") } { // selection.yaml line #329 /* [] */ var expected_ []interface{} = []interface{}{} /* r.expr([{'a':1}]).filter({'b':1}) */ suite.T().Log("About to run line #329: r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, }}).Filter(map[interface{}]interface{}{'b': 1, })") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{map[interface{}]interface{}{"a": 1}}).Filter(map[interface{}]interface{}{"b": 1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #329") } { // selection.yaml line #335 /* 25 */ var expected_ int = 25 /* table_test_selection.count(lambda row: {'a':1}) */ suite.T().Log("About to run line #335: table_test_selection.Count(func(row r.Term) interface{} { return map[interface{}]interface{}{'a': 1, }})") runAndAssert(suite.Suite, expected_, table_test_selection.Count(func(row r.Term) interface{} { return map[interface{}]interface{}{"a": 1} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #335") } { // selection.yaml line #341 /* 2 */ var expected_ int = 2 /* r.expr([1,2,3,1]).count(1) */ suite.T().Log("About to run line #341: r.Expr([]interface{}{1, 2, 3, 1}).Count(1)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{1, 2, 3, 1}).Count(1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #341") } { // selection.yaml line #344 /* 2 */ var expected_ int = 2 /* r.expr([null, 4, null, 'foo']).count(null) */ suite.T().Log("About to run line #344: r.Expr([]interface{}{nil, 4, nil, 'foo'}).Count(nil)") runAndAssert(suite.Suite, expected_, r.Expr([]interface{}{nil, 4, nil, "foo"}).Count(nil), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #344") } { // selection.yaml line #348 /* err('ReqlQueryLogicError', 'Expected type DATUM but found TABLE:', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type DATUM but found TABLE:") /* r.expr(5) + table_test_selection */ suite.T().Log("About to run line #348: r.Expr(5).Add(table_test_selection)") runAndAssert(suite.Suite, expected_, r.Expr(5).Add(table_test_selection), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #348") } { // selection.yaml line #353 /* "SELECTION" */ var expected_ string = "SELECTION" /* table_test_selection.has_fields('field').type_of() */ suite.T().Log("About to run line #353: table_test_selection.HasFields('field').TypeOf()") runAndAssert(suite.Suite, expected_, table_test_selection.HasFields("field").TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #353") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_sindex_api_test.go000066400000000000000000007155241363464422500272040ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // sindex api (#602) func TestSindexApiSuite(t *testing.T) { suite.Run(t, new(SindexApiSuite)) } type SindexApiSuite struct { suite.Suite session *r.Session } func (suite *SindexApiSuite) SetupTest() { suite.T().Log("Setting up SindexApiSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_sindex_api").Exec(suite.session) err = r.DBCreate("db_sindex_api").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sindex_api").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_sindex_api").TableDrop("table_test_sindex_api").Exec(suite.session) err = r.DB("db_sindex_api").TableCreate("table_test_sindex_api").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sindex_api").Table("table_test_sindex_api").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *SindexApiSuite) TearDownSuite() { suite.T().Log("Tearing down SindexApiSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_sindex_api").TableDrop("table_test_sindex_api").Exec(suite.session) r.DBDrop("db_sindex_api").Exec(suite.session) suite.session.Close() } } func (suite *SindexApiSuite) TestCases() { suite.T().Log("Running SindexApiSuite: sindex api (#602)") table_test_sindex_api := r.DB("db_sindex_api").Table("table_test_sindex_api") _ = table_test_sindex_api // Prevent any noused variable errors // sindex/api.yaml line #5 // rows = [{'id':0, 'a':0, 'b':0, 'c':0, 'm':[1,2,3]},{'id':1, 'a':0, 'b':0, 'c':0, 'm':[4,5,6]},{'id':2, 'a':0, 'b':0, 'c':1, 'm':7},{'id':3, 'a':0, 'b':1, 'c':1, 'm':[10,11,12]},{'id':4, 'a':4, 'b':4, 'c':4, 'm':[14,15,16]}] suite.T().Log("Possibly executing: var rows []interface{} = []interface{}{map[interface{}]interface{}{'id': 0, 'a': 0, 'b': 0, 'c': 0, 'm': []interface{}{1, 2, 3}, }, map[interface{}]interface{}{'id': 1, 'a': 0, 'b': 0, 'c': 0, 'm': []interface{}{4, 5, 6}, }, map[interface{}]interface{}{'id': 2, 'a': 0, 'b': 0, 'c': 1, 'm': 7, }, map[interface{}]interface{}{'id': 3, 'a': 0, 'b': 1, 'c': 1, 'm': []interface{}{10, 11, 12}, }, map[interface{}]interface{}{'id': 4, 'a': 4, 'b': 4, 'c': 4, 'm': []interface{}{14, 15, 16}, }}") rows := []interface{}{map[interface{}]interface{}{"id": 0, "a": 0, "b": 0, "c": 0, "m": []interface{}{1, 2, 3}}, map[interface{}]interface{}{"id": 1, "a": 0, "b": 0, "c": 0, "m": []interface{}{4, 5, 6}}, map[interface{}]interface{}{"id": 2, "a": 0, "b": 0, "c": 1, "m": 7}, map[interface{}]interface{}{"id": 3, "a": 0, "b": 1, "c": 1, "m": []interface{}{10, 11, 12}}, map[interface{}]interface{}{"id": 4, "a": 4, "b": 4, "c": 4, "m": []interface{}{14, 15, 16}}} _ = rows // Prevent any noused variable errors { // sindex/api.yaml line #11 /* ({'deleted':0,'inserted':4,'skipped':0,'errors':0,'replaced':0,'unchanged':0}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "inserted": 4, "skipped": 0, "errors": 0, "replaced": 0, "unchanged": 0} /* table_test_sindex_api.insert([{'id':0, 'a':0, 'b':0, 'c':0, 'm':[1,2,3]}, {'id':1, 'a':0, 'b':0, 'c':0, 'm':[4,5,6]}, {'id':2, 'a':0, 'b':0, 'c':1, 'm':7}, {'id':3, 'a':0, 'b':1, 'c':1, 'm':[10,11,12]}]) */ suite.T().Log("About to run line #11: table_test_sindex_api.Insert([]interface{}{map[interface{}]interface{}{'id': 0, 'a': 0, 'b': 0, 'c': 0, 'm': []interface{}{1, 2, 3}, }, map[interface{}]interface{}{'id': 1, 'a': 0, 'b': 0, 'c': 0, 'm': []interface{}{4, 5, 6}, }, map[interface{}]interface{}{'id': 2, 'a': 0, 'b': 0, 'c': 1, 'm': 7, }, map[interface{}]interface{}{'id': 3, 'a': 0, 'b': 1, 'c': 1, 'm': []interface{}{10, 11, 12}, }})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Insert([]interface{}{map[interface{}]interface{}{"id": 0, "a": 0, "b": 0, "c": 0, "m": []interface{}{1, 2, 3}}, map[interface{}]interface{}{"id": 1, "a": 0, "b": 0, "c": 0, "m": []interface{}{4, 5, 6}}, map[interface{}]interface{}{"id": 2, "a": 0, "b": 0, "c": 1, "m": 7}, map[interface{}]interface{}{"id": 3, "a": 0, "b": 1, "c": 1, "m": []interface{}{10, 11, 12}}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // sindex/api.yaml line #18 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('rename-foo', r.row['b']) */ suite.T().Log("About to run line #18: table_test_sindex_api.IndexCreateFunc('rename-foo', r.Row.AtIndex('b'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("rename-foo", r.Row.AtIndex("b")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // sindex/api.yaml line #23 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('rename-bar', r.row['c']) */ suite.T().Log("About to run line #23: table_test_sindex_api.IndexCreateFunc('rename-bar', r.Row.AtIndex('c'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("rename-bar", r.Row.AtIndex("c")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // sindex/api.yaml line #28 /* err_regex('ReqlOpFailedError','Index `rename-foo` does not exist or index `rename-bar` already exists on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]',[]) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `rename-foo` does not exist or index `rename-bar` already exists on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_sindex_api.index_rename('rename-foo','rename-bar') */ suite.T().Log("About to run line #28: table_test_sindex_api.IndexRename('rename-foo', 'rename-bar')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-foo", "rename-bar"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // sindex/api.yaml line #31 /* err_regex('ReqlOpFailedError','Index `rename-fake` does not exist or index `rename-stuff` already exists on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]',[]) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `rename-fake` does not exist or index `rename-stuff` already exists on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_sindex_api.index_rename('rename-fake','rename-stuff') */ suite.T().Log("About to run line #31: table_test_sindex_api.IndexRename('rename-fake', 'rename-stuff')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-fake", "rename-stuff"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #31") } { // sindex/api.yaml line #34 /* err('ReqlQueryLogicError','Index name conflict:'+' `id` is the name of the primary key.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Index name conflict:"+" `id` is the name of the primary key.") /* table_test_sindex_api.index_rename('id','rename-stuff') */ suite.T().Log("About to run line #34: table_test_sindex_api.IndexRename('id', 'rename-stuff')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("id", "rename-stuff"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // sindex/api.yaml line #37 /* err('ReqlQueryLogicError','Index name conflict:'+' `id` is the name of the primary key.',[]) */ var expected_ Err = err("ReqlQueryLogicError", "Index name conflict:"+" `id` is the name of the primary key.") /* table_test_sindex_api.index_rename('rename-stuff','id') */ suite.T().Log("About to run line #37: table_test_sindex_api.IndexRename('rename-stuff', 'id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-stuff", "id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // sindex/api.yaml line #40 /* {'renamed':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"renamed": 0} /* table_test_sindex_api.index_rename('rename-foo','rename-foo') */ suite.T().Log("About to run line #40: table_test_sindex_api.IndexRename('rename-foo', 'rename-foo')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-foo", "rename-foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // sindex/api.yaml line #43 /* {'renamed':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"renamed": 0} /* table_test_sindex_api.index_rename('rename-foo','rename-foo',overwrite=True) */ suite.T().Log("About to run line #43: table_test_sindex_api.IndexRename('rename-foo', 'rename-foo').OptArgs(r.IndexRenameOpts{Overwrite: true, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-foo", "rename-foo").OptArgs(r.IndexRenameOpts{Overwrite: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // sindex/api.yaml line #48 /* {'renamed':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"renamed": 1} /* table_test_sindex_api.index_rename('rename-foo','rename-bar',overwrite=True) */ suite.T().Log("About to run line #48: table_test_sindex_api.IndexRename('rename-foo', 'rename-bar').OptArgs(r.IndexRenameOpts{Overwrite: true, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-foo", "rename-bar").OptArgs(r.IndexRenameOpts{Overwrite: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #48") } { // sindex/api.yaml line #53 /* {'renamed':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"renamed": 1} /* table_test_sindex_api.index_rename('rename-bar','rename-stuff',overwrite=True) */ suite.T().Log("About to run line #53: table_test_sindex_api.IndexRename('rename-bar', 'rename-stuff').OptArgs(r.IndexRenameOpts{Overwrite: true, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-bar", "rename-stuff").OptArgs(r.IndexRenameOpts{Overwrite: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #53") } { // sindex/api.yaml line #58 /* {'renamed':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"renamed": 1} /* table_test_sindex_api.index_rename('rename-stuff','rename-last') */ suite.T().Log("About to run line #58: table_test_sindex_api.IndexRename('rename-stuff', 'rename-last')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexRename("rename-stuff", "rename-last"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #58") } { // sindex/api.yaml line #62 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('minval', lambda:r.minval) */ suite.T().Log("About to run line #62: table_test_sindex_api.IndexCreateFunc('minval', func() interface{} { return r.MinVal})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("minval", func() interface{} { return r.MinVal }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #62") } { // sindex/api.yaml line #67 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('maxval', lambda:r.maxval) */ suite.T().Log("About to run line #67: table_test_sindex_api.IndexCreateFunc('maxval', func() interface{} { return r.MaxVal})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("maxval", func() interface{} { return r.MaxVal }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #67") } { // sindex/api.yaml line #71 /* bag([{'index':'rename-last','ready':true}, {'index':'minval','ready':true}, {'index':'maxval','ready':true}]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{map[interface{}]interface{}{"index": "rename-last", "ready": true}, map[interface{}]interface{}{"index": "minval", "ready": true}, map[interface{}]interface{}{"index": "maxval", "ready": true}}) /* table_test_sindex_api.index_wait('rename-last', 'minval', 'maxval').pluck('index', 'ready') */ suite.T().Log("About to run line #71: table_test_sindex_api.IndexWait('rename-last', 'minval', 'maxval').Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexWait("rename-last", "minval", "maxval").Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // sindex/api.yaml line #76 /* 3 */ var expected_ int = 3 /* table_test_sindex_api.get_all(0, index='rename-last').count() */ suite.T().Log("About to run line #76: table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: 'rename-last', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: "rename-last"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #76") } { // sindex/api.yaml line #82 /* 0 */ var expected_ int = 0 /* table_test_sindex_api.get_all(r.minval, index='minval').count() */ suite.T().Log("About to run line #82: table_test_sindex_api.GetAll(r.MinVal).OptArgs(r.GetAllOpts{Index: 'minval', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(r.MinVal).OptArgs(r.GetAllOpts{Index: "minval"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #82") } { // sindex/api.yaml line #87 /* 0 */ var expected_ int = 0 /* table_test_sindex_api.get_all(r.maxval, index='maxval').count() */ suite.T().Log("About to run line #87: table_test_sindex_api.GetAll(r.MaxVal).OptArgs(r.GetAllOpts{Index: 'maxval', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(r.MaxVal).OptArgs(r.GetAllOpts{Index: "maxval"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } { // sindex/api.yaml line #92 /* 0 */ var expected_ int = 0 /* table_test_sindex_api.between(r.minval, r.maxval, index='minval').count() */ suite.T().Log("About to run line #92: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'minval', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "minval"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #92") } { // sindex/api.yaml line #97 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('rename-last-dup', table_test_sindex_api.index_status('rename-last').nth(0).get_field('function')) */ suite.T().Log("About to run line #97: table_test_sindex_api.IndexCreateFunc('rename-last-dup', table_test_sindex_api.IndexStatus('rename-last').Nth(0).Field('function'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("rename-last-dup", table_test_sindex_api.IndexStatus("rename-last").Nth(0).Field("function")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #97") } { // sindex/api.yaml line #100 /* [{'index':'rename-last-dup','ready':true}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"index": "rename-last-dup", "ready": true}} /* table_test_sindex_api.index_wait('rename-last-dup').pluck('index', 'ready') */ suite.T().Log("About to run line #100: table_test_sindex_api.IndexWait('rename-last-dup').Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexWait("rename-last-dup").Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #100") } { // sindex/api.yaml line #103 /* 3 */ var expected_ int = 3 /* table_test_sindex_api.get_all(0, index='rename-last-dup').count() */ suite.T().Log("About to run line #103: table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: 'rename-last-dup', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: "rename-last-dup"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // sindex/api.yaml line #109 /* {'dropped':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} /* table_test_sindex_api.index_drop('rename-last-dup') */ suite.T().Log("About to run line #109: table_test_sindex_api.IndexDrop('rename-last-dup')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexDrop("rename-last-dup"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // sindex/api.yaml line #110 /* {'dropped':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} /* table_test_sindex_api.index_drop('minval') */ suite.T().Log("About to run line #110: table_test_sindex_api.IndexDrop('minval')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexDrop("minval"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #110") } { // sindex/api.yaml line #111 /* {'dropped':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} /* table_test_sindex_api.index_drop('maxval') */ suite.T().Log("About to run line #111: table_test_sindex_api.IndexDrop('maxval')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexDrop("maxval"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // sindex/api.yaml line #114 /* ['rename-last'] */ var expected_ []interface{} = []interface{}{"rename-last"} /* table_test_sindex_api.index_list() */ suite.T().Log("About to run line #114: table_test_sindex_api.IndexList()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexList(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #114") } { // sindex/api.yaml line #117 /* {'dropped':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} /* table_test_sindex_api.index_drop('rename-last') */ suite.T().Log("About to run line #117: table_test_sindex_api.IndexDrop('rename-last')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexDrop("rename-last"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #117") } { // sindex/api.yaml line #121 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('ai', r.row['a']) */ suite.T().Log("About to run line #121: table_test_sindex_api.IndexCreateFunc('ai', r.Row.AtIndex('a'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("ai", r.Row.AtIndex("a")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #121") } { // sindex/api.yaml line #125 /* err_regex("ReqlOpFailedError", "Index `ai` already exists on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]", []) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `ai` already exists on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_sindex_api.index_create('ai', r.row['a']) */ suite.T().Log("About to run line #125: table_test_sindex_api.IndexCreateFunc('ai', r.Row.AtIndex('a'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("ai", r.Row.AtIndex("a")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #125") } { // sindex/api.yaml line #129 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('bi', r.row['b']) */ suite.T().Log("About to run line #129: table_test_sindex_api.IndexCreateFunc('bi', r.Row.AtIndex('b'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("bi", r.Row.AtIndex("b")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #129") } { // sindex/api.yaml line #133 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('ci', r.row['c']) */ suite.T().Log("About to run line #133: table_test_sindex_api.IndexCreateFunc('ci', r.Row.AtIndex('c'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("ci", r.Row.AtIndex("c")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #133") } { // sindex/api.yaml line #137 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('idi', r.row['id']) */ suite.T().Log("About to run line #137: table_test_sindex_api.IndexCreateFunc('idi', r.Row.AtIndex('id'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("idi", r.Row.AtIndex("id")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #137") } { // sindex/api.yaml line #141 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('kdi', [r.row['id']]) */ suite.T().Log("About to run line #141: table_test_sindex_api.IndexCreateFunc('kdi', []interface{}{r.Row.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("kdi", []interface{}{r.Row.AtIndex("id")}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #141") } { // sindex/api.yaml line #145 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('mi', r.row['m'], multi=True) */ suite.T().Log("About to run line #145: table_test_sindex_api.IndexCreateFunc('mi', r.Row.AtIndex('m')).OptArgs(r.IndexCreateOpts{Multi: true, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("mi", r.Row.AtIndex("m")).OptArgs(r.IndexCreateOpts{Multi: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #145") } { // sindex/api.yaml line #149 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('brokeni', r.row['broken']) */ suite.T().Log("About to run line #149: table_test_sindex_api.IndexCreateFunc('brokeni', r.Row.AtIndex('broken'))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("brokeni", r.Row.AtIndex("broken")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #149") } { // sindex/api.yaml line #153 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.index_wait().pluck('index', 'ready') */ suite.T().Log("About to run line #153: table_test_sindex_api.IndexWait().Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexWait().Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #153") } { // sindex/api.yaml line #156 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.get(True) */ suite.T().Log("About to run line #156: table_test_sindex_api.Get(true)") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Get(true), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #156") } { // sindex/api.yaml line #159 /* null */ var expected_ interface{} = nil /* table_test_sindex_api.get([]) */ suite.T().Log("About to run line #159: table_test_sindex_api.Get([]interface{}{})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Get([]interface{}{}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #159") } { // sindex/api.yaml line #161 /* null */ var expected_ interface{} = nil /* table_test_sindex_api.get(-1) */ suite.T().Log("About to run line #161: table_test_sindex_api.Get(-1)") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Get(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #161") } { // sindex/api.yaml line #164 /* 1 */ var expected_ int = 1 /* table_test_sindex_api.get(1)['id'] */ suite.T().Log("About to run line #164: table_test_sindex_api.Get(1).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Get(1).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #164") } { // sindex/api.yaml line #168 /* 'SELECTION' */ var expected_ string = "SELECTION" /* table_test_sindex_api.get(1).type_of() */ suite.T().Log("About to run line #168: table_test_sindex_api.Get(1).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Get(1).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #168") } { // sindex/api.yaml line #172 /* {'replaced':0,'skipped':0,'deleted':0,'unchanged':1,'errors':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"replaced": 0, "skipped": 0, "deleted": 0, "unchanged": 1, "errors": 0, "inserted": 0} /* table_test_sindex_api.get(1).update(lambda x:null) */ suite.T().Log("About to run line #172: table_test_sindex_api.Get(1).Update(func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Get(1).Update(func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #172") } { // sindex/api.yaml line #180 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.get_all(True, index='id') */ suite.T().Log("About to run line #180: table_test_sindex_api.GetAll(true).OptArgs(r.GetAllOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(true).OptArgs(r.GetAllOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #180") } { // sindex/api.yaml line #185 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all(-1, index='id') */ suite.T().Log("About to run line #185: table_test_sindex_api.GetAll(-1).OptArgs(r.GetAllOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(-1).OptArgs(r.GetAllOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #185") } { // sindex/api.yaml line #189 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all(-1) */ suite.T().Log("About to run line #189: table_test_sindex_api.GetAll(-1)") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(-1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #189") } { // sindex/api.yaml line #193 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all([-1]) */ suite.T().Log("About to run line #193: table_test_sindex_api.GetAll([]interface{}{-1})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll([]interface{}{-1}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #193") } { // sindex/api.yaml line #197 /* 1 */ var expected_ int = 1 /* table_test_sindex_api.get_all(1, index='id')[0]['id'] */ suite.T().Log("About to run line #197: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'id', }).AtIndex(0).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "id"}).AtIndex(0).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #197") } { // sindex/api.yaml line #201 /* 1 */ var expected_ int = 1 /* table_test_sindex_api.get_all(1)[0]['id'] */ suite.T().Log("About to run line #201: table_test_sindex_api.GetAll(1).AtIndex(0).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).AtIndex(0).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #201") } { // sindex/api.yaml line #205 /* bag([1,2,3]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{1, 2, 3}) /* table_test_sindex_api.get_all(1,2,3, index='id').map(lambda x:x["id"]).coerce_to("ARRAY") */ suite.T().Log("About to run line #205: table_test_sindex_api.GetAll(1, 2, 3).OptArgs(r.GetAllOpts{Index: 'id', }).Map(func(x r.Term) interface{} { return x.AtIndex('id')}).CoerceTo('ARRAY')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1, 2, 3).OptArgs(r.GetAllOpts{Index: "id"}).Map(func(x r.Term) interface{} { return x.AtIndex("id") }).CoerceTo("ARRAY"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #205") } { // sindex/api.yaml line #209 /* bag([1,2,3]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{1, 2, 3}) /* table_test_sindex_api.get_all(1,2,3).map(lambda x:x["id"]).coerce_to("ARRAY") */ suite.T().Log("About to run line #209: table_test_sindex_api.GetAll(1, 2, 3).Map(func(x r.Term) interface{} { return x.AtIndex('id')}).CoerceTo('ARRAY')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1, 2, 3).Map(func(x r.Term) interface{} { return x.AtIndex("id") }).CoerceTo("ARRAY"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #209") } { // sindex/api.yaml line #213 /* 'SELECTION' */ var expected_ string = "SELECTION" /* table_test_sindex_api.get_all(1, index='id').type_of() */ suite.T().Log("About to run line #213: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'id', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "id"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #213") } { // sindex/api.yaml line #217 /* 'SELECTION' */ var expected_ string = "SELECTION" /* table_test_sindex_api.get_all(1).type_of() */ suite.T().Log("About to run line #217: table_test_sindex_api.GetAll(1).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #217") } { // sindex/api.yaml line #221 /* {'replaced':0,'skipped':0,'deleted':0,'unchanged':1,'errors':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"replaced": 0, "skipped": 0, "deleted": 0, "unchanged": 1, "errors": 0, "inserted": 0} /* table_test_sindex_api.get_all(1, index='id').update(lambda x:null) */ suite.T().Log("About to run line #221: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'id', }).Update(func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "id"}).Update(func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #221") } { // sindex/api.yaml line #225 /* {'replaced':0,'skipped':0,'deleted':0,'unchanged':1,'errors':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"replaced": 0, "skipped": 0, "deleted": 0, "unchanged": 1, "errors": 0, "inserted": 0} /* table_test_sindex_api.get_all(1).update(lambda x:null) */ suite.T().Log("About to run line #225: table_test_sindex_api.GetAll(1).Update(func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).Update(func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #225") } { // sindex/api.yaml line #229 /* {'replaced':0,'skipped':0,'deleted':0,'unchanged':3,'errors':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"replaced": 0, "skipped": 0, "deleted": 0, "unchanged": 3, "errors": 0, "inserted": 0} /* table_test_sindex_api.get_all(1,2,3, index='id').update(lambda x:null) */ suite.T().Log("About to run line #229: table_test_sindex_api.GetAll(1, 2, 3).OptArgs(r.GetAllOpts{Index: 'id', }).Update(func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1, 2, 3).OptArgs(r.GetAllOpts{Index: "id"}).Update(func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #229") } { // sindex/api.yaml line #233 /* {'replaced':0,'skipped':0,'deleted':0,'unchanged':3,'errors':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"replaced": 0, "skipped": 0, "deleted": 0, "unchanged": 3, "errors": 0, "inserted": 0} /* table_test_sindex_api.get_all(1,2,3).update(lambda x:null) */ suite.T().Log("About to run line #233: table_test_sindex_api.GetAll(1, 2, 3).Update(func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1, 2, 3).Update(func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #233") } { // sindex/api.yaml line #238 /* err_regex("ReqlOpFailedError", "Index `fake` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]", []) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `fake` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_sindex_api.get_all(0, index='fake') */ suite.T().Log("About to run line #238: table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: 'fake', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: "fake"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #238") } { // sindex/api.yaml line #242 /* err("ReqlQueryLogicError", "Cannot use a geospatial index with `get_all`. Use `get_intersecting` instead.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use a geospatial index with `get_all`. Use `get_intersecting` instead.") /* table_test_sindex_api.get_all(r.point(0, 0)) */ suite.T().Log("About to run line #242: table_test_sindex_api.GetAll(r.Point(0, 0))") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(r.Point(0, 0)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #242") } { // sindex/api.yaml line #246 /* err("ReqlQueryLogicError", "Expected type STRING but found BOOL.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found BOOL.") /* table_test_sindex_api.get_all(0, index=False) */ suite.T().Log("About to run line #246: table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: false, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(0).OptArgs(r.GetAllOpts{Index: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #246") } { // sindex/api.yaml line #251 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.get_all(True, index='id') */ suite.T().Log("About to run line #251: table_test_sindex_api.GetAll(true).OptArgs(r.GetAllOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(true).OptArgs(r.GetAllOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #251") } { // sindex/api.yaml line #256 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all([], index='id') */ suite.T().Log("About to run line #256: table_test_sindex_api.GetAll([]interface{}{}).OptArgs(r.GetAllOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll([]interface{}{}).OptArgs(r.GetAllOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #256") } { // sindex/api.yaml line #260 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.get_all(True, index='idi') */ suite.T().Log("About to run line #260: table_test_sindex_api.GetAll(true).OptArgs(r.GetAllOpts{Index: 'idi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(true).OptArgs(r.GetAllOpts{Index: "idi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #260") } { // sindex/api.yaml line #265 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all([], index='idi') */ suite.T().Log("About to run line #265: table_test_sindex_api.GetAll([]interface{}{}).OptArgs(r.GetAllOpts{Index: 'idi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll([]interface{}{}).OptArgs(r.GetAllOpts{Index: "idi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #265") } { // sindex/api.yaml line #270 /* 1 */ var expected_ int = 1 /* table_test_sindex_api.get_all(1, index='id')[0]['id'] */ suite.T().Log("About to run line #270: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'id', }).AtIndex(0).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "id"}).AtIndex(0).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #270") } { // sindex/api.yaml line #274 /* 1 */ var expected_ int = 1 /* table_test_sindex_api.get_all(1, index='idi')[0]['id'] */ suite.T().Log("About to run line #274: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'idi', }).AtIndex(0).AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "idi"}).AtIndex(0).AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #274") } { // sindex/api.yaml line #278 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all(1, index='ai') */ suite.T().Log("About to run line #278: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'ai', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "ai"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #278") } { // sindex/api.yaml line #282 /* [3] */ var expected_ []interface{} = []interface{}{3} /* table_test_sindex_api.get_all(1, index='bi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #282: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'bi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "bi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #282") } { // sindex/api.yaml line #286 /* err('ReqlQueryLogicError', 'Indexed order_by can only be performed on a TABLE or TABLE_SLICE.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Indexed order_by can only be performed on a TABLE or TABLE_SLICE. Make sure order_by comes before any transformations (such as map) or filters.") /* table_test_sindex_api.get_all(1, index='bi').order_by(index='id').map(lambda x:x['id']) */ suite.T().Log("About to run line #286: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'bi', }).OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "bi"}).OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #286") } { // sindex/api.yaml line #290 /* err('ReqlQueryLogicError', 'Expected type TABLE_SLICE but found SELECTION:', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type TABLE_SLICE but found SELECTION:") /* table_test_sindex_api.get_all(1, index='bi').between(1, 1, index='id').map(lambda x:x['id']) */ suite.T().Log("About to run line #290: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'bi', }).Between(1, 1).OptArgs(r.BetweenOpts{Index: 'id', }).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "bi"}).Between(1, 1).OptArgs(r.BetweenOpts{Index: "id"}).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #290") } { // sindex/api.yaml line #294 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.get_all(1, index='ci').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #294: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'ci', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "ci"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #294") } { // sindex/api.yaml line #298 /* 'SELECTION' */ var expected_ string = "SELECTION" /* table_test_sindex_api.get_all(1, index='ci').type_of() */ suite.T().Log("About to run line #298: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'ci', }).TypeOf()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "ci"}).TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #298") } { // sindex/api.yaml line #302 /* {'replaced':0,'skipped':0,'deleted':0,'unchanged':2,'errors':0,'inserted':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"replaced": 0, "skipped": 0, "deleted": 0, "unchanged": 2, "errors": 0, "inserted": 0} /* table_test_sindex_api.get_all(1, index='ci').update(lambda x:null) */ suite.T().Log("About to run line #302: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'ci', }).Update(func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "ci"}).Update(func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #302") } { // sindex/api.yaml line #306 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all(1, index='brokeni') */ suite.T().Log("About to run line #306: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'brokeni', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "brokeni"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #306") } { // sindex/api.yaml line #311 /* [rows[0]] */ var expected_ []interface{} = []interface{}{rows[0]} /* table_test_sindex_api.get_all(1, index='mi') */ suite.T().Log("About to run line #311: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'mi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "mi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #311") } { // sindex/api.yaml line #316 /* [rows[0]] */ var expected_ []interface{} = []interface{}{rows[0]} /* table_test_sindex_api.get_all(2, index='mi') */ suite.T().Log("About to run line #316: table_test_sindex_api.GetAll(2).OptArgs(r.GetAllOpts{Index: 'mi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(2).OptArgs(r.GetAllOpts{Index: "mi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #316") } { // sindex/api.yaml line #321 /* [rows[1]] */ var expected_ []interface{} = []interface{}{rows[1]} /* table_test_sindex_api.get_all(5, index='mi') */ suite.T().Log("About to run line #321: table_test_sindex_api.GetAll(5).OptArgs(r.GetAllOpts{Index: 'mi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(5).OptArgs(r.GetAllOpts{Index: "mi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #321") } { // sindex/api.yaml line #326 /* [rows[2]] */ var expected_ []interface{} = []interface{}{rows[2]} /* table_test_sindex_api.get_all(7, index='mi') */ suite.T().Log("About to run line #326: table_test_sindex_api.GetAll(7).OptArgs(r.GetAllOpts{Index: 'mi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(7).OptArgs(r.GetAllOpts{Index: "mi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #326") } { // sindex/api.yaml line #331 /* err_regex("ReqlOpFailedError", "Index `fake` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]", []) */ var expected_ Err = err_regex("ReqlOpFailedError", "Index `fake` was not found on table `[a-zA-Z0-9_]+.[a-zA-Z0-9_]+`[.]") /* table_test_sindex_api.eq_join('id', table_test_sindex_api, index='fake') */ suite.T().Log("About to run line #331: table_test_sindex_api.EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'fake', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "fake"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #331") } { // sindex/api.yaml line #335 /* err("ReqlQueryLogicError", "Expected type STRING but found BOOL.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found BOOL.") /* table_test_sindex_api.eq_join('id', table_test_sindex_api, index=False) */ suite.T().Log("About to run line #335: table_test_sindex_api.EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: false, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: false}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #335") } { // sindex/api.yaml line #340 /* [{'left':rows[1],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[1], "right": rows[0]}} /* table_test_sindex_api.filter({'id':1}).eq_join('id', table_test_sindex_api, index='mi') */ suite.T().Log("About to run line #340: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 1, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'mi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 1}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "mi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #340") } { // sindex/api.yaml line #345 /* [{'left':rows[0],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api) */ suite.T().Log("About to run line #345: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api)") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #345") } { // sindex/api.yaml line #350 /* [{'left':rows[0],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join(lambda x:x['id'], table_test_sindex_api) */ suite.T().Log("About to run line #350: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin(func(x r.Term) interface{} { return x.AtIndex('id')}, table_test_sindex_api)") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin(func(x r.Term) interface{} { return x.AtIndex("id") }, table_test_sindex_api), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #350") } { // sindex/api.yaml line #355 /* [{'left':rows[0],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api, index='id') */ suite.T().Log("About to run line #355: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #355") } { // sindex/api.yaml line #360 /* [{'left':rows[0],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join(lambda x:x['id'], table_test_sindex_api, index='id') */ suite.T().Log("About to run line #360: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin(func(x r.Term) interface{} { return x.AtIndex('id')}, table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'id', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin(func(x r.Term) interface{} { return x.AtIndex("id") }, table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "id"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #360") } { // sindex/api.yaml line #365 /* [{'left':rows[0],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api, index='idi') */ suite.T().Log("About to run line #365: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'idi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "idi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #365") } { // sindex/api.yaml line #370 /* [{'left':rows[0],'right':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join(lambda x:x['id'], table_test_sindex_api, index='idi') */ suite.T().Log("About to run line #370: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin(func(x r.Term) interface{} { return x.AtIndex('id')}, table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'idi', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin(func(x r.Term) interface{} { return x.AtIndex("id") }, table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "idi"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #370") } { // sindex/api.yaml line #375 /* [{'right':rows[0],'left':rows[0]}, {'right':rows[1],'left':rows[0]}, {'right':rows[2],'left':rows[0]}, {'right':rows[3],'left':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"right": rows[0], "left": rows[0]}, map[interface{}]interface{}{"right": rows[1], "left": rows[0]}, map[interface{}]interface{}{"right": rows[2], "left": rows[0]}, map[interface{}]interface{}{"right": rows[3], "left": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api, index='ai').order_by('right') */ suite.T().Log("About to run line #375: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'ai', }).OrderBy('right')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "ai"}).OrderBy("right"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #375") } { // sindex/api.yaml line #382 /* ([{'right':rows[0],'left':rows[0]}, {'right':rows[1],'left':rows[0]}, {'right':rows[2],'left':rows[0]}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"right": rows[0], "left": rows[0]}, map[interface{}]interface{}{"right": rows[1], "left": rows[0]}, map[interface{}]interface{}{"right": rows[2], "left": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api, index='bi').order_by('right') */ suite.T().Log("About to run line #382: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'bi', }).OrderBy('right')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "bi"}).OrderBy("right"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #382") } { // sindex/api.yaml line #388 /* [{'right':rows[0],'left':rows[0]}, {'right':rows[1],'left':rows[0]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"right": rows[0], "left": rows[0]}, map[interface{}]interface{}{"right": rows[1], "left": rows[0]}} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api, index='ci').order_by('right') */ suite.T().Log("About to run line #388: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'ci', }).OrderBy('right')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "ci"}).OrderBy("right"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #388") } { // sindex/api.yaml line #392 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.filter({'id':0}).eq_join('id', table_test_sindex_api, index='brokeni') */ suite.T().Log("About to run line #392: table_test_sindex_api.Filter(map[interface{}]interface{}{'id': 0, }).EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'brokeni', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Filter(map[interface{}]interface{}{"id": 0}).EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "brokeni"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #392") } { // sindex/api.yaml line #397 /* [{'left':rows[0],'right':rows[0]}, {'left':rows[1],'right':rows[0]}, {'left':rows[0],'right':rows[1]}, {'left':rows[1],'right':rows[1]}, {'left':rows[0],'right':rows[2]}, {'left':rows[1],'right':rows[2]}, {'left':rows[2],'right':rows[3]}, {'left':rows[3],'right':rows[3]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"left": rows[0], "right": rows[0]}, map[interface{}]interface{}{"left": rows[1], "right": rows[0]}, map[interface{}]interface{}{"left": rows[0], "right": rows[1]}, map[interface{}]interface{}{"left": rows[1], "right": rows[1]}, map[interface{}]interface{}{"left": rows[0], "right": rows[2]}, map[interface{}]interface{}{"left": rows[1], "right": rows[2]}, map[interface{}]interface{}{"left": rows[2], "right": rows[3]}, map[interface{}]interface{}{"left": rows[3], "right": rows[3]}} /* table_test_sindex_api.eq_join('c', table_test_sindex_api, index='bi').order_by('right', 'left') */ suite.T().Log("About to run line #397: table_test_sindex_api.EqJoin('c', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'bi', }).OrderBy('right', 'left')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.EqJoin("c", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "bi"}).OrderBy("right", "left"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #397") } { // sindex/api.yaml line #408 /* err("ReqlQueryLogicError", "Index name conflict: `id` is the name of the primary key.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Index name conflict: `id` is the name of the primary key.") /* table_test_sindex_api.index_create('id') */ suite.T().Log("About to run line #408: table_test_sindex_api.IndexCreate('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreate("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #408") } { // sindex/api.yaml line #411 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('c') */ suite.T().Log("About to run line #411: table_test_sindex_api.IndexCreate('c')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreate("c"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #411") } { // sindex/api.yaml line #413 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('broken') */ suite.T().Log("About to run line #413: table_test_sindex_api.IndexCreate('broken')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreate("broken"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #413") } { // sindex/api.yaml line #416 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.index_wait('broken') */ suite.T().Log("About to run line #416: table_test_sindex_api.IndexWait('broken')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexWait("broken"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #416") } { // sindex/api.yaml line #419 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.get_all(1, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #419: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #419") } { // sindex/api.yaml line #423 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.get_all(1, index='broken').order_by('broken').map(lambda x:x['id']) */ suite.T().Log("About to run line #423: table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: 'broken', }).OrderBy('broken').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(1).OptArgs(r.GetAllOpts{Index: "broken"}).OrderBy("broken").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #423") } { // sindex/api.yaml line #428 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('nil', lambda x:null) */ suite.T().Log("About to run line #428: table_test_sindex_api.IndexCreateFunc('nil', func(x r.Term) interface{} { return nil})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("nil", func(x r.Term) interface{} { return nil }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #428") } { // sindex/api.yaml line #431 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.index_wait().pluck('index', 'ready') */ suite.T().Log("About to run line #431: table_test_sindex_api.IndexWait().Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexWait().Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #431") } { // sindex/api.yaml line #434 /* err("ReqlNonExistenceError", "Keys cannot be NULL.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Keys cannot be NULL.") /* table_test_sindex_api.get_all(null, index='nil') */ suite.T().Log("About to run line #434: table_test_sindex_api.GetAll(nil).OptArgs(r.GetAllOpts{Index: 'nil', })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.GetAll(nil).OptArgs(r.GetAllOpts{Index: "nil"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #434") } { // sindex/api.yaml line #439 /* {'deleted':0,'inserted':1,'skipped':0,'errors':0,'replaced':0,'unchanged':0} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "inserted": 1, "skipped": 0, "errors": 0, "replaced": 0, "unchanged": 0} /* table_test_sindex_api.insert({'id':4, 'a':4, 'b':4, 'c':4, 'm':[14,15,16]}) */ suite.T().Log("About to run line #439: table_test_sindex_api.Insert(map[interface{}]interface{}{'id': 4, 'a': 4, 'b': 4, 'c': 4, 'm': []interface{}{14, 15, 16}, })") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Insert(map[interface{}]interface{}{"id": 4, "a": 4, "b": 4, "c": 4, "m": []interface{}{14, 15, 16}}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #439") } { // sindex/api.yaml line #446 /* [{'right':rows[0],'left':rows[0]}, {'right':rows[1],'left':rows[0]}, {'right':rows[2],'left':rows[1]}, {'right':rows[3],'left':rows[1]}, {'right':rows[4],'left':rows[4]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"right": rows[0], "left": rows[0]}, map[interface{}]interface{}{"right": rows[1], "left": rows[0]}, map[interface{}]interface{}{"right": rows[2], "left": rows[1]}, map[interface{}]interface{}{"right": rows[3], "left": rows[1]}, map[interface{}]interface{}{"right": rows[4], "left": rows[4]}} /* table_test_sindex_api.eq_join('id', table_test_sindex_api, index='c').order_by('left', 'right').coerce_to("ARRAY") */ suite.T().Log("About to run line #446: table_test_sindex_api.EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'c', }).OrderBy('left', 'right').CoerceTo('ARRAY')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "c"}).OrderBy("left", "right").CoerceTo("ARRAY"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #446") } { // sindex/api.yaml line #455 /* [{'right':rows[0],'left':rows[0]}, {'right':rows[1],'left':rows[0]}, {'right':rows[2],'left':rows[1]}, {'right':rows[3],'left':rows[1]}, {'right':rows[4],'left':rows[4]}] */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"right": rows[0], "left": rows[0]}, map[interface{}]interface{}{"right": rows[1], "left": rows[0]}, map[interface{}]interface{}{"right": rows[2], "left": rows[1]}, map[interface{}]interface{}{"right": rows[3], "left": rows[1]}, map[interface{}]interface{}{"right": rows[4], "left": rows[4]}} /* table_test_sindex_api.eq_join('id', table_test_sindex_api, index='ci').order_by('left', 'right') */ suite.T().Log("About to run line #455: table_test_sindex_api.EqJoin('id', table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: 'ci', }).OrderBy('left', 'right')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.EqJoin("id", table_test_sindex_api).OptArgs(r.EqJoinOpts{Index: "ci"}).OrderBy("left", "right"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #455") } { // sindex/api.yaml line #465 /* err('ReqlQueryLogicError', 'Cannot use `nu' + 'll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use `nu"+"ll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.") /* table_test_sindex_api.between(null, 2, index='id').count() */ suite.T().Log("About to run line #465: table_test_sindex_api.Between(nil, 2).OptArgs(r.BetweenOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(nil, 2).OptArgs(r.BetweenOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #465") } { // sindex/api.yaml line #466 /* err('ReqlQueryLogicError', 'Cannot use `nu' + 'll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use `nu"+"ll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.") /* table_test_sindex_api.between(2, null, index='id').count() */ suite.T().Log("About to run line #466: table_test_sindex_api.Between(2, nil).OptArgs(r.BetweenOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(2, nil).OptArgs(r.BetweenOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #466") } { // sindex/api.yaml line #467 /* err('ReqlQueryLogicError', 'Cannot use `nu' + 'll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.') */ var expected_ Err = err("ReqlQueryLogicError", "Cannot use `nu"+"ll` in BETWEEN, use `r.minval` or `r.maxval` to denote unboundedness.") /* table_test_sindex_api.between(null, null, index='id').count() */ suite.T().Log("About to run line #467: table_test_sindex_api.Between(nil, nil).OptArgs(r.BetweenOpts{Index: 'id', }).Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(nil, nil).OptArgs(r.BetweenOpts{Index: "id"}).Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #467") } { // sindex/api.yaml line #479 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #479: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #479") } { // sindex/api.yaml line #483 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval).order_by(index='id').map(lambda x:x['id']) */ suite.T().Log("About to run line #483: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #483") } { // sindex/api.yaml line #487 /* err('ReqlQueryLogicError', 'Cannot perform multiple BETWEENs on the same table.', [0]) */ var expected_ Err = err("ReqlQueryLogicError", "Cannot perform multiple BETWEENs on the same table.") /* table_test_sindex_api.between(r.minval, r.maxval).between(r.minval, r.maxval).map(lambda x:x['id']) */ suite.T().Log("About to run line #487: table_test_sindex_api.Between(r.MinVal, r.MaxVal).Between(r.MinVal, r.MaxVal).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).Between(r.MinVal, r.MaxVal).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #487") } { // sindex/api.yaml line #491 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.order_by(index='id').between(r.minval, 3).map(lambda x:x['id']) */ suite.T().Log("About to run line #491: table_test_sindex_api.OrderBy().OptArgs(r.OrderByOpts{Index: 'id', }).Between(r.MinVal, 3).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.OrderBy().OptArgs(r.OrderByOpts{Index: "id"}).Between(r.MinVal, 3).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #491") } { // sindex/api.yaml line #495 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #495: table_test_sindex_api.Between(0, r.MaxVal).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #495") } { // sindex/api.yaml line #499 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, 4).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #499: table_test_sindex_api.Between(r.MinVal, 4).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #499") } { // sindex/api.yaml line #503 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 4).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #503: table_test_sindex_api.Between(0, 4).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #503") } { // sindex/api.yaml line #507 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, 5).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #507: table_test_sindex_api.Between(-1, 5).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 5).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #507") } { // sindex/api.yaml line #511 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, 5).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #511: table_test_sindex_api.Between(5, 5).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, 5).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #511") } { // sindex/api.yaml line #515 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #515: table_test_sindex_api.Between(5, r.MaxVal).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #515") } { // sindex/api.yaml line #519 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #519: table_test_sindex_api.Between(-1, -1).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #519") } { // sindex/api.yaml line #523 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1).order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #523: table_test_sindex_api.Between(r.MinVal, -1).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #523") } { // sindex/api.yaml line #528 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #528: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #528") } { // sindex/api.yaml line #532 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #532: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #532") } { // sindex/api.yaml line #536 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, 4, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #536: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #536") } { // sindex/api.yaml line #540 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, 4, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #540: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #540") } { // sindex/api.yaml line #544 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, 5, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #544: table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #544") } { // sindex/api.yaml line #548 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, 5, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #548: table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #548") } { // sindex/api.yaml line #552 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #552: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #552") } { // sindex/api.yaml line #556 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #556: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #556") } { // sindex/api.yaml line #560 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #560: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #560") } { // sindex/api.yaml line #565 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #565: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #565") } { // sindex/api.yaml line #569 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #569: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #569") } { // sindex/api.yaml line #573 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, 4, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #573: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #573") } { // sindex/api.yaml line #577 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 4, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #577: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #577") } { // sindex/api.yaml line #581 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, 5, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #581: table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #581") } { // sindex/api.yaml line #585 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, 5, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #585: table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #585") } { // sindex/api.yaml line #589 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #589: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #589") } { // sindex/api.yaml line #593 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #593: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #593") } { // sindex/api.yaml line #597 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, index='id').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #597: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: 'id', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: "id"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #597") } { // sindex/api.yaml line #602 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #602: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #602") } { // sindex/api.yaml line #606 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #606: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #606") } { // sindex/api.yaml line #610 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, 4, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #610: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #610") } { // sindex/api.yaml line #614 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, 4, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #614: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #614") } { // sindex/api.yaml line #618 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, 5, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #618: table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #618") } { // sindex/api.yaml line #622 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, 5, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #622: table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #622") } { // sindex/api.yaml line #626 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #626: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #626") } { // sindex/api.yaml line #630 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #630: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #630") } { // sindex/api.yaml line #634 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, index='id', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #634: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #634") } { // sindex/api.yaml line #639 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #639: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #639") } { // sindex/api.yaml line #643 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #643: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #643") } { // sindex/api.yaml line #647 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, 4, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #647: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #647") } { // sindex/api.yaml line #651 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 4, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #651: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #651") } { // sindex/api.yaml line #655 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, 5, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #655: table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #655") } { // sindex/api.yaml line #659 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, 5, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #659: table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #659") } { // sindex/api.yaml line #663 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #663: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #663") } { // sindex/api.yaml line #667 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #667: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #667") } { // sindex/api.yaml line #671 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, index='idi').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #671: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: 'idi', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: "idi"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #671") } { // sindex/api.yaml line #676 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #676: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #676") } { // sindex/api.yaml line #680 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #680: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #680") } { // sindex/api.yaml line #684 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, 4, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #684: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #684") } { // sindex/api.yaml line #688 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, 4, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #688: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #688") } { // sindex/api.yaml line #692 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, 5, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #692: table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 5).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #692") } { // sindex/api.yaml line #696 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, 5, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #696: table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, 5).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #696") } { // sindex/api.yaml line #700 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #700: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #700") } { // sindex/api.yaml line #704 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #704: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #704") } { // sindex/api.yaml line #708 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, index='idi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #708: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: 'idi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: "idi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #708") } { // sindex/api.yaml line #713 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #713: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #713") } { // sindex/api.yaml line #717 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #717: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #717") } { // sindex/api.yaml line #721 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, 4, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #721: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #721") } { // sindex/api.yaml line #725 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 4, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #725: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #725") } { // sindex/api.yaml line #729 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, 5, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #729: table_test_sindex_api.Between(0, 5).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 5).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #729") } { // sindex/api.yaml line #734 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #734: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #734") } { // sindex/api.yaml line #738 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #738: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #738") } { // sindex/api.yaml line #742 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, 4, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #742: table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 4).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #742") } { // sindex/api.yaml line #746 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, 4, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #746: table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 4).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #746") } { // sindex/api.yaml line #750 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, 5, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #750: table_test_sindex_api.Between(0, 5).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 5).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #750") } { // sindex/api.yaml line #755 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 3, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #755: table_test_sindex_api.Between(0, 3).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 3).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #755") } { // sindex/api.yaml line #759 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 1, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #759: table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #759") } { // sindex/api.yaml line #763 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(0, 0, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #763: table_test_sindex_api.Between(0, 0).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 0).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #763") } { // sindex/api.yaml line #767 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(-1, 2, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #767: table_test_sindex_api.Between(-1, 2).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 2).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #767") } { // sindex/api.yaml line #772 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 3, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #772: table_test_sindex_api.Between(0, 3).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 3).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #772") } { // sindex/api.yaml line #776 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 1, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #776: table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #776") } { // sindex/api.yaml line #780 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 0, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #780: table_test_sindex_api.Between(0, 0).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 0).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #780") } { // sindex/api.yaml line #784 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(-1, 2, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #784: table_test_sindex_api.Between(-1, 2).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 2).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #784") } { // sindex/api.yaml line #789 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(1, 1, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #789: table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #789") } { // sindex/api.yaml line #793 /* [4] */ var expected_ []interface{} = []interface{}{4} /* table_test_sindex_api.between(1, r.maxval, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #793: table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #793") } { // sindex/api.yaml line #797 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #797: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #797") } { // sindex/api.yaml line #801 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, 0, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #801: table_test_sindex_api.Between(r.MinVal, 0).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 0).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #801") } { // sindex/api.yaml line #805 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #805: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #805") } { // sindex/api.yaml line #809 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, index='ai').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #809: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: 'ai', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: "ai"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #809") } { // sindex/api.yaml line #814 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(1, 1, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #814: table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #814") } { // sindex/api.yaml line #818 /* [4] */ var expected_ []interface{} = []interface{}{4} /* table_test_sindex_api.between(1, r.maxval, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #818: table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #818") } { // sindex/api.yaml line #822 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(5, r.maxval, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #822: table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(5, r.MaxVal).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #822") } { // sindex/api.yaml line #826 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, 0, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #826: table_test_sindex_api.Between(r.MinVal, 0).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 0).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #826") } { // sindex/api.yaml line #830 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(-1, -1, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #830: table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, -1).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #830") } { // sindex/api.yaml line #834 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, -1, index='ai', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #834: table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: 'ai', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, -1).OptArgs(r.BetweenOpts{Index: "ai", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #834") } { // sindex/api.yaml line #839 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(0, 1, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #839: table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #839") } { // sindex/api.yaml line #843 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(-1, 1, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #843: table_test_sindex_api.Between(-1, 1).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 1).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #843") } { // sindex/api.yaml line #847 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, 1, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #847: table_test_sindex_api.Between(r.MinVal, 1).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 1).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #847") } { // sindex/api.yaml line #851 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #851: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #851") } { // sindex/api.yaml line #855 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, r.maxval, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #855: table_test_sindex_api.Between(-1, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #855") } { // sindex/api.yaml line #859 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #859: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #859") } { // sindex/api.yaml line #863 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between(1, r.maxval, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #863: table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #863") } { // sindex/api.yaml line #867 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(1, 1, index='c').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #867: table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: 'c', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: "c"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #867") } { // sindex/api.yaml line #872 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(0, 1, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #872: table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #872") } { // sindex/api.yaml line #876 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(-1, 1, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #876: table_test_sindex_api.Between(-1, 1).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, 1).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #876") } { // sindex/api.yaml line #880 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, 1, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #880: table_test_sindex_api.Between(r.MinVal, 1).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, 1).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #880") } { // sindex/api.yaml line #884 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(0, r.maxval, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #884: table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #884") } { // sindex/api.yaml line #888 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(-1, r.maxval, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #888: table_test_sindex_api.Between(-1, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(-1, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #888") } { // sindex/api.yaml line #892 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #892: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #892") } { // sindex/api.yaml line #896 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between(1, r.maxval, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #896: table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, r.MaxVal).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #896") } { // sindex/api.yaml line #900 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.between(1, 1, index='c', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #900: table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, 1).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #900") } { // sindex/api.yaml line #905 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('bc', lambda row:[row['b'], row['c']]) */ suite.T().Log("About to run line #905: table_test_sindex_api.IndexCreateFunc('bc', func(row r.Term) interface{} { return []interface{}{row.AtIndex('b'), row.AtIndex('c')}})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("bc", func(row r.Term) interface{} { return []interface{}{row.AtIndex("b"), row.AtIndex("c")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #905") } { // sindex/api.yaml line #909 /* {'created':1} */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_api.index_create('cb', lambda row:[row['c'], row['b']]) */ suite.T().Log("About to run line #909: table_test_sindex_api.IndexCreateFunc('cb', func(row r.Term) interface{} { return []interface{}{row.AtIndex('c'), row.AtIndex('b')}})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexCreateFunc("cb", func(row r.Term) interface{} { return []interface{}{row.AtIndex("c"), row.AtIndex("b")} }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #909") } { // sindex/api.yaml line #912 /* AnythingIsFine */ var expected_ string = compare.AnythingIsFine /* table_test_sindex_api.index_wait().pluck('index', 'ready') */ suite.T().Log("About to run line #912: table_test_sindex_api.IndexWait().Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.IndexWait().Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #912") } { // sindex/api.yaml line #915 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, [0, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #915: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #915") } { // sindex/api.yaml line #919 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between(r.minval, [0, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #919: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #919") } { // sindex/api.yaml line #923 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, [0, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #923: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #923") } { // sindex/api.yaml line #927 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, [0, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #927: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #927") } { // sindex/api.yaml line #931 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between(r.minval, [1, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #931: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #931") } { // sindex/api.yaml line #935 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, [1, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #935: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #935") } { // sindex/api.yaml line #939 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between(r.minval, [1, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #939: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #939") } { // sindex/api.yaml line #943 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between(r.minval, [1, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #943: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #943") } { // sindex/api.yaml line #947 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #947: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #947") } { // sindex/api.yaml line #951 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #951: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #951") } { // sindex/api.yaml line #956 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, [0, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #956: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #956") } { // sindex/api.yaml line #960 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, [0, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #960: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #960") } { // sindex/api.yaml line #964 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between(r.minval, [0, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #964: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #964") } { // sindex/api.yaml line #968 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between(r.minval, [0, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #968: table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #968") } { // sindex/api.yaml line #972 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between(r.minval, [1, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #972: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #972") } { // sindex/api.yaml line #976 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between(r.minval, [1, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #976: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #976") } { // sindex/api.yaml line #980 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, [1, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #980: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #980") } { // sindex/api.yaml line #984 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between(r.minval, [1, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #984: table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #984") } { // sindex/api.yaml line #988 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #988: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #988") } { // sindex/api.yaml line #992 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between(r.minval, r.maxval, index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #992: table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(r.MinVal, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #992") } { // sindex/api.yaml line #997 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 0], [0, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #997: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #997") } { // sindex/api.yaml line #1001 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 0], [0, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1001: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1001") } { // sindex/api.yaml line #1005 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between([0, 0], [0, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1005: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1005") } { // sindex/api.yaml line #1009 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between([0, 0], [0, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1009: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1009") } { // sindex/api.yaml line #1013 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between([0, 0], [1, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1013: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1013") } { // sindex/api.yaml line #1017 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between([0, 0], [1, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1017: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1017") } { // sindex/api.yaml line #1021 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between([0, 0], [1, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1021: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1021") } { // sindex/api.yaml line #1025 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between([0, 0], [1, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1025: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1025") } { // sindex/api.yaml line #1029 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between([0, 0], r.maxval, index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1029: table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1029") } { // sindex/api.yaml line #1033 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between([0, 0], r.maxval, index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1033: table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1033") } { // sindex/api.yaml line #1038 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between([0, 0], [0, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1038: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1038") } { // sindex/api.yaml line #1042 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between([0, 0], [0, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1042: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1042") } { // sindex/api.yaml line #1046 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between([0, 0], [0, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1046: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1046") } { // sindex/api.yaml line #1050 /* [0, 1] */ var expected_ []interface{} = []interface{}{0, 1} /* table_test_sindex_api.between([0, 0], [0, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1050: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1050") } { // sindex/api.yaml line #1054 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between([0, 0], [1, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1054: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1054") } { // sindex/api.yaml line #1058 /* [0, 1, 2] */ var expected_ []interface{} = []interface{}{0, 1, 2} /* table_test_sindex_api.between([0, 0], [1, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1058: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1058") } { // sindex/api.yaml line #1062 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between([0, 0], [1, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1062: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1062") } { // sindex/api.yaml line #1066 /* [0, 1, 2, 3] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3} /* table_test_sindex_api.between([0, 0], [1, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1066: table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1066") } { // sindex/api.yaml line #1070 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between([0, 0], r.maxval, index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1070: table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1070") } { // sindex/api.yaml line #1074 /* [0, 1, 2, 3, 4] */ var expected_ []interface{} = []interface{}{0, 1, 2, 3, 4} /* table_test_sindex_api.between([0, 0], r.maxval, index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1074: table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1074") } { // sindex/api.yaml line #1079 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1079: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1079") } { // sindex/api.yaml line #1083 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1083: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1083") } { // sindex/api.yaml line #1087 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1087: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1087") } { // sindex/api.yaml line #1091 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1091: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1091") } { // sindex/api.yaml line #1095 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([0, 1], [1, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1095: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1095") } { // sindex/api.yaml line #1099 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [1, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1099: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1099") } { // sindex/api.yaml line #1103 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([0, 1], [1, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1103: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1103") } { // sindex/api.yaml line #1107 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([0, 1], [1, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1107: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1107") } { // sindex/api.yaml line #1111 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between([0, 1], r.maxval, index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1111: table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1111") } { // sindex/api.yaml line #1115 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between([0, 1], r.maxval, index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1115: table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1115") } { // sindex/api.yaml line #1120 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1120: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1120") } { // sindex/api.yaml line #1124 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1124: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1124") } { // sindex/api.yaml line #1128 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([0, 1], [0, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1128: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1128") } { // sindex/api.yaml line #1132 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([0, 1], [0, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1132: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1132") } { // sindex/api.yaml line #1136 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([0, 1], [1, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1136: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1136") } { // sindex/api.yaml line #1140 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([0, 1], [1, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1140: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1140") } { // sindex/api.yaml line #1144 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.between([0, 1], [1, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1144: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1144") } { // sindex/api.yaml line #1148 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.between([0, 1], [1, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1148: table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1148") } { // sindex/api.yaml line #1152 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between([0, 1], r.maxval, index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1152: table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1152") } { // sindex/api.yaml line #1156 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between([0, 1], r.maxval, index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1156: table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{0, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1156") } { // sindex/api.yaml line #1161 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1161: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1161") } { // sindex/api.yaml line #1165 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1165: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1165") } { // sindex/api.yaml line #1169 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1169: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1169") } { // sindex/api.yaml line #1173 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1173: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1173") } { // sindex/api.yaml line #1177 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [1, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1177: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1177") } { // sindex/api.yaml line #1181 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [1, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1181: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1181") } { // sindex/api.yaml line #1185 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [1, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1185: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1185") } { // sindex/api.yaml line #1189 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([1, 0], [1, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1189: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1189") } { // sindex/api.yaml line #1193 /* [3, 4] */ var expected_ []interface{} = []interface{}{3, 4} /* table_test_sindex_api.between([1, 0], r.maxval, index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1193: table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1193") } { // sindex/api.yaml line #1197 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between([1, 0], r.maxval, index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1197: table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1197") } { // sindex/api.yaml line #1202 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1202: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1202") } { // sindex/api.yaml line #1206 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1206: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1206") } { // sindex/api.yaml line #1210 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1210: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1210") } { // sindex/api.yaml line #1214 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [0, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1214: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1214") } { // sindex/api.yaml line #1218 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 0], [1, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1218: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1218") } { // sindex/api.yaml line #1222 /* [2] */ var expected_ []interface{} = []interface{}{2} /* table_test_sindex_api.between([1, 0], [1, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1222: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1222") } { // sindex/api.yaml line #1226 /* [3] */ var expected_ []interface{} = []interface{}{3} /* table_test_sindex_api.between([1, 0], [1, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1226: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1226") } { // sindex/api.yaml line #1230 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.between([1, 0], [1, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1230: table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1230") } { // sindex/api.yaml line #1234 /* [3, 4] */ var expected_ []interface{} = []interface{}{3, 4} /* table_test_sindex_api.between([1, 0], r.maxval, index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1234: table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1234") } { // sindex/api.yaml line #1238 /* [2, 3, 4] */ var expected_ []interface{} = []interface{}{2, 3, 4} /* table_test_sindex_api.between([1, 0], r.maxval, index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1238: table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 0}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1238") } { // sindex/api.yaml line #1243 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1243: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1243") } { // sindex/api.yaml line #1247 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1247: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1247") } { // sindex/api.yaml line #1251 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1251: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1251") } { // sindex/api.yaml line #1255 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1255: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1255") } { // sindex/api.yaml line #1259 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [1, 0], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1259: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1259") } { // sindex/api.yaml line #1263 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [1, 0], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1263: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1263") } { // sindex/api.yaml line #1267 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [1, 1], index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1267: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1267") } { // sindex/api.yaml line #1271 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [1, 1], index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1271: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1271") } { // sindex/api.yaml line #1275 /* [3, 4] */ var expected_ []interface{} = []interface{}{3, 4} /* table_test_sindex_api.between([1, 1], r.maxval, index='bc').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1275: table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1275") } { // sindex/api.yaml line #1279 /* [3, 4] */ var expected_ []interface{} = []interface{}{3, 4} /* table_test_sindex_api.between([1, 1], r.maxval, index='cb').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1279: table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1279") } { // sindex/api.yaml line #1284 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1284: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1284") } { // sindex/api.yaml line #1288 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1288: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1288") } { // sindex/api.yaml line #1292 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1292: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1292") } { // sindex/api.yaml line #1296 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [0, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1296: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{0, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1296") } { // sindex/api.yaml line #1300 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [1, 0], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1300: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1300") } { // sindex/api.yaml line #1304 /* [] */ var expected_ []interface{} = []interface{}{} /* table_test_sindex_api.between([1, 1], [1, 0], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1304: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 0}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1304") } { // sindex/api.yaml line #1308 /* [3] */ var expected_ []interface{} = []interface{}{3} /* table_test_sindex_api.between([1, 1], [1, 1], index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1308: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1308") } { // sindex/api.yaml line #1312 /* [3] */ var expected_ []interface{} = []interface{}{3} /* table_test_sindex_api.between([1, 1], [1, 1], index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1312: table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, []interface{}{1, 1}).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1312") } { // sindex/api.yaml line #1316 /* [3, 4] */ var expected_ []interface{} = []interface{}{3, 4} /* table_test_sindex_api.between([1, 1], r.maxval, index='bc', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1316: table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'bc', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "bc", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1316") } { // sindex/api.yaml line #1320 /* [3, 4] */ var expected_ []interface{} = []interface{}{3, 4} /* table_test_sindex_api.between([1, 1], r.maxval, index='cb', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1320: table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: 'cb', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between([]interface{}{1, 1}, r.MaxVal).OptArgs(r.BetweenOpts{Index: "cb", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1320") } { // sindex/api.yaml line #1325 /* [0,0,0] */ var expected_ []interface{} = []interface{}{0, 0, 0} /* table_test_sindex_api.between(1, 3, index='mi', right_bound='closed').map(lambda x:x['id']) */ suite.T().Log("About to run line #1325: table_test_sindex_api.Between(1, 3).OptArgs(r.BetweenOpts{Index: 'mi', RightBound: 'closed', }).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, 3).OptArgs(r.BetweenOpts{Index: "mi", RightBound: "closed"}).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1325") } { // sindex/api.yaml line #1330 /* [0,0,0,1,1,1,2,3,3,3,4,4,4] */ var expected_ []interface{} = []interface{}{0, 0, 0, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4} /* table_test_sindex_api.between(1, 16, index='mi', right_bound='closed').order_by('id').map(lambda x:x['id']) */ suite.T().Log("About to run line #1330: table_test_sindex_api.Between(1, 16).OptArgs(r.BetweenOpts{Index: 'mi', RightBound: 'closed', }).OrderBy('id').Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(1, 16).OptArgs(r.BetweenOpts{Index: "mi", RightBound: "closed"}).OrderBy("id").Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1330") } { // sindex/api.yaml line #1335 /* [0,0,0,1,1,1,2,3,3,3,4,4,4] */ var expected_ []interface{} = []interface{}{0, 0, 0, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4} /* table_test_sindex_api.order_by(index='mi').map(lambda x:x['id']) */ suite.T().Log("About to run line #1335: table_test_sindex_api.OrderBy().OptArgs(r.OrderByOpts{Index: 'mi', }).Map(func(x r.Term) interface{} { return x.AtIndex('id')})") runAndAssert(suite.Suite, expected_, table_test_sindex_api.OrderBy().OptArgs(r.OrderByOpts{Index: "mi"}).Map(func(x r.Term) interface{} { return x.AtIndex("id") }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1335") } { // sindex/api.yaml line #1341 /* [2, 3] */ var expected_ []interface{} = []interface{}{2, 3} /* table_test_sindex_api.between(0, 1, index='c', right_bound='closed', left_bound='open').order_by('id')['id'] */ suite.T().Log("About to run line #1341: table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'c', RightBound: 'closed', LeftBound: 'open', }).OrderBy('id').AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: "c", RightBound: "closed", LeftBound: "open"}).OrderBy("id").AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1341") } { // sindex/api.yaml line #1345 /* [1] */ var expected_ []interface{} = []interface{}{1} /* table_test_sindex_api.between(0, 1, index='id', right_bound='closed', left_bound='open').order_by('id')['id'] */ suite.T().Log("About to run line #1345: table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: 'id', RightBound: 'closed', LeftBound: 'open', }).OrderBy('id').AtIndex('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_api.Between(0, 1).OptArgs(r.BetweenOpts{Index: "id", RightBound: "closed", LeftBound: "open"}).OrderBy("id").AtIndex("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #1345") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_sindex_nullsinstrings_test.go000066400000000000000000000124471363464422500315230ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // sindex nulls in strings func TestSindexNullsinstringsSuite(t *testing.T) { suite.Run(t, new(SindexNullsinstringsSuite)) } type SindexNullsinstringsSuite struct { suite.Suite session *r.Session } func (suite *SindexNullsinstringsSuite) SetupTest() { suite.T().Log("Setting up SindexNullsinstringsSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_sindex_null").Exec(suite.session) err = r.DBCreate("db_sindex_null").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sindex_null").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_sindex_null").TableDrop("table_test_sindex_nullstr").Exec(suite.session) err = r.DB("db_sindex_null").TableCreate("table_test_sindex_nullstr").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sindex_null").Table("table_test_sindex_nullstr").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *SindexNullsinstringsSuite) TearDownSuite() { suite.T().Log("Tearing down SindexNullsinstringsSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_sindex_null").TableDrop("table_test_sindex_nullstr").Exec(suite.session) r.DBDrop("db_sindex_null").Exec(suite.session) suite.session.Close() } } func (suite *SindexNullsinstringsSuite) TestCases() { suite.T().Log("Running SindexNullsinstringsSuite: sindex nulls in strings") table_test_sindex_nullstr := r.DB("db_sindex_null").Table("table_test_sindex_nullstr") _ = table_test_sindex_nullstr // Prevent any noused variable errors { // sindex/nullsinstrings.yaml line #4 /* ({"created":1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_nullstr.index_create("key") */ suite.T().Log("About to run line #4: table_test_sindex_nullstr.IndexCreate('key')") runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.IndexCreate("key"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #4") } { // sindex/nullsinstrings.yaml line #6 /* ([{"ready":true}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"ready": true}} /* table_test_sindex_nullstr.index_wait().pluck("ready") */ suite.T().Log("About to run line #6: table_test_sindex_nullstr.IndexWait().Pluck('ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.IndexWait().Pluck("ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #6") } { // sindex/nullsinstrings.yaml line #10 /* ({"inserted":2}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"inserted": 2} /* table_test_sindex_nullstr.insert([{"id":1,"key":["a","b"]},{"id":2,"key":["a\u0000Sb"]}]).pluck("inserted") */ suite.T().Log("About to run line #10: table_test_sindex_nullstr.Insert([]interface{}{map[interface{}]interface{}{'id': 1, 'key': []interface{}{'a', 'b'}, }, map[interface{}]interface{}{'id': 2, 'key': []interface{}{'a\\u0000Sb'}, }}).Pluck('inserted')") runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.Insert([]interface{}{map[interface{}]interface{}{"id": 1, "key": []interface{}{"a", "b"}}, map[interface{}]interface{}{"id": 2, "key": []interface{}{"a\u0000Sb"}}}).Pluck("inserted"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #10") } { // sindex/nullsinstrings.yaml line #13 /* ([{"id":2}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 2}} /* table_test_sindex_nullstr.get_all(["a\u0000Sb"], index="key").pluck("id") */ suite.T().Log("About to run line #13: table_test_sindex_nullstr.GetAll([]interface{}{'a\\u0000Sb'}).OptArgs(r.GetAllOpts{Index: 'key', }).Pluck('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.GetAll([]interface{}{"a\u0000Sb"}).OptArgs(r.GetAllOpts{Index: "key"}).Pluck("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // sindex/nullsinstrings.yaml line #18 /* ([{"id":1}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 1}} /* table_test_sindex_nullstr.get_all(["a","b"], index="key").pluck("id") */ suite.T().Log("About to run line #18: table_test_sindex_nullstr.GetAll([]interface{}{'a', 'b'}).OptArgs(r.GetAllOpts{Index: 'key', }).Pluck('id')") runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.GetAll([]interface{}{"a", "b"}).OptArgs(r.GetAllOpts{Index: "key"}).Pluck("id"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_sindex_status_test.go000066400000000000000000000306671363464422500277540ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // sindex status func TestSindexStatusSuite(t *testing.T) { suite.Run(t, new(SindexStatusSuite)) } type SindexStatusSuite struct { suite.Suite session *r.Session } func (suite *SindexStatusSuite) SetupTest() { suite.T().Log("Setting up SindexStatusSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_sindex_st").Exec(suite.session) err = r.DBCreate("db_sindex_st").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sindex_st").Wait().Exec(suite.session) suite.Require().NoError(err) r.DB("db_sindex_st").TableDrop("table_test_sindex_status2").Exec(suite.session) err = r.DB("db_sindex_st").TableCreate("table_test_sindex_status2").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_sindex_st").Table("table_test_sindex_status2").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *SindexStatusSuite) TearDownSuite() { suite.T().Log("Tearing down SindexStatusSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DB("db_sindex_st").TableDrop("table_test_sindex_status2").Exec(suite.session) r.DBDrop("db_sindex_st").Exec(suite.session) suite.session.Close() } } func (suite *SindexStatusSuite) TestCases() { suite.T().Log("Running SindexStatusSuite: sindex status") table_test_sindex_status2 := r.DB("db_sindex_st").Table("table_test_sindex_status2") _ = table_test_sindex_status2 // Prevent any noused variable errors { // sindex/status.yaml line #7 /* ({'created':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_status2.index_create("a") */ suite.T().Log("About to run line #7: table_test_sindex_status2.IndexCreate('a')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #7") } { // sindex/status.yaml line #9 /* ({'created':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_status2.index_create("b") */ suite.T().Log("About to run line #9: table_test_sindex_status2.IndexCreate('b')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #9") } { // sindex/status.yaml line #12 /* 2 */ var expected_ int = 2 /* table_test_sindex_status2.index_status().count() */ suite.T().Log("About to run line #12: table_test_sindex_status2.IndexStatus().Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus().Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #12") } { // sindex/status.yaml line #14 /* 1 */ var expected_ int = 1 /* table_test_sindex_status2.index_status("a").count() */ suite.T().Log("About to run line #14: table_test_sindex_status2.IndexStatus('a').Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("a").Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // sindex/status.yaml line #16 /* 1 */ var expected_ int = 1 /* table_test_sindex_status2.index_status("b").count() */ suite.T().Log("About to run line #16: table_test_sindex_status2.IndexStatus('b').Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("b").Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #16") } { // sindex/status.yaml line #18 /* 2 */ var expected_ int = 2 /* table_test_sindex_status2.index_status("a", "b").count() */ suite.T().Log("About to run line #18: table_test_sindex_status2.IndexStatus('a', 'b').Count()") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("a", "b").Count(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // sindex/status.yaml line #21 /* ({'dropped':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} /* table_test_sindex_status2.index_drop("a") */ suite.T().Log("About to run line #21: table_test_sindex_status2.IndexDrop('a')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexDrop("a"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // sindex/status.yaml line #23 /* ({'dropped':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} /* table_test_sindex_status2.index_drop("b") */ suite.T().Log("About to run line #23: table_test_sindex_status2.IndexDrop('b')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexDrop("b"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #23") } { // sindex/status.yaml line #28 /* partial({'inserted':5000}) */ var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 5000}) /* table_test_sindex_status2.insert(r.range(0, 5000).map({'a':r.row})) */ suite.T().Log("About to run line #28: table_test_sindex_status2.Insert(r.Range(0, 5000).Map(map[interface{}]interface{}{'a': r.Row, }))") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.Insert(r.Range(0, 5000).Map(map[interface{}]interface{}{"a": r.Row})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #28") } { // sindex/status.yaml line #33 /* ({'created':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_status2.index_create("foo") */ suite.T().Log("About to run line #33: table_test_sindex_status2.IndexCreate('foo')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("foo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #33") } { // sindex/status.yaml line #36 /* ({'created':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_status2.index_create("bar", multi=True) */ suite.T().Log("About to run line #36: table_test_sindex_status2.IndexCreate('bar').OptArgs(r.IndexCreateOpts{Multi: true, })") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("bar").OptArgs(r.IndexCreateOpts{Multi: true}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } { // sindex/status.yaml line #44 /* [true, true] */ var expected_ []interface{} = []interface{}{true, true} /* table_test_sindex_status2.index_status().map(lambda x:x["progress"] < 1) */ suite.T().Log("About to run line #44: table_test_sindex_status2.IndexStatus().Map(func(x r.Term) interface{} { return x.AtIndex('progress').Lt(1)})") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus().Map(func(x r.Term) interface{} { return x.AtIndex("progress").Lt(1) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #44") } { // sindex/status.yaml line #49 /* ([true, true]) */ var expected_ []interface{} = []interface{}{true, true} /* table_test_sindex_status2.index_wait()['ready'] */ suite.T().Log("About to run line #49: table_test_sindex_status2.IndexWait().AtIndex('ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #49") } { // sindex/status.yaml line #54 /* bag([false, false]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{false, false}) /* table_test_sindex_status2.index_wait()['geo'] */ suite.T().Log("About to run line #54: table_test_sindex_status2.IndexWait().AtIndex('geo')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("geo"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #54") } { // sindex/status.yaml line #57 /* bag([false, true]) */ var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{false, true}) /* table_test_sindex_status2.index_wait()['multi'] */ suite.T().Log("About to run line #57: table_test_sindex_status2.IndexWait().AtIndex('multi')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("multi"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #57") } { // sindex/status.yaml line #60 /* ([false, false]) */ var expected_ []interface{} = []interface{}{false, false} /* table_test_sindex_status2.index_wait()['outdated'] */ suite.T().Log("About to run line #60: table_test_sindex_status2.IndexWait().AtIndex('outdated')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("outdated"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // sindex/status.yaml line #63 /* ({'created':1}) */ var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} /* table_test_sindex_status2.index_create("quux") */ suite.T().Log("About to run line #63: table_test_sindex_status2.IndexCreate('quux')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("quux"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #63") } { // sindex/status.yaml line #66 /* true */ var expected_ bool = true /* table_test_sindex_status2.index_status("quux").do(lambda x:(x[0]["index"] == "quux") & (x[0]["progress"] < 1)) */ suite.T().Log("About to run line #66: table_test_sindex_status2.IndexStatus('quux').Do(func(x r.Term) interface{} { return x.AtIndex(0).AtIndex('index').Eq('quux').And(x.AtIndex(0).AtIndex('progress').Lt(1))})") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("quux").Do(func(x r.Term) interface{} { return x.AtIndex(0).AtIndex("index").Eq("quux").And(x.AtIndex(0).AtIndex("progress").Lt(1)) }), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #66") } { // sindex/status.yaml line #71 /* ([{'index':'quux', 'ready':true}]) */ var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"index": "quux", "ready": true}} /* table_test_sindex_status2.index_wait("quux").pluck('index', 'ready') */ suite.T().Log("About to run line #71: table_test_sindex_status2.IndexWait('quux').Pluck('index', 'ready')") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait("quux").Pluck("index", "ready"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #71") } { // sindex/status.yaml line #74 /* ("PTYPE") */ var expected_ string = "PTYPE" /* table_test_sindex_status2.index_wait("quux").nth(0).get_field('function').type_of() */ suite.T().Log("About to run line #74: table_test_sindex_status2.IndexWait('quux').Nth(0).Field('function').TypeOf()") runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait("quux").Nth(0).Field("function").TypeOf(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #74") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_timeout_test.go000066400000000000000000000153361363464422500265410ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // Tests timeouts. func TestTimeoutSuite(t *testing.T) { suite.Run(t, new(TimeoutSuite)) } type TimeoutSuite struct { suite.Suite session *r.Session } func (suite *TimeoutSuite) SetupTest() { suite.T().Log("Setting up TimeoutSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_timeout").Exec(suite.session) err = r.DBCreate("db_timeout").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_timeout").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *TimeoutSuite) TearDownSuite() { suite.T().Log("Tearing down TimeoutSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_timeout").Exec(suite.session) suite.session.Close() } } func (suite *TimeoutSuite) TestCases() { suite.T().Log("Running TimeoutSuite: Tests timeouts.") { // r.JS default timeout is 5 sec // timeout.yaml line #5 /* err("ReqlQueryLogicError", "JavaScript query `while(true) {}` timed out after 5.000 seconds.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "JavaScript query `while(true) {}` timed out after 5.000 seconds.") /* r.js('while(true) {}') */ suite.T().Log("About to run line #5: r.JS('while(true) {}')") runAndAssert(suite.Suite, expected_, r.JS("while(true) {}"), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #5") } { // timeout.yaml line #8 /* err("ReqlQueryLogicError", "JavaScript query `while(true) {}` timed out after 1.300 seconds.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "JavaScript query `while(true) {}` timed out after 1.300 seconds.") /* r.js('while(true) {}', timeout=1.3) */ suite.T().Log("About to run line #8: r.JS('while(true) {}').OptArgs(r.JSOpts{Timeout: 1.3, })") runAndAssert(suite.Suite, expected_, r.JS("while(true) {}").OptArgs(r.JSOpts{Timeout: 1.3}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #8") } { // timeout.yaml line #13 /* err("ReqlQueryLogicError", "JavaScript query `while(true) {}` timed out after 8.000 seconds.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "JavaScript query `while(true) {}` timed out after 8.000 seconds.") /* r.js('while(true) {}', timeout=8) */ suite.T().Log("About to run line #13: r.JS('while(true) {}').OptArgs(r.JSOpts{Timeout: 8, })") runAndAssert(suite.Suite, expected_, r.JS("while(true) {}").OptArgs(r.JSOpts{Timeout: 8}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #13") } { // timeout.yaml line #18 /* err("ReqlQueryLogicError", "JavaScript query `(function(x) { while(true) {} })` timed out after 5.000 seconds.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "JavaScript query `(function(x) { while(true) {} })` timed out after 5.000 seconds.") /* r.expr('foo').do(r.js('(function(x) { while(true) {} })')) */ suite.T().Log("About to run line #18: r.Expr('foo').Do(r.JS('(function(x) { while(true) {} })'))") runAndAssert(suite.Suite, expected_, r.Expr("foo").Do(r.JS("(function(x) { while(true) {} })")), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #18") } { // timeout.yaml line #21 /* err("ReqlQueryLogicError", "JavaScript query `(function(x) { while(true) {} })` timed out after 1.300 seconds.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "JavaScript query `(function(x) { while(true) {} })` timed out after 1.300 seconds.") /* r.expr('foo').do(r.js('(function(x) { while(true) {} })', timeout=1.3)) */ suite.T().Log("About to run line #21: r.Expr('foo').Do(r.JS('(function(x) { while(true) {} })').OptArgs(r.JSOpts{Timeout: 1.3, }))") runAndAssert(suite.Suite, expected_, r.Expr("foo").Do(r.JS("(function(x) { while(true) {} })").OptArgs(r.JSOpts{Timeout: 1.3})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #21") } { // timeout.yaml line #26 /* err("ReqlQueryLogicError", "JavaScript query `(function(x) { while(true) {} })` timed out after 8.000 seconds.", [0]) */ var expected_ Err = err("ReqlQueryLogicError", "JavaScript query `(function(x) { while(true) {} })` timed out after 8.000 seconds.") /* r.expr('foo').do(r.js('(function(x) { while(true) {} })', timeout=8)) */ suite.T().Log("About to run line #26: r.Expr('foo').Do(r.JS('(function(x) { while(true) {} })').OptArgs(r.JSOpts{Timeout: 8, }))") runAndAssert(suite.Suite, expected_, r.Expr("foo").Do(r.JS("(function(x) { while(true) {} })").OptArgs(r.JSOpts{Timeout: 8})), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #26") } { // timeout.yaml line #32 /* err("ReqlNonExistenceError", "Error in HTTP GET of `httpbin.org/delay/10`:" + " timed out after 0.800 seconds.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Error in HTTP GET of `httpbin.org/delay/10`:"+" timed out after 0.800 seconds.") /* r.http('httpbin.org/delay/10', timeout=0.8) */ suite.T().Log("About to run line #32: r.HTTP('httpbin.org/delay/10').OptArgs(r.HTTPOpts{Timeout: 0.8, })") runAndAssert(suite.Suite, expected_, r.HTTP("httpbin.org/delay/10").OptArgs(r.HTTPOpts{Timeout: 0.8}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } { // timeout.yaml line #36 /* err("ReqlNonExistenceError", "Error in HTTP PUT of `httpbin.org/delay/10`:" + " timed out after 0.000 seconds.", []) */ var expected_ Err = err("ReqlNonExistenceError", "Error in HTTP PUT of `httpbin.org/delay/10`:"+" timed out after 0.000 seconds.") /* r.http('httpbin.org/delay/10', method='PUT', timeout=0.0) */ suite.T().Log("About to run line #36: r.HTTP('httpbin.org/delay/10').OptArgs(r.HTTPOpts{Method: 'PUT', Timeout: 0.0, })") runAndAssert(suite.Suite, expected_, r.HTTP("httpbin.org/delay/10").OptArgs(r.HTTPOpts{Method: "PUT", Timeout: 0.0}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #36") } } rethinkdb-go-6.2.1/internal/integration/reql_tests/reql_times_api_test.go000066400000000000000000000507731363464422500270310ustar00rootroot00000000000000// Code generated by gen_tests.py and process_polyglot.py. // Do not edit this file directly. // The template for this file is located at: // ../template.go.tpl package reql_tests import ( "testing" "time" "github.com/stretchr/testify/suite" r "gopkg.in/rethinkdb/rethinkdb-go.v6" "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" ) // date/time api (#977) func TestTimesApiSuite(t *testing.T) { suite.Run(t, new(TimesApiSuite)) } type TimesApiSuite struct { suite.Suite session *r.Session } func (suite *TimesApiSuite) SetupTest() { suite.T().Log("Setting up TimesApiSuite") // Use imports to prevent errors _ = time.Time{} _ = compare.AnythingIsFine session, err := r.Connect(r.ConnectOpts{ Address: url, }) suite.Require().NoError(err, "Error returned when connecting to server") suite.session = session r.DBDrop("db_timesapi").Exec(suite.session) err = r.DBCreate("db_timesapi").Exec(suite.session) suite.Require().NoError(err) err = r.DB("db_timesapi").Wait().Exec(suite.session) suite.Require().NoError(err) } func (suite *TimesApiSuite) TearDownSuite() { suite.T().Log("Tearing down TimesApiSuite") if suite.session != nil { r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) r.DBDrop("db_timesapi").Exec(suite.session) suite.session.Close() } } func (suite *TimesApiSuite) TestCases() { suite.T().Log("Running TimesApiSuite: date/time api (#977)") // times/api.yaml line #6 // rt1 = 1375147296.6812 suite.T().Log("Possibly executing: var rt1 float64 = 1375147296.6812") rt1 := 1375147296.6812 _ = rt1 // Prevent any noused variable errors // times/api.yaml line #7 // t1 = r.epoch_time(rt1) suite.T().Log("Possibly executing: var t1 r.Term = r.EpochTime(rt1)") t1 := r.EpochTime(rt1) _ = t1 // Prevent any noused variable errors // times/api.yaml line #8 // t2 = r.epoch_time(rt1 + 1000) suite.T().Log("Possibly executing: var t2 r.Term = r.EpochTime(r.Add(rt1, 1000))") t2 := r.EpochTime(r.Add(rt1, 1000)) _ = t2 // Prevent any noused variable errors { // times/api.yaml line #11 /* (1375148296.681) */ var expected_ float64 = 1375148296.681 /* (t1 + 1000).to_epoch_time() */ suite.T().Log("About to run line #11: r.Add(t1, 1000).ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Add(t1, 1000).ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #11") } { // times/api.yaml line #14 /* (1375146296.681) */ var expected_ float64 = 1375146296.681 /* (t1 - 1000).to_epoch_time() */ suite.T().Log("About to run line #14: r.Sub(t1, 1000).ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Sub(t1, 1000).ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #14") } { // times/api.yaml line #17 /* 1000 */ var expected_ int = 1000 /* (t1 - (t1 - 1000)) */ suite.T().Log("About to run line #17: r.Sub(t1, r.Sub(t1, 1000))") runAndAssert(suite.Suite, expected_, r.Sub(t1, r.Sub(t1, 1000)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #17") } { // times/api.yaml line #22 /* false */ var expected_ bool = false /* (t1 < t1) */ suite.T().Log("About to run line #22: r.Lt(t1, t1)") runAndAssert(suite.Suite, expected_, r.Lt(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #22") } { // times/api.yaml line #25 /* true */ var expected_ bool = true /* (t1 <= t1) */ suite.T().Log("About to run line #25: r.Le(t1, t1)") runAndAssert(suite.Suite, expected_, r.Le(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #25") } { // times/api.yaml line #29 /* true */ var expected_ bool = true /* (t1 == t1) */ suite.T().Log("About to run line #29: r.Eq(t1, t1)") runAndAssert(suite.Suite, expected_, r.Eq(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #29") } { // times/api.yaml line #32 /* false */ var expected_ bool = false /* (t1 != t1) */ suite.T().Log("About to run line #32: r.Ne(t1, t1)") runAndAssert(suite.Suite, expected_, r.Ne(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #32") } { // times/api.yaml line #34 /* true */ var expected_ bool = true /* (t1 >= t1) */ suite.T().Log("About to run line #34: r.Ge(t1, t1)") runAndAssert(suite.Suite, expected_, r.Ge(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #34") } { // times/api.yaml line #37 /* false */ var expected_ bool = false /* (t1 > t1) */ suite.T().Log("About to run line #37: r.Gt(t1, t1)") runAndAssert(suite.Suite, expected_, r.Gt(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #37") } { // times/api.yaml line #40 /* true */ var expected_ bool = true /* (t1 < t2) */ suite.T().Log("About to run line #40: r.Lt(t1, t2)") runAndAssert(suite.Suite, expected_, r.Lt(t1, t2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #40") } { // times/api.yaml line #43 /* true */ var expected_ bool = true /* (t1 <= t2) */ suite.T().Log("About to run line #43: r.Le(t1, t2)") runAndAssert(suite.Suite, expected_, r.Le(t1, t2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #43") } { // times/api.yaml line #47 /* false */ var expected_ bool = false /* (t1 == t2) */ suite.T().Log("About to run line #47: r.Eq(t1, t2)") runAndAssert(suite.Suite, expected_, r.Eq(t1, t2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #47") } { // times/api.yaml line #50 /* true */ var expected_ bool = true /* (t1 != t2) */ suite.T().Log("About to run line #50: r.Ne(t1, t2)") runAndAssert(suite.Suite, expected_, r.Ne(t1, t2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #50") } { // times/api.yaml line #52 /* false */ var expected_ bool = false /* (t1 >= t2) */ suite.T().Log("About to run line #52: r.Ge(t1, t2)") runAndAssert(suite.Suite, expected_, r.Ge(t1, t2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #52") } { // times/api.yaml line #55 /* false */ var expected_ bool = false /* (t1 > t2) */ suite.T().Log("About to run line #55: r.Gt(t1, t2)") runAndAssert(suite.Suite, expected_, r.Gt(t1, t2), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #55") } { // times/api.yaml line #60 /* true */ var expected_ bool = true /* t1.during(t1, t1 + 1000) */ suite.T().Log("About to run line #60: t1.During(t1, r.Add(t1, 1000))") runAndAssert(suite.Suite, expected_, t1.During(t1, r.Add(t1, 1000)), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #60") } { // times/api.yaml line #64 /* false */ var expected_ bool = false /* t1.during(t1, t1 + 1000, left_bound='open') */ suite.T().Log("About to run line #64: t1.During(t1, r.Add(t1, 1000)).OptArgs(r.DuringOpts{LeftBound: 'open', })") runAndAssert(suite.Suite, expected_, t1.During(t1, r.Add(t1, 1000)).OptArgs(r.DuringOpts{LeftBound: "open"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #64") } { // times/api.yaml line #67 /* false */ var expected_ bool = false /* t1.during(t1, t1) */ suite.T().Log("About to run line #67: t1.During(t1, t1)") runAndAssert(suite.Suite, expected_, t1.During(t1, t1), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #67") } { // times/api.yaml line #70 /* true */ var expected_ bool = true /* t1.during(t1, t1, right_bound='closed') */ suite.T().Log("About to run line #70: t1.During(t1, t1).OptArgs(r.DuringOpts{RightBound: 'closed', })") runAndAssert(suite.Suite, expected_, t1.During(t1, t1).OptArgs(r.DuringOpts{RightBound: "closed"}), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #70") } { // times/api.yaml line #77 /* 1375142400 */ var expected_ int = 1375142400 /* t1.date().to_epoch_time() */ suite.T().Log("About to run line #77: t1.Date().ToEpochTime()") runAndAssert(suite.Suite, expected_, t1.Date().ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #77") } { // times/api.yaml line #79 /* (4896.681) */ var expected_ float64 = 4896.681 /* t1.time_of_day() */ suite.T().Log("About to run line #79: t1.TimeOfDay()") runAndAssert(suite.Suite, expected_, t1.TimeOfDay(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #79") } { // times/api.yaml line #81 /* 2013 */ var expected_ int = 2013 /* t1.year() */ suite.T().Log("About to run line #81: t1.Year()") runAndAssert(suite.Suite, expected_, t1.Year(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #81") } { // times/api.yaml line #83 /* 7 */ var expected_ int = 7 /* t1.month() */ suite.T().Log("About to run line #83: t1.Month()") runAndAssert(suite.Suite, expected_, t1.Month(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #83") } { // times/api.yaml line #85 /* 30 */ var expected_ int = 30 /* t1.day() */ suite.T().Log("About to run line #85: t1.Day()") runAndAssert(suite.Suite, expected_, t1.Day(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #85") } { // times/api.yaml line #87 /* 2 */ var expected_ int = 2 /* t1.day_of_week() */ suite.T().Log("About to run line #87: t1.DayOfWeek()") runAndAssert(suite.Suite, expected_, t1.DayOfWeek(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #87") } { // times/api.yaml line #89 /* 211 */ var expected_ int = 211 /* t1.day_of_year() */ suite.T().Log("About to run line #89: t1.DayOfYear()") runAndAssert(suite.Suite, expected_, t1.DayOfYear(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #89") } { // times/api.yaml line #91 /* 1 */ var expected_ int = 1 /* t1.hours() */ suite.T().Log("About to run line #91: t1.Hours()") runAndAssert(suite.Suite, expected_, t1.Hours(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #91") } { // times/api.yaml line #93 /* 21 */ var expected_ int = 21 /* t1.minutes() */ suite.T().Log("About to run line #93: t1.Minutes()") runAndAssert(suite.Suite, expected_, t1.Minutes(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #93") } { // times/api.yaml line #95 /* 36.681 */ var expected_ float64 = 36.681 /* t1.seconds() */ suite.T().Log("About to run line #95: t1.Seconds()") runAndAssert(suite.Suite, expected_, t1.Seconds(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #95") } { // times/api.yaml line #99 /* (1375165800.1) */ var expected_ float64 = 1375165800.1 /* r.time(2013, r.july, 29, 23, 30, 0.1, "-07:00").to_epoch_time() */ suite.T().Log("About to run line #99: r.Time(2013, r.July, 29, 23, 30, 0.1, '-07:00').ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1, "-07:00").ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #99") } { // times/api.yaml line #101 /* ("-07:00") */ var expected_ string = "-07:00" /* r.time(2013, r.july, 29, 23, 30, 0.1, "-07:00").timezone() */ suite.T().Log("About to run line #101: r.Time(2013, r.July, 29, 23, 30, 0.1, '-07:00').Timezone()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1, "-07:00").Timezone(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #101") } { // times/api.yaml line #103 /* err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).") /* r.time(2013, r.july, 29, 23, 30, 0.1).to_epoch_time() */ suite.T().Log("About to run line #103: r.Time(2013, r.July, 29, 23, 30, 0.1).ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1).ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #103") } { // times/api.yaml line #105 /* err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Got 6 arguments to TIME (expected 4 or 7).") /* r.time(2013, r.july, 29, 23, 30, 0.1).timezone() */ suite.T().Log("About to run line #105: r.Time(2013, r.July, 29, 23, 30, 0.1).Timezone()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30, 0.1).Timezone(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #105") } { // times/api.yaml line #107 /* err("ReqlQueryLogicError", "Got 5 arguments to TIME (expected 4 or 7).", []) */ var expected_ Err = err("ReqlQueryLogicError", "Got 5 arguments to TIME (expected 4 or 7).") /* r.time(2013, r.july, 29, 23, 30).to_epoch_time() */ suite.T().Log("About to run line #107: r.Time(2013, r.July, 29, 23, 30).ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23, 30).ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #107") } { // times/api.yaml line #109 /* err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.", []) */ var expected_ Err = err("ReqlQueryLogicError", "Expected type STRING but found NUMBER.") /* r.time(2013, r.july, 29, 23).to_epoch_time() */ suite.T().Log("About to run line #109: r.Time(2013, r.July, 29, 23).ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, 23).ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #109") } { // times/api.yaml line #111 /* 1375081200 */ var expected_ int = 1375081200 /* r.time(2013, r.july, 29, "-07:00").to_epoch_time() */ suite.T().Log("About to run line #111: r.Time(2013, r.July, 29, '-07:00').ToEpochTime()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, "-07:00").ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #111") } { // times/api.yaml line #113 /* ("-07:00") */ var expected_ string = "-07:00" /* r.time(2013, r.july, 29, "-07:00").timezone() */ suite.T().Log("About to run line #113: r.Time(2013, r.July, 29, '-07:00').Timezone()") runAndAssert(suite.Suite, expected_, r.Time(2013, r.July, 29, "-07:00").Timezone(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #113") } { // times/api.yaml line #119 /* 1375242965 */ var expected_ int = 1375242965 /* r.iso8601("2013-07-30T20:56:05-07:00").to_epoch_time() */ suite.T().Log("About to run line #119: r.ISO8601('2013-07-30T20:56:05-07:00').ToEpochTime()") runAndAssert(suite.Suite, expected_, r.ISO8601("2013-07-30T20:56:05-07:00").ToEpochTime(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #119") } { // times/api.yaml line #122 /* ("2013-07-30T20:56:05-07:00") */ var expected_ string = "2013-07-30T20:56:05-07:00" /* r.epoch_time(1375242965).in_timezone("-07:00").to_iso8601() */ suite.T().Log("About to run line #122: r.EpochTime(1375242965).InTimezone('-07:00').ToISO8601()") runAndAssert(suite.Suite, expected_, r.EpochTime(1375242965).InTimezone("-07:00").ToISO8601(), suite.session, r.RunOpts{ GeometryFormat: "raw", GroupFormat: "map", }) suite.T().Log("Finished running line #122") } { // times/api.yaml line #125 /* ("PTYPE