| 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 nulls in strings |
| 17 | func TestSindexNullsinstringsSuite(t *testing.T) { |
| 18 | suite.Run(t, new(SindexNullsinstringsSuite)) |
| 19 | } |
| 20 | |
| 21 | type SindexNullsinstringsSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *SindexNullsinstringsSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up SindexNullsinstringsSuite") |
| 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_null").Exec(suite.session) |
| 40 | err = r.DBCreate("db_sindex_null").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_sindex_null").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | r.DB("db_sindex_null").TableDrop("table_test_sindex_nullstr").Exec(suite.session) |
| 46 | err = r.DB("db_sindex_null").TableCreate("table_test_sindex_nullstr").Exec(suite.session) |
| 47 | suite.Require().NoError(err) |
| 48 | err = r.DB("db_sindex_null").Table("table_test_sindex_nullstr").Wait().Exec(suite.session) |
| 49 | suite.Require().NoError(err) |
| 50 | } |
| 51 | |
| 52 | func (suite *SindexNullsinstringsSuite) TearDownSuite() { |
| 53 | suite.T().Log("Tearing down SindexNullsinstringsSuite") |
| 54 | |
| 55 | if suite.session != nil { |
| 56 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 57 | r.DB("db_sindex_null").TableDrop("table_test_sindex_nullstr").Exec(suite.session) |
| 58 | r.DBDrop("db_sindex_null").Exec(suite.session) |
| 59 | |
| 60 | suite.session.Close() |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (suite *SindexNullsinstringsSuite) TestCases() { |
| 65 | suite.T().Log("Running SindexNullsinstringsSuite: sindex nulls in strings") |
| 66 | |
| 67 | table_test_sindex_nullstr := r.DB("db_sindex_null").Table("table_test_sindex_nullstr") |
| 68 | _ = table_test_sindex_nullstr // Prevent any noused variable errors |
| 69 | |
| 70 | { |
| 71 | // sindex/nullsinstrings.yaml line #4 |
| 72 | /* ({"created":1}) */ |
| 73 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1} |
| 74 | /* table_test_sindex_nullstr.index_create("key") */ |
| 75 | |
| 76 | suite.T().Log("About to run line #4: table_test_sindex_nullstr.IndexCreate('key')") |
| 77 | |
| 78 | runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.IndexCreate("key"), suite.session, r.RunOpts{ |
| 79 | GeometryFormat: "raw", |
| 80 | GroupFormat: "map", |
| 81 | }) |
| 82 | suite.T().Log("Finished running line #4") |
| 83 | } |
| 84 | |
| 85 | { |
| 86 | // sindex/nullsinstrings.yaml line #6 |
| 87 | /* ([{"ready":true}]) */ |
| 88 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"ready": true}} |
| 89 | /* table_test_sindex_nullstr.index_wait().pluck("ready") */ |
| 90 | |
| 91 | suite.T().Log("About to run line #6: table_test_sindex_nullstr.IndexWait().Pluck('ready')") |
| 92 | |
| 93 | runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.IndexWait().Pluck("ready"), suite.session, r.RunOpts{ |
| 94 | GeometryFormat: "raw", |
| 95 | GroupFormat: "map", |
| 96 | }) |
| 97 | suite.T().Log("Finished running line #6") |
| 98 | } |
| 99 | |
| 100 | { |
| 101 | // sindex/nullsinstrings.yaml line #10 |
| 102 | /* ({"inserted":2}) */ |
| 103 | var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"inserted": 2} |
| 104 | /* table_test_sindex_nullstr.insert([{"id":1,"key":["a","b"]},{"id":2,"key":["a\u0000Sb"]}]).pluck("inserted") */ |
| 105 | |
| 106 | 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')") |
| 107 | |
| 108 | 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{ |
| 109 | GeometryFormat: "raw", |
| 110 | GroupFormat: "map", |
| 111 | }) |
| 112 | suite.T().Log("Finished running line #10") |
| 113 | } |
| 114 | |
| 115 | { |
| 116 | // sindex/nullsinstrings.yaml line #13 |
| 117 | /* ([{"id":2}]) */ |
| 118 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 2}} |
| 119 | /* table_test_sindex_nullstr.get_all(["a\u0000Sb"], index="key").pluck("id") */ |
| 120 | |
| 121 | suite.T().Log("About to run line #13: table_test_sindex_nullstr.GetAll([]interface{}{'a\\u0000Sb'}).OptArgs(r.GetAllOpts{Index: 'key', }).Pluck('id')") |
| 122 | |
| 123 | runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.GetAll([]interface{}{"a\u0000Sb"}).OptArgs(r.GetAllOpts{Index: "key"}).Pluck("id"), suite.session, r.RunOpts{ |
| 124 | GeometryFormat: "raw", |
| 125 | GroupFormat: "map", |
| 126 | }) |
| 127 | suite.T().Log("Finished running line #13") |
| 128 | } |
| 129 | |
| 130 | { |
| 131 | // sindex/nullsinstrings.yaml line #18 |
| 132 | /* ([{"id":1}]) */ |
| 133 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 1}} |
| 134 | /* table_test_sindex_nullstr.get_all(["a","b"], index="key").pluck("id") */ |
| 135 | |
| 136 | suite.T().Log("About to run line #18: table_test_sindex_nullstr.GetAll([]interface{}{'a', 'b'}).OptArgs(r.GetAllOpts{Index: 'key', }).Pluck('id')") |
| 137 | |
| 138 | runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.GetAll([]interface{}{"a", "b"}).OptArgs(r.GetAllOpts{Index: "key"}).Pluck("id"), suite.session, r.RunOpts{ |
| 139 | GeometryFormat: "raw", |
| 140 | GroupFormat: "map", |
| 141 | }) |
| 142 | suite.T().Log("Finished running line #18") |
| 143 | } |
| 144 | } |