Debian Codegraph @

internal/integration/reql_tests/reql_polymorphism_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 // Tests that manipulation data in tables
17 func TestPolymorphismSuite(t *testing.T) {
18 suite.Run(t, new(PolymorphismSuite))
19 }
20
21 type PolymorphismSuite struct {
22 suite.Suite
23
24 session *r.Session
25 }
26
27 func (suite *PolymorphismSuite) SetupTest() {
28 suite.T().Log("Setting up PolymorphismSuite")
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_poly").Exec(suite.session)
40 err = r.DBCreate("db_poly").Exec(suite.session)
41 suite.Require().NoError(err)
42 err = r.DB("db_poly").Wait().Exec(suite.session)
43 suite.Require().NoError(err)
44
45 r.DB("db_poly").TableDrop("table_test_poly").Exec(suite.session)
46 err = r.DB("db_poly").TableCreate("table_test_poly").Exec(suite.session)
47 suite.Require().NoError(err)
48 err = r.DB("db_poly").Table("table_test_poly").Wait().Exec(suite.session)
49 suite.Require().NoError(err)
50 }
51
52 func (suite *PolymorphismSuite) TearDownSuite() {
53 suite.T().Log("Tearing down PolymorphismSuite")
54
55 if suite.session != nil {
56 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
57 r.DB("db_poly").TableDrop("table_test_poly").Exec(suite.session)
58 r.DBDrop("db_poly").Exec(suite.session)
59
60 suite.session.Close()
61 }
62 }
63
64 func (suite *PolymorphismSuite) TestCases() {
65 suite.T().Log("Running PolymorphismSuite: Tests that manipulation data in tables")
66
67 table_test_poly := r.DB("db_poly").Table("table_test_poly")
68 _ = table_test_poly // Prevent any noused variable errors
69
70 // polymorphism.yaml line #5
71 // obj = r.expr({'id':0,'a':0})
72 suite.T().Log("Possibly executing: var obj r.Term = r.Expr(map[interface{}]interface{}{'id': 0, 'a': 0, })")
73
74 obj := r.Expr(map[interface{}]interface{}{"id": 0, "a": 0})
75 _ = obj // Prevent any noused variable errors
76
77 {
78 // polymorphism.yaml line #7
79 /* ({'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':3}) */
80 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 3}
81 /* table_test_poly.insert([{'id':i, 'a':i} for i in xrange(3)]) */
82
83 suite.T().Log("About to run line #7: table_test_poly.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 0; iterator_ < 3; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': i, 'a': i, })\n }\n return res\n}()))")
84
85 runAndAssert(suite.Suite, expected_, table_test_poly.Insert((func() []interface{} {
86 res := []interface{}{}
87 for iterator_ := 0; iterator_ < 3; iterator_++ {
88 i := iterator_
89 res = append(res, map[interface{}]interface{}{"id": i, "a": i})
90 }
91 return res
92 }())), suite.session, r.RunOpts{
93 GeometryFormat: "raw",
94 GroupFormat: "map",
95 })
96 suite.T().Log("Finished running line #7")
97 }
98
99 {
100 // polymorphism.yaml line #21
101 /* ({'id':0,'c':1,'a':0}) */
102 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "c": 1, "a": 0}
103 /* table_test_poly.merge({'c':1}).nth(0) */
104
105 suite.T().Log("About to run line #21: table_test_poly.Merge(map[interface{}]interface{}{'c': 1, }).Nth(0)")
106
107 runAndAssert(suite.Suite, expected_, table_test_poly.Merge(map[interface{}]interface{}{"c": 1}).Nth(0), suite.session, r.RunOpts{
108 GeometryFormat: "raw",
109 GroupFormat: "map",
110 })
111 suite.T().Log("Finished running line #21")
112 }
113
114 {
115 // polymorphism.yaml line #22
116 /* ({'id':0,'c':1,'a':0}) */
117 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0, "c": 1, "a": 0}
118 /* obj.merge({'c':1}) */
119
120 suite.T().Log("About to run line #22: obj.Merge(map[interface{}]interface{}{'c': 1, })")
121
122 runAndAssert(suite.Suite, expected_, obj.Merge(map[interface{}]interface{}{"c": 1}), suite.session, r.RunOpts{
123 GeometryFormat: "raw",
124 GroupFormat: "map",
125 })
126 suite.T().Log("Finished running line #22")
127 }
128
129 {
130 // polymorphism.yaml line #26
131 /* ({'id':0}) */
132 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0}
133 /* table_test_poly.without('a').nth(0) */
134
135 suite.T().Log("About to run line #26: table_test_poly.Without('a').Nth(0)")
136
137 runAndAssert(suite.Suite, expected_, table_test_poly.Without("a").Nth(0), suite.session, r.RunOpts{
138 GeometryFormat: "raw",
139 GroupFormat: "map",
140 })
141 suite.T().Log("Finished running line #26")
142 }
143
144 {
145 // polymorphism.yaml line #27
146 /* ({'id':0}) */
147 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 0}
148 /* obj.without('a') */
149
150 suite.T().Log("About to run line #27: obj.Without('a')")
151
152 runAndAssert(suite.Suite, expected_, obj.Without("a"), suite.session, r.RunOpts{
153 GeometryFormat: "raw",
154 GroupFormat: "map",
155 })
156 suite.T().Log("Finished running line #27")
157 }
158
159 {
160 // polymorphism.yaml line #31
161 /* ({'a':0}) */
162 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0}
163 /* table_test_poly.pluck('a').nth(0) */
164
165 suite.T().Log("About to run line #31: table_test_poly.Pluck('a').Nth(0)")
166
167 runAndAssert(suite.Suite, expected_, table_test_poly.Pluck("a").Nth(0), suite.session, r.RunOpts{
168 GeometryFormat: "raw",
169 GroupFormat: "map",
170 })
171 suite.T().Log("Finished running line #31")
172 }
173
174 {
175 // polymorphism.yaml line #32
176 /* ({'a':0}) */
177 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"a": 0}
178 /* obj.pluck('a') */
179
180 suite.T().Log("About to run line #32: obj.Pluck('a')")
181
182 runAndAssert(suite.Suite, expected_, obj.Pluck("a"), suite.session, r.RunOpts{
183 GeometryFormat: "raw",
184 GroupFormat: "map",
185 })
186 suite.T().Log("Finished running line #32")
187 }
188 }