| 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 | // sindex status |
| 17 | func TestSindexStatusSuite(t *testing.T) { |
| 18 | suite.Run(t, new(SindexStatusSuite)) |
| 19 | } |
| 20 | |
| 21 | type SindexStatusSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *SindexStatusSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up SindexStatusSuite") |
| 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_sindex_st").Exec(suite.session) |
| 40 | err = r.DBCreate("db_sindex_st").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_sindex_st").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | r.DB("db_sindex_st").TableDrop("table_test_sindex_status2").Exec(suite.session) |
| 46 | err = r.DB("db_sindex_st").TableCreate("table_test_sindex_status2").Exec(suite.session) |
| 47 | suite.Require().NoError(err) |
| 48 | err = r.DB("db_sindex_st").Table("table_test_sindex_status2").Wait().Exec(suite.session) |
| 49 | suite.Require().NoError(err) |
| 50 | } |
| 51 | |
| 52 | func (suite *SindexStatusSuite) TearDownSuite() { |
| 53 | suite.T().Log("Tearing down SindexStatusSuite") |
| 54 | |
| 55 | if suite.session != nil { |
| 56 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 57 | r.DB("db_sindex_st").TableDrop("table_test_sindex_status2").Exec(suite.session) |
| 58 | r.DBDrop("db_sindex_st").Exec(suite.session) |
| 59 | |
| 60 | suite.session.Close() |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (suite *SindexStatusSuite) TestCases() { |
| 65 | suite.T().Log("Running SindexStatusSuite: sindex status") |
| 66 | |
| 67 | table_test_sindex_status2 := r.DB("db_sindex_st").Table("table_test_sindex_status2") |
| 68 | _ = table_test_sindex_status2 // Prevent any noused variable errors |
| 69 | |
| 70 | { |
| 71 | // sindex/status.yaml line #7 |
| 72 | /* ({'created':1}) */ |
| 73 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 74 | /* table_test_sindex_status2.index_create("a") */ |
| 75 | |
| 76 | suite.T().Log("About to run line #7: table_test_sindex_status2.IndexCreate('a')") |
| 77 | |
| 78 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("a"), suite.session, r.RunOpts{ |
| 79 | GeometryFormat: "raw", |
| 80 | GroupFormat: "map", |
| 81 | }) |
| 82 | suite.T().Log("Finished running line #7") |
| 83 | } |
| 84 | |
| 85 | { |
| 86 | // sindex/status.yaml line #9 |
| 87 | /* ({'created':1}) */ |
| 88 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 89 | /* table_test_sindex_status2.index_create("b") */ |
| 90 | |
| 91 | suite.T().Log("About to run line #9: table_test_sindex_status2.IndexCreate('b')") |
| 92 | |
| 93 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("b"), suite.session, r.RunOpts{ |
| 94 | GeometryFormat: "raw", |
| 95 | GroupFormat: "map", |
| 96 | }) |
| 97 | suite.T().Log("Finished running line #9") |
| 98 | } |
| 99 | |
| 100 | { |
| 101 | // sindex/status.yaml line #12 |
| 102 | /* 2 */ |
| 103 | var expected_ int = 2 |
| 104 | /* table_test_sindex_status2.index_status().count() */ |
| 105 | |
| 106 | suite.T().Log("About to run line #12: table_test_sindex_status2.IndexStatus().Count()") |
| 107 | |
| 108 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus().Count(), suite.session, r.RunOpts{ |
| 109 | GeometryFormat: "raw", |
| 110 | GroupFormat: "map", |
| 111 | }) |
| 112 | suite.T().Log("Finished running line #12") |
| 113 | } |
| 114 | |
| 115 | { |
| 116 | // sindex/status.yaml line #14 |
| 117 | /* 1 */ |
| 118 | var expected_ int = 1 |
| 119 | /* table_test_sindex_status2.index_status("a").count() */ |
| 120 | |
| 121 | suite.T().Log("About to run line #14: table_test_sindex_status2.IndexStatus('a').Count()") |
| 122 | |
| 123 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("a").Count(), suite.session, r.RunOpts{ |
| 124 | GeometryFormat: "raw", |
| 125 | GroupFormat: "map", |
| 126 | }) |
| 127 | suite.T().Log("Finished running line #14") |
| 128 | } |
| 129 | |
| 130 | { |
| 131 | // sindex/status.yaml line #16 |
| 132 | /* 1 */ |
| 133 | var expected_ int = 1 |
| 134 | /* table_test_sindex_status2.index_status("b").count() */ |
| 135 | |
| 136 | suite.T().Log("About to run line #16: table_test_sindex_status2.IndexStatus('b').Count()") |
| 137 | |
| 138 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("b").Count(), suite.session, r.RunOpts{ |
| 139 | GeometryFormat: "raw", |
| 140 | GroupFormat: "map", |
| 141 | }) |
| 142 | suite.T().Log("Finished running line #16") |
| 143 | } |
| 144 | |
| 145 | { |
| 146 | // sindex/status.yaml line #18 |
| 147 | /* 2 */ |
| 148 | var expected_ int = 2 |
| 149 | /* table_test_sindex_status2.index_status("a", "b").count() */ |
| 150 | |
| 151 | suite.T().Log("About to run line #18: table_test_sindex_status2.IndexStatus('a', 'b').Count()") |
| 152 | |
| 153 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("a", "b").Count(), suite.session, r.RunOpts{ |
| 154 | GeometryFormat: "raw", |
| 155 | GroupFormat: "map", |
| 156 | }) |
| 157 | suite.T().Log("Finished running line #18") |
| 158 | } |
| 159 | |
| 160 | { |
| 161 | // sindex/status.yaml line #21 |
| 162 | /* ({'dropped':1}) */ |
| 163 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} |
| 164 | /* table_test_sindex_status2.index_drop("a") */ |
| 165 | |
| 166 | suite.T().Log("About to run line #21: table_test_sindex_status2.IndexDrop('a')") |
| 167 | |
| 168 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexDrop("a"), suite.session, r.RunOpts{ |
| 169 | GeometryFormat: "raw", |
| 170 | GroupFormat: "map", |
| 171 | }) |
| 172 | suite.T().Log("Finished running line #21") |
| 173 | } |
| 174 | |
| 175 | { |
| 176 | // sindex/status.yaml line #23 |
| 177 | /* ({'dropped':1}) */ |
| 178 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"dropped": 1} |
| 179 | /* table_test_sindex_status2.index_drop("b") */ |
| 180 | |
| 181 | suite.T().Log("About to run line #23: table_test_sindex_status2.IndexDrop('b')") |
| 182 | |
| 183 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexDrop("b"), suite.session, r.RunOpts{ |
| 184 | GeometryFormat: "raw", |
| 185 | GroupFormat: "map", |
| 186 | }) |
| 187 | suite.T().Log("Finished running line #23") |
| 188 | } |
| 189 | |
| 190 | { |
| 191 | // sindex/status.yaml line #28 |
| 192 | /* partial({'inserted':5000}) */ |
| 193 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 5000}) |
| 194 | /* table_test_sindex_status2.insert(r.range(0, 5000).map({'a':r.row})) */ |
| 195 | |
| 196 | suite.T().Log("About to run line #28: table_test_sindex_status2.Insert(r.Range(0, 5000).Map(map[interface{}]interface{}{'a': r.Row, }))") |
| 197 | |
| 198 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.Insert(r.Range(0, 5000).Map(map[interface{}]interface{}{"a": r.Row})), suite.session, r.RunOpts{ |
| 199 | GeometryFormat: "raw", |
| 200 | GroupFormat: "map", |
| 201 | }) |
| 202 | suite.T().Log("Finished running line #28") |
| 203 | } |
| 204 | |
| 205 | { |
| 206 | // sindex/status.yaml line #33 |
| 207 | /* ({'created':1}) */ |
| 208 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 209 | /* table_test_sindex_status2.index_create("foo") */ |
| 210 | |
| 211 | suite.T().Log("About to run line #33: table_test_sindex_status2.IndexCreate('foo')") |
| 212 | |
| 213 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("foo"), suite.session, r.RunOpts{ |
| 214 | GeometryFormat: "raw", |
| 215 | GroupFormat: "map", |
| 216 | }) |
| 217 | suite.T().Log("Finished running line #33") |
| 218 | } |
| 219 | |
| 220 | { |
| 221 | // sindex/status.yaml line #36 |
| 222 | /* ({'created':1}) */ |
| 223 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 224 | /* table_test_sindex_status2.index_create("bar", multi=True) */ |
| 225 | |
| 226 | suite.T().Log("About to run line #36: table_test_sindex_status2.IndexCreate('bar').OptArgs(r.IndexCreateOpts{Multi: true, })") |
| 227 | |
| 228 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("bar").OptArgs(r.IndexCreateOpts{Multi: true}), suite.session, r.RunOpts{ |
| 229 | GeometryFormat: "raw", |
| 230 | GroupFormat: "map", |
| 231 | }) |
| 232 | suite.T().Log("Finished running line #36") |
| 233 | } |
| 234 | |
| 235 | { |
| 236 | // sindex/status.yaml line #44 |
| 237 | /* [true, true] */ |
| 238 | var expected_ []interface{} = []interface{}{true, true} |
| 239 | /* table_test_sindex_status2.index_status().map(lambda x:x["progress"] < 1) */ |
| 240 | |
| 241 | 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)})") |
| 242 | |
| 243 | 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{ |
| 244 | GeometryFormat: "raw", |
| 245 | GroupFormat: "map", |
| 246 | }) |
| 247 | suite.T().Log("Finished running line #44") |
| 248 | } |
| 249 | |
| 250 | { |
| 251 | // sindex/status.yaml line #49 |
| 252 | /* ([true, true]) */ |
| 253 | var expected_ []interface{} = []interface{}{true, true} |
| 254 | /* table_test_sindex_status2.index_wait()['ready'] */ |
| 255 | |
| 256 | suite.T().Log("About to run line #49: table_test_sindex_status2.IndexWait().AtIndex('ready')") |
| 257 | |
| 258 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("ready"), suite.session, r.RunOpts{ |
| 259 | GeometryFormat: "raw", |
| 260 | GroupFormat: "map", |
| 261 | }) |
| 262 | suite.T().Log("Finished running line #49") |
| 263 | } |
| 264 | |
| 265 | { |
| 266 | // sindex/status.yaml line #54 |
| 267 | /* bag([false, false]) */ |
| 268 | var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{false, false}) |
| 269 | /* table_test_sindex_status2.index_wait()['geo'] */ |
| 270 | |
| 271 | suite.T().Log("About to run line #54: table_test_sindex_status2.IndexWait().AtIndex('geo')") |
| 272 | |
| 273 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("geo"), suite.session, r.RunOpts{ |
| 274 | GeometryFormat: "raw", |
| 275 | GroupFormat: "map", |
| 276 | }) |
| 277 | suite.T().Log("Finished running line #54") |
| 278 | } |
| 279 | |
| 280 | { |
| 281 | // sindex/status.yaml line #57 |
| 282 | /* bag([false, true]) */ |
| 283 | var expected_ compare.Expected = compare.UnorderedMatch([]interface{}{false, true}) |
| 284 | /* table_test_sindex_status2.index_wait()['multi'] */ |
| 285 | |
| 286 | suite.T().Log("About to run line #57: table_test_sindex_status2.IndexWait().AtIndex('multi')") |
| 287 | |
| 288 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("multi"), suite.session, r.RunOpts{ |
| 289 | GeometryFormat: "raw", |
| 290 | GroupFormat: "map", |
| 291 | }) |
| 292 | suite.T().Log("Finished running line #57") |
| 293 | } |
| 294 | |
| 295 | { |
| 296 | // sindex/status.yaml line #60 |
| 297 | /* ([false, false]) */ |
| 298 | var expected_ []interface{} = []interface{}{false, false} |
| 299 | /* table_test_sindex_status2.index_wait()['outdated'] */ |
| 300 | |
| 301 | suite.T().Log("About to run line #60: table_test_sindex_status2.IndexWait().AtIndex('outdated')") |
| 302 | |
| 303 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait().AtIndex("outdated"), suite.session, r.RunOpts{ |
| 304 | GeometryFormat: "raw", |
| 305 | GroupFormat: "map", |
| 306 | }) |
| 307 | suite.T().Log("Finished running line #60") |
| 308 | } |
| 309 | |
| 310 | { |
| 311 | // sindex/status.yaml line #63 |
| 312 | /* ({'created':1}) */ |
| 313 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 314 | /* table_test_sindex_status2.index_create("quux") */ |
| 315 | |
| 316 | suite.T().Log("About to run line #63: table_test_sindex_status2.IndexCreate('quux')") |
| 317 | |
| 318 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexCreate("quux"), suite.session, r.RunOpts{ |
| 319 | GeometryFormat: "raw", |
| 320 | GroupFormat: "map", |
| 321 | }) |
| 322 | suite.T().Log("Finished running line #63") |
| 323 | } |
| 324 | |
| 325 | { |
| 326 | // sindex/status.yaml line #66 |
| 327 | /* true */ |
| 328 | var expected_ bool = true |
| 329 | /* table_test_sindex_status2.index_status("quux").do(lambda x:(x[0]["index"] == "quux") & (x[0]["progress"] < 1)) */ |
| 330 | |
| 331 | 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))})") |
| 332 | |
| 333 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexStatus("quux").Do(func(x r.Term) interface{} { |
| 334 | return x.AtIndex(0).AtIndex("index").Eq("quux").And(x.AtIndex(0).AtIndex("progress").Lt(1)) |
| 335 | }), suite.session, r.RunOpts{ |
| 336 | GeometryFormat: "raw", |
| 337 | GroupFormat: "map", |
| 338 | }) |
| 339 | suite.T().Log("Finished running line #66") |
| 340 | } |
| 341 | |
| 342 | { |
| 343 | // sindex/status.yaml line #71 |
| 344 | /* ([{'index':'quux', 'ready':true}]) */ |
| 345 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"index": "quux", "ready": true}} |
| 346 | /* table_test_sindex_status2.index_wait("quux").pluck('index', 'ready') */ |
| 347 | |
| 348 | suite.T().Log("About to run line #71: table_test_sindex_status2.IndexWait('quux').Pluck('index', 'ready')") |
| 349 | |
| 350 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait("quux").Pluck("index", "ready"), suite.session, r.RunOpts{ |
| 351 | GeometryFormat: "raw", |
| 352 | GroupFormat: "map", |
| 353 | }) |
| 354 | suite.T().Log("Finished running line #71") |
| 355 | } |
| 356 | |
| 357 | { |
| 358 | // sindex/status.yaml line #74 |
| 359 | /* ("PTYPE<BINARY>") */ |
| 360 | var expected_ string = "PTYPE<BINARY>" |
| 361 | /* table_test_sindex_status2.index_wait("quux").nth(0).get_field('function').type_of() */ |
| 362 | |
| 363 | suite.T().Log("About to run line #74: table_test_sindex_status2.IndexWait('quux').Nth(0).Field('function').TypeOf()") |
| 364 | |
| 365 | runAndAssert(suite.Suite, expected_, table_test_sindex_status2.IndexWait("quux").Nth(0).Field("function").TypeOf(), suite.session, r.RunOpts{ |
| 366 | GeometryFormat: "raw", |
| 367 | GroupFormat: "map", |
| 368 | }) |
| 369 | suite.T().Log("Finished running line #74") |
| 370 | } |
| 371 | } |