| 1 | // Code generated by gen_tests.py and process_polyglot.py. |
| 2 | // Do not edit this file directly. |
| 3 | // The template for this file is located at: |
| 4 | // ../template.go.tpl |
| 5 | package reql_tests |
| 6 | |
| 7 | import ( |
| 8 | "testing" |
| 9 | "time" |
| 10 | |
| 11 | "github.com/stretchr/testify/suite" |
| 12 | r "gopkg.in/rethinkdb/rethinkdb-go.v6" |
| 13 | "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare" |
| 14 | ) |
| 15 | |
| 16 | // Test changefeeds on a table |
| 17 | func TestChangefeedsTableSuite(t *testing.T) { |
| 18 | suite.Run(t, new(ChangefeedsTableSuite)) |
| 19 | } |
| 20 | |
| 21 | type ChangefeedsTableSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *ChangefeedsTableSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up ChangefeedsTableSuite") |
| 29 | // Use imports to prevent errors |
| 30 | _ = time.Time{} |
| 31 | _ = compare.AnythingIsFine |
| 32 | |
| 33 | session, err := r.Connect(r.ConnectOpts{ |
| 34 | Address: url, |
| 35 | }) |
| 36 | suite.Require().NoError(err, "Error returned when connecting to server") |
| 37 | suite.session = session |
| 38 | |
| 39 | r.DBDrop("db_feed_table").Exec(suite.session) |
| 40 | err = r.DBCreate("db_feed_table").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_feed_table").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | r.DB("db_feed_table").TableDrop("table_test_changefeed_table").Exec(suite.session) |
| 46 | err = r.DB("db_feed_table").TableCreate("table_test_changefeed_table").Exec(suite.session) |
| 47 | suite.Require().NoError(err) |
| 48 | err = r.DB("db_feed_table").Table("table_test_changefeed_table").Wait().Exec(suite.session) |
| 49 | suite.Require().NoError(err) |
| 50 | } |
| 51 | |
| 52 | func (suite *ChangefeedsTableSuite) TearDownSuite() { |
| 53 | suite.T().Log("Tearing down ChangefeedsTableSuite") |
| 54 | |
| 55 | if suite.session != nil { |
| 56 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 57 | r.DB("db_feed_table").TableDrop("table_test_changefeed_table").Exec(suite.session) |
| 58 | r.DBDrop("db_feed_table").Exec(suite.session) |
| 59 | |
| 60 | suite.session.Close() |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (suite *ChangefeedsTableSuite) TestCases() { |
| 65 | suite.T().Log("Running ChangefeedsTableSuite: Test changefeeds on a table") |
| 66 | |
| 67 | table_test_changefeed_table := r.DB("db_feed_table").Table("table_test_changefeed_table") |
| 68 | _ = table_test_changefeed_table // Prevent any noused variable errors |
| 69 | |
| 70 | // changefeeds/table.yaml line #9 |
| 71 | // all = table_test_changefeed_table.changes() |
| 72 | suite.T().Log("Possibly executing: var all r.Term = table_test_changefeed_table.Changes()") |
| 73 | |
| 74 | all := maybeRun(table_test_changefeed_table.Changes(), suite.session, r.RunOpts{}) |
| 75 | _ = all // Prevent any noused variable errors |
| 76 | |
| 77 | { |
| 78 | // changefeeds/table.yaml line #15 |
| 79 | /* partial({'errors':0, 'inserted':2}) */ |
| 80 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 2}) |
| 81 | /* table_test_changefeed_table.insert([{'id':1}, {'id':2}]) */ |
| 82 | |
| 83 | suite.T().Log("About to run line #15: table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 1, }, map[interface{}]interface{}{'id': 2, }})") |
| 84 | |
| 85 | runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 1}, map[interface{}]interface{}{"id": 2}}), suite.session, r.RunOpts{ |
| 86 | GeometryFormat: "raw", |
| 87 | GroupFormat: "map", |
| 88 | }) |
| 89 | suite.T().Log("Finished running line #15") |
| 90 | } |
| 91 | |
| 92 | { |
| 93 | // changefeeds/table.yaml line #17 |
| 94 | /* bag([{'old_val':null, 'new_val':{'id':1}}, {'old_val':null, 'new_val':{'id':2}}]) */ |
| 95 | 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}}}) |
| 96 | /* fetch(all, 2) */ |
| 97 | |
| 98 | suite.T().Log("About to run line #17: fetch(all, 2)") |
| 99 | |
| 100 | fetchAndAssert(suite.Suite, expected_, all, 2) |
| 101 | suite.T().Log("Finished running line #17") |
| 102 | } |
| 103 | |
| 104 | { |
| 105 | // changefeeds/table.yaml line #22 |
| 106 | /* partial({'errors':0, 'replaced':1}) */ |
| 107 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) |
| 108 | /* table_test_changefeed_table.get(1).update({'version':1}) */ |
| 109 | |
| 110 | suite.T().Log("About to run line #22: table_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{'version': 1, })") |
| 111 | |
| 112 | runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{"version": 1}), suite.session, r.RunOpts{ |
| 113 | GeometryFormat: "raw", |
| 114 | GroupFormat: "map", |
| 115 | }) |
| 116 | suite.T().Log("Finished running line #22") |
| 117 | } |
| 118 | |
| 119 | { |
| 120 | // changefeeds/table.yaml line #24 |
| 121 | /* [{'old_val':{'id':1}, 'new_val':{'id':1, 'version':1}}] */ |
| 122 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "version": 1}}} |
| 123 | /* fetch(all, 1) */ |
| 124 | |
| 125 | suite.T().Log("About to run line #24: fetch(all, 1)") |
| 126 | |
| 127 | fetchAndAssert(suite.Suite, expected_, all, 1) |
| 128 | suite.T().Log("Finished running line #24") |
| 129 | } |
| 130 | |
| 131 | { |
| 132 | // changefeeds/table.yaml line #29 |
| 133 | /* partial({'errors':0, 'deleted':1}) */ |
| 134 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "deleted": 1}) |
| 135 | /* table_test_changefeed_table.get(1).delete() */ |
| 136 | |
| 137 | suite.T().Log("About to run line #29: table_test_changefeed_table.Get(1).Delete()") |
| 138 | |
| 139 | runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Get(1).Delete(), suite.session, r.RunOpts{ |
| 140 | GeometryFormat: "raw", |
| 141 | GroupFormat: "map", |
| 142 | }) |
| 143 | suite.T().Log("Finished running line #29") |
| 144 | } |
| 145 | |
| 146 | { |
| 147 | // changefeeds/table.yaml line #31 |
| 148 | /* [{'old_val':{'id':1, 'version':1}, 'new_val':null}] */ |
| 149 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1, "version": 1}, "new_val": nil}} |
| 150 | /* fetch(all, 1) */ |
| 151 | |
| 152 | suite.T().Log("About to run line #31: fetch(all, 1)") |
| 153 | |
| 154 | fetchAndAssert(suite.Suite, expected_, all, 1) |
| 155 | suite.T().Log("Finished running line #31") |
| 156 | } |
| 157 | |
| 158 | // changefeeds/table.yaml line #36 |
| 159 | // pluck = table_test_changefeed_table.changes().pluck({'new_val':['version']}) |
| 160 | suite.T().Log("Possibly executing: var pluck r.Term = table_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{'new_val': []interface{}{'version'}, })") |
| 161 | |
| 162 | pluck := maybeRun(table_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{"new_val": []interface{}{"version"}}), suite.session, r.RunOpts{}) |
| 163 | _ = pluck // Prevent any noused variable errors |
| 164 | |
| 165 | { |
| 166 | // changefeeds/table.yaml line #37 |
| 167 | /* partial({'errors':0, 'inserted':1}) */ |
| 168 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) |
| 169 | /* table_test_changefeed_table.insert([{'id':5, 'version':5}]) */ |
| 170 | |
| 171 | suite.T().Log("About to run line #37: table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 5, 'version': 5, }})") |
| 172 | |
| 173 | runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 5, "version": 5}}), suite.session, r.RunOpts{ |
| 174 | GeometryFormat: "raw", |
| 175 | GroupFormat: "map", |
| 176 | }) |
| 177 | suite.T().Log("Finished running line #37") |
| 178 | } |
| 179 | |
| 180 | { |
| 181 | // changefeeds/table.yaml line #39 |
| 182 | /* [{'new_val':{'version':5}}] */ |
| 183 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"version": 5}}} |
| 184 | /* fetch(pluck, 1) */ |
| 185 | |
| 186 | suite.T().Log("About to run line #39: fetch(pluck, 1)") |
| 187 | |
| 188 | fetchAndAssert(suite.Suite, expected_, pluck, 1) |
| 189 | suite.T().Log("Finished running line #39") |
| 190 | } |
| 191 | |
| 192 | { |
| 193 | // changefeeds/table.yaml line #44 |
| 194 | /* err('ReqlQueryLogicError', "Cannot call a terminal (`reduce`, `count`, etc.) on an infinite stream (such as a changefeed).") */ |
| 195 | var expected_ Err = err("ReqlQueryLogicError", "Cannot call a terminal (`reduce`, `count`, etc.) on an infinite stream (such as a changefeed).") |
| 196 | /* table_test_changefeed_table.changes().order_by('id') */ |
| 197 | |
| 198 | suite.T().Log("About to run line #44: table_test_changefeed_table.Changes().OrderBy('id')") |
| 199 | |
| 200 | runAndAssert(suite.Suite, expected_, table_test_changefeed_table.Changes().OrderBy("id"), suite.session, r.RunOpts{ |
| 201 | GeometryFormat: "raw", |
| 202 | GroupFormat: "map", |
| 203 | }) |
| 204 | suite.T().Log("Finished running line #44") |
| 205 | } |
| 206 | |
| 207 | // changefeeds/table.yaml line #59 |
| 208 | // overflow = table_test_changefeed_table.changes(changefeed_queue_size=100) |
| 209 | suite.T().Log("Possibly executing: var overflow r.Term = table_test_changefeed_table.Changes().OptArgs(r.ChangesOpts{ChangefeedQueueSize: 100, })") |
| 210 | |
| 211 | overflow := maybeRun(table_test_changefeed_table.Changes().OptArgs(r.ChangesOpts{ChangefeedQueueSize: 100}), suite.session, r.RunOpts{}) |
| 212 | _ = overflow // Prevent any noused variable errors |
| 213 | |
| 214 | { |
| 215 | // changefeeds/table.yaml line #62 |
| 216 | /* AnythingIsFine */ |
| 217 | var expected_ string = compare.AnythingIsFine |
| 218 | /* table_test_changefeed_table.insert(r.range(200).map(lambda x: {})) */ |
| 219 | |
| 220 | 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{}{}}))") |
| 221 | |
| 222 | 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{ |
| 223 | GeometryFormat: "raw", |
| 224 | GroupFormat: "map", |
| 225 | }) |
| 226 | suite.T().Log("Finished running line #62") |
| 227 | } |
| 228 | |
| 229 | { |
| 230 | // changefeeds/table.yaml line #64 |
| 231 | /* partial([{'error': regex('Changefeed cache over array size limit, skipped \d+ elements.')}]) */ |
| 232 | var expected_ compare.Expected = compare.PartialMatch([]interface{}{map[interface{}]interface{}{"error": compare.MatchesRegexp("Changefeed cache over array size limit, skipped \\d+ elements.")}}) |
| 233 | /* fetch(overflow, 90) */ |
| 234 | |
| 235 | suite.T().Log("About to run line #64: fetch(overflow, 90)") |
| 236 | |
| 237 | fetchAndAssert(suite.Suite, expected_, overflow, 90) |
| 238 | suite.T().Log("Finished running line #64") |
| 239 | } |
| 240 | |
| 241 | // changefeeds/table.yaml line #69 |
| 242 | // vtable_test_changefeed_table = r.db('rethinkdb').table('_debug_scratch') |
| 243 | suite.T().Log("Possibly executing: var vtable_test_changefeed_table r.Term = r.DB('rethinkdb').Table('_debug_scratch')") |
| 244 | |
| 245 | vtable_test_changefeed_table := r.DB("rethinkdb").Table("_debug_scratch") |
| 246 | _ = vtable_test_changefeed_table // Prevent any noused variable errors |
| 247 | |
| 248 | // changefeeds/table.yaml line #70 |
| 249 | // allVirtual = vtable_test_changefeed_table.changes() |
| 250 | suite.T().Log("Possibly executing: var allVirtual r.Term = vtable_test_changefeed_table.Changes()") |
| 251 | |
| 252 | allVirtual := maybeRun(vtable_test_changefeed_table.Changes(), suite.session, r.RunOpts{}) |
| 253 | _ = allVirtual // Prevent any noused variable errors |
| 254 | |
| 255 | { |
| 256 | // changefeeds/table.yaml line #74 |
| 257 | /* partial({'errors':0, 'inserted':2}) */ |
| 258 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 2}) |
| 259 | /* vtable_test_changefeed_table.insert([{'id':1}, {'id':2}]) */ |
| 260 | |
| 261 | suite.T().Log("About to run line #74: vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 1, }, map[interface{}]interface{}{'id': 2, }})") |
| 262 | |
| 263 | runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 1}, map[interface{}]interface{}{"id": 2}}), suite.session, r.RunOpts{ |
| 264 | GeometryFormat: "raw", |
| 265 | GroupFormat: "map", |
| 266 | }) |
| 267 | suite.T().Log("Finished running line #74") |
| 268 | } |
| 269 | |
| 270 | { |
| 271 | // changefeeds/table.yaml line #76 |
| 272 | /* bag([{'old_val':null, 'new_val':{'id':1}}, {'old_val':null, 'new_val':{'id':2}}]) */ |
| 273 | 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}}}) |
| 274 | /* fetch(allVirtual, 2) */ |
| 275 | |
| 276 | suite.T().Log("About to run line #76: fetch(allVirtual, 2)") |
| 277 | |
| 278 | fetchAndAssert(suite.Suite, expected_, allVirtual, 2) |
| 279 | suite.T().Log("Finished running line #76") |
| 280 | } |
| 281 | |
| 282 | { |
| 283 | // changefeeds/table.yaml line #81 |
| 284 | /* partial({'errors':0, 'replaced':1}) */ |
| 285 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "replaced": 1}) |
| 286 | /* vtable_test_changefeed_table.get(1).update({'version':1}) */ |
| 287 | |
| 288 | suite.T().Log("About to run line #81: vtable_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{'version': 1, })") |
| 289 | |
| 290 | runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Get(1).Update(map[interface{}]interface{}{"version": 1}), suite.session, r.RunOpts{ |
| 291 | GeometryFormat: "raw", |
| 292 | GroupFormat: "map", |
| 293 | }) |
| 294 | suite.T().Log("Finished running line #81") |
| 295 | } |
| 296 | |
| 297 | { |
| 298 | // changefeeds/table.yaml line #83 |
| 299 | /* [{'old_val':{'id':1}, 'new_val':{'id':1, 'version':1}}] */ |
| 300 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1}, "new_val": map[interface{}]interface{}{"id": 1, "version": 1}}} |
| 301 | /* fetch(allVirtual, 1) */ |
| 302 | |
| 303 | suite.T().Log("About to run line #83: fetch(allVirtual, 1)") |
| 304 | |
| 305 | fetchAndAssert(suite.Suite, expected_, allVirtual, 1) |
| 306 | suite.T().Log("Finished running line #83") |
| 307 | } |
| 308 | |
| 309 | { |
| 310 | // changefeeds/table.yaml line #88 |
| 311 | /* partial({'errors':0, 'deleted':1}) */ |
| 312 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "deleted": 1}) |
| 313 | /* vtable_test_changefeed_table.get(1).delete() */ |
| 314 | |
| 315 | suite.T().Log("About to run line #88: vtable_test_changefeed_table.Get(1).Delete()") |
| 316 | |
| 317 | runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Get(1).Delete(), suite.session, r.RunOpts{ |
| 318 | GeometryFormat: "raw", |
| 319 | GroupFormat: "map", |
| 320 | }) |
| 321 | suite.T().Log("Finished running line #88") |
| 322 | } |
| 323 | |
| 324 | { |
| 325 | // changefeeds/table.yaml line #90 |
| 326 | /* [{'old_val':{'id':1, 'version':1}, 'new_val':null}] */ |
| 327 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 1, "version": 1}, "new_val": nil}} |
| 328 | /* fetch(allVirtual, 1) */ |
| 329 | |
| 330 | suite.T().Log("About to run line #90: fetch(allVirtual, 1)") |
| 331 | |
| 332 | fetchAndAssert(suite.Suite, expected_, allVirtual, 1) |
| 333 | suite.T().Log("Finished running line #90") |
| 334 | } |
| 335 | |
| 336 | // changefeeds/table.yaml line #95 |
| 337 | // vpluck = vtable_test_changefeed_table.changes().pluck({'new_val':['version']}) |
| 338 | suite.T().Log("Possibly executing: var vpluck r.Term = vtable_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{'new_val': []interface{}{'version'}, })") |
| 339 | |
| 340 | vpluck := maybeRun(vtable_test_changefeed_table.Changes().Pluck(map[interface{}]interface{}{"new_val": []interface{}{"version"}}), suite.session, r.RunOpts{}) |
| 341 | _ = vpluck // Prevent any noused variable errors |
| 342 | |
| 343 | { |
| 344 | // changefeeds/table.yaml line #96 |
| 345 | /* partial({'errors':0, 'inserted':1}) */ |
| 346 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 1}) |
| 347 | /* vtable_test_changefeed_table.insert([{'id':5, 'version':5}]) */ |
| 348 | |
| 349 | suite.T().Log("About to run line #96: vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{'id': 5, 'version': 5, }})") |
| 350 | |
| 351 | runAndAssert(suite.Suite, expected_, vtable_test_changefeed_table.Insert([]interface{}{map[interface{}]interface{}{"id": 5, "version": 5}}), suite.session, r.RunOpts{ |
| 352 | GeometryFormat: "raw", |
| 353 | GroupFormat: "map", |
| 354 | }) |
| 355 | suite.T().Log("Finished running line #96") |
| 356 | } |
| 357 | |
| 358 | { |
| 359 | // changefeeds/table.yaml line #98 |
| 360 | /* [{'new_val':{'version':5}}] */ |
| 361 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"version": 5}}} |
| 362 | /* fetch(vpluck, 1) */ |
| 363 | |
| 364 | suite.T().Log("About to run line #98: fetch(vpluck, 1)") |
| 365 | |
| 366 | fetchAndAssert(suite.Suite, expected_, vpluck, 1) |
| 367 | suite.T().Log("Finished running line #98") |
| 368 | } |
| 369 | } |