gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_changefeeds_squash_test.go (about) 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 changefeed squashing 17 func TestChangefeedsSquashSuite(t *testing.T) { 18 suite.Run(t, new(ChangefeedsSquashSuite)) 19 } 20 21 type ChangefeedsSquashSuite struct { 22 suite.Suite 23 24 session *r.Session 25 } 26 27 func (suite *ChangefeedsSquashSuite) SetupTest() { 28 suite.T().Log("Setting up ChangefeedsSquashSuite") 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("test").Exec(suite.session) 40 err = r.DBCreate("test").Exec(suite.session) 41 suite.Require().NoError(err) 42 err = r.DB("test").Wait().Exec(suite.session) 43 suite.Require().NoError(err) 44 45 r.DB("test").TableDrop("tbl").Exec(suite.session) 46 err = r.DB("test").TableCreate("tbl").Exec(suite.session) 47 suite.Require().NoError(err) 48 err = r.DB("test").Table("tbl").Wait().Exec(suite.session) 49 suite.Require().NoError(err) 50 } 51 52 func (suite *ChangefeedsSquashSuite) TearDownSuite() { 53 suite.T().Log("Tearing down ChangefeedsSquashSuite") 54 55 if suite.session != nil { 56 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) 57 r.DB("test").TableDrop("tbl").Exec(suite.session) 58 r.DBDrop("test").Exec(suite.session) 59 60 suite.session.Close() 61 } 62 } 63 64 func (suite *ChangefeedsSquashSuite) TestCases() { 65 suite.T().Log("Running ChangefeedsSquashSuite: Test changefeed squashing") 66 67 tbl := r.DB("test").Table("tbl") 68 _ = tbl // Prevent any noused variable errors 69 70 { 71 // changefeeds/squash.yaml line #7 72 /* ("STREAM") */ 73 var expected_ string = "STREAM" 74 /* tbl.changes(squash=true).type_of() */ 75 76 suite.T().Log("About to run line #7: tbl.Changes().OptArgs(r.ChangesOpts{Squash: true, }).TypeOf()") 77 78 runAndAssert(suite.Suite, expected_, tbl.Changes().OptArgs(r.ChangesOpts{Squash: true}).TypeOf(), suite.session, r.RunOpts{ 79 GeometryFormat: "raw", 80 GroupFormat: "map", 81 }) 82 suite.T().Log("Finished running line #7") 83 } 84 85 // changefeeds/squash.yaml line #14 86 // normal_changes = tbl.changes().limit(2) 87 suite.T().Log("Possibly executing: var normal_changes r.Term = tbl.Changes().Limit(2)") 88 89 normal_changes := maybeRun(tbl.Changes().Limit(2), suite.session, r.RunOpts{}) 90 _ = normal_changes // Prevent any noused variable errors 91 92 // changefeeds/squash.yaml line #16 93 // false_squash_changes = tbl.changes(squash=False).limit(2) 94 suite.T().Log("Possibly executing: var false_squash_changes r.Term = tbl.Changes().OptArgs(r.ChangesOpts{Squash: false, }).Limit(2)") 95 96 false_squash_changes := maybeRun(tbl.Changes().OptArgs(r.ChangesOpts{Squash: false}).Limit(2), suite.session, r.RunOpts{}) 97 _ = false_squash_changes // Prevent any noused variable errors 98 99 // changefeeds/squash.yaml line #20 100 // long_squash_changes = tbl.changes(squash=0.5).limit(1) 101 suite.T().Log("Possibly executing: var long_squash_changes r.Term = tbl.Changes().OptArgs(r.ChangesOpts{Squash: 0.5, }).Limit(1)") 102 103 long_squash_changes := maybeRun(tbl.Changes().OptArgs(r.ChangesOpts{Squash: 0.5}).Limit(1), suite.session, r.RunOpts{}) 104 _ = long_squash_changes // Prevent any noused variable errors 105 106 // changefeeds/squash.yaml line #24 107 // squash_changes = tbl.changes(squash=true).limit(1) 108 suite.T().Log("Possibly executing: var squash_changes r.Term = tbl.Changes().OptArgs(r.ChangesOpts{Squash: true, }).Limit(1)") 109 110 squash_changes := maybeRun(tbl.Changes().OptArgs(r.ChangesOpts{Squash: true}).Limit(1), suite.session, r.RunOpts{}) 111 _ = squash_changes // Prevent any noused variable errors 112 113 { 114 // changefeeds/squash.yaml line #28 115 /* 1 */ 116 var expected_ int = 1 117 /* tbl.insert({'id':100})['inserted'] */ 118 119 suite.T().Log("About to run line #28: tbl.Insert(map[interface{}]interface{}{'id': 100, }).AtIndex('inserted')") 120 121 runAndAssert(suite.Suite, expected_, tbl.Insert(map[interface{}]interface{}{"id": 100}).AtIndex("inserted"), suite.session, r.RunOpts{ 122 GeometryFormat: "raw", 123 GroupFormat: "map", 124 }) 125 suite.T().Log("Finished running line #28") 126 } 127 128 { 129 // changefeeds/squash.yaml line #32 130 /* 1 */ 131 var expected_ int = 1 132 /* tbl.get(100).update({'a':1})['replaced'] */ 133 134 suite.T().Log("About to run line #32: tbl.Get(100).Update(map[interface{}]interface{}{'a': 1, }).AtIndex('replaced')") 135 136 runAndAssert(suite.Suite, expected_, tbl.Get(100).Update(map[interface{}]interface{}{"a": 1}).AtIndex("replaced"), suite.session, r.RunOpts{ 137 GeometryFormat: "raw", 138 GroupFormat: "map", 139 }) 140 suite.T().Log("Finished running line #32") 141 } 142 143 { 144 // changefeeds/squash.yaml line #36 145 /* ([{'new_val':{'id':100}, 'old_val':null}, 146 {'new_val':{'a':1, 'id':100}, 'old_val':{'id':100}}]) */ 147 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 100}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 1, "id": 100}, "old_val": map[interface{}]interface{}{"id": 100}}} 148 /* normal_changes */ 149 150 suite.T().Log("About to run line #36: normal_changes") 151 152 runAndAssert(suite.Suite, expected_, normal_changes, suite.session, r.RunOpts{ 153 GeometryFormat: "raw", 154 GroupFormat: "map", 155 }) 156 suite.T().Log("Finished running line #36") 157 } 158 159 { 160 // changefeeds/squash.yaml line #40 161 /* ([{'new_val':{'id':100}, 'old_val':null}, 162 {'new_val':{'a':1, 'id':100}, 'old_val':{'id':100}}]) */ 163 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 100}, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 1, "id": 100}, "old_val": map[interface{}]interface{}{"id": 100}}} 164 /* false_squash_changes */ 165 166 suite.T().Log("About to run line #40: false_squash_changes") 167 168 runAndAssert(suite.Suite, expected_, false_squash_changes, suite.session, r.RunOpts{ 169 GeometryFormat: "raw", 170 GroupFormat: "map", 171 }) 172 suite.T().Log("Finished running line #40") 173 } 174 175 { 176 // changefeeds/squash.yaml line #44 177 /* ([{'new_val':{'a':1, 'id':100}, 'old_val':null}]) */ 178 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"a": 1, "id": 100}, "old_val": nil}} 179 /* long_squash_changes */ 180 181 suite.T().Log("About to run line #44: long_squash_changes") 182 183 runAndAssert(suite.Suite, expected_, long_squash_changes, suite.session, r.RunOpts{ 184 GeometryFormat: "raw", 185 GroupFormat: "map", 186 }) 187 suite.T().Log("Finished running line #44") 188 } 189 190 { 191 // changefeeds/squash.yaml line #59 192 /* err('ReqlQueryLogicError', 'Expected BOOL or a positive NUMBER but found a negative NUMBER.') */ 193 var expected_ Err = err("ReqlQueryLogicError", "Expected BOOL or a positive NUMBER but found a negative NUMBER.") 194 /* tbl.changes(squash=-10) */ 195 196 suite.T().Log("About to run line #59: tbl.Changes().OptArgs(r.ChangesOpts{Squash: -10, })") 197 198 runAndAssert(suite.Suite, expected_, tbl.Changes().OptArgs(r.ChangesOpts{Squash: -10}), suite.session, r.RunOpts{ 199 GeometryFormat: "raw", 200 GroupFormat: "map", 201 }) 202 suite.T().Log("Finished running line #59") 203 } 204 }