Debian Codegraph @

internal/integration/reql_tests/reql_changefeeds_idxcopy_test.go

raw symbols SCIP
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 duplicate indexes with squashing
17 func TestChangefeedsIdxcopySuite(t *testing.T) {
18 suite.Run(t, new(ChangefeedsIdxcopySuite))
19 }
20
21 type ChangefeedsIdxcopySuite struct {
22 suite.Suite
23
24 session *r.Session
25 }
26
27 func (suite *ChangefeedsIdxcopySuite) SetupTest() {
28 suite.T().Log("Setting up ChangefeedsIdxcopySuite")
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_idxcopy").Exec(suite.session)
40 err = r.DBCreate("db_feed_idxcopy").Exec(suite.session)
41 suite.Require().NoError(err)
42 err = r.DB("db_feed_idxcopy").Wait().Exec(suite.session)
43 suite.Require().NoError(err)
44
45 r.DB("db_feed_idxcopy").TableDrop("table_test_changefeed_idx").Exec(suite.session)
46 err = r.DB("db_feed_idxcopy").TableCreate("table_test_changefeed_idx").Exec(suite.session)
47 suite.Require().NoError(err)
48 err = r.DB("db_feed_idxcopy").Table("table_test_changefeed_idx").Wait().Exec(suite.session)
49 suite.Require().NoError(err)
50 }
51
52 func (suite *ChangefeedsIdxcopySuite) TearDownSuite() {
53 suite.T().Log("Tearing down ChangefeedsIdxcopySuite")
54
55 if suite.session != nil {
56 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
57 r.DB("db_feed_idxcopy").TableDrop("table_test_changefeed_idx").Exec(suite.session)
58 r.DBDrop("db_feed_idxcopy").Exec(suite.session)
59
60 suite.session.Close()
61 }
62 }
63
64 func (suite *ChangefeedsIdxcopySuite) TestCases() {
65 suite.T().Log("Running ChangefeedsIdxcopySuite: Test duplicate indexes with squashing")
66
67 table_test_changefeed_idx := r.DB("db_feed_idxcopy").Table("table_test_changefeed_idx")
68 _ = table_test_changefeed_idx // Prevent any noused variable errors
69
70 {
71 // changefeeds/idxcopy.yaml line #4
72 /* partial({'created':1}) */
73 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"created": 1})
74 /* table_test_changefeed_idx.index_create('a') */
75
76 suite.T().Log("About to run line #4: table_test_changefeed_idx.IndexCreate('a')")
77
78 runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.IndexCreate("a"), suite.session, r.RunOpts{
79 GeometryFormat: "raw",
80 GroupFormat: "map",
81 })
82 suite.T().Log("Finished running line #4")
83 }
84
85 {
86 // changefeeds/idxcopy.yaml line #6
87 /* AnythingIsFine */
88 var expected_ string = compare.AnythingIsFine
89 /* table_test_changefeed_idx.index_wait('a') */
90
91 suite.T().Log("About to run line #6: table_test_changefeed_idx.IndexWait('a')")
92
93 runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.IndexWait("a"), suite.session, r.RunOpts{
94 GeometryFormat: "raw",
95 GroupFormat: "map",
96 })
97 suite.T().Log("Finished running line #6")
98 }
99
100 // changefeeds/idxcopy.yaml line #8
101 // feed = table_test_changefeed_idx.order_by(index='a').limit(10).changes(squash=2).limit(9)
102 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)")
103
104 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{
105 MaxBatchRows: 1,
106 })
107 _ = feed // Prevent any noused variable errors
108
109 {
110 // changefeeds/idxcopy.yaml line #15
111 /* partial({'inserted':12, 'errors':0}) */
112 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 12, "errors": 0})
113 /* table_test_changefeed_idx.insert(r.range(0, 12).map({'id':r.row, 'a':5})) */
114
115 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, }))")
116
117 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{
118 GeometryFormat: "raw",
119 GroupFormat: "map",
120 })
121 suite.T().Log("Finished running line #15")
122 }
123
124 {
125 // changefeeds/idxcopy.yaml line #20
126 /* partial({'deleted':3, 'errors':0}) */
127 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"deleted": 3, "errors": 0})
128 /* table_test_changefeed_idx.get_all(1, 8, 9, index='id').delete() */
129
130 suite.T().Log("About to run line #20: table_test_changefeed_idx.GetAll(1, 8, 9).OptArgs(r.GetAllOpts{Index: 'id', }).Delete()")
131
132 runAndAssert(suite.Suite, expected_, table_test_changefeed_idx.GetAll(1, 8, 9).OptArgs(r.GetAllOpts{Index: "id"}).Delete(), suite.session, r.RunOpts{
133 GeometryFormat: "raw",
134 GroupFormat: "map",
135 })
136 suite.T().Log("Finished running line #20")
137 }
138
139 {
140 // changefeeds/idxcopy.yaml line #26
141 /* AnythingIsFine */
142 var expected_ string = compare.AnythingIsFine
143 /* wait(2) */
144
145 suite.T().Log("About to run line #26: wait(2)")
146
147 actual := wait(2)
148
149 compare.Assert(suite.T(), expected_, actual)
150 suite.T().Log("Finished running line #26")
151 }
152
153 {
154 // changefeeds/idxcopy.yaml line #28
155 /* bag([
156 {"new_val":{"a":5, "id":0}, "old_val":nil},
157 {"new_val":{"a":5, "id":2}, "old_val":nil},
158 {"new_val":{"a":5, "id":3}, "old_val":nil},
159 {"new_val":{"a":5, "id":4}, "old_val":nil},
160 {"new_val":{"a":5, "id":5}, "old_val":nil},
161 {"new_val":{"a":5, "id":6}, "old_val":nil},
162 {"new_val":{"a":5, "id":7}, "old_val":nil},
163 {"new_val":{"a":5, "id":10}, "old_val":nil},
164 {"new_val":{"a":5, "id":11}, "old_val":nil}]) */
165 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}})
166 /* fetch(feed) */
167
168 suite.T().Log("About to run line #28: fetch(feed, 0)")
169
170 fetchAndAssert(suite.Suite, expected_, feed, 0)
171 suite.T().Log("Finished running line #28")
172 }
173 }