Debian Codegraph @

internal/integration/reql_tests/reql_meta_dbs_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 meta queries for databases
17 func TestMetaDbsSuite(t *testing.T) {
18 suite.Run(t, new(MetaDbsSuite))
19 }
20
21 type MetaDbsSuite struct {
22 suite.Suite
23
24 session *r.Session
25 }
26
27 func (suite *MetaDbsSuite) SetupTest() {
28 suite.T().Log("Setting up MetaDbsSuite")
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_dbs").Exec(suite.session)
40 err = r.DBCreate("db_dbs").Exec(suite.session)
41 suite.Require().NoError(err)
42 err = r.DB("db_dbs").Wait().Exec(suite.session)
43 suite.Require().NoError(err)
44
45 }
46
47 func (suite *MetaDbsSuite) TearDownSuite() {
48 suite.T().Log("Tearing down MetaDbsSuite")
49
50 if suite.session != nil {
51 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
52 r.DBDrop("db_dbs").Exec(suite.session)
53
54 suite.session.Close()
55 }
56 }
57
58 func (suite *MetaDbsSuite) TestCases() {
59 suite.T().Log("Running MetaDbsSuite: Tests meta queries for databases")
60
61 {
62 // meta/dbs.yaml line #6
63 /* bag(['rethinkdb', 'test']) */
64 var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "db_dbs"})
65 /* r.db_list() */
66
67 suite.T().Log("About to run line #6: r.DBList()")
68
69 runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{
70 GeometryFormat: "raw",
71 GroupFormat: "map",
72 })
73 suite.T().Log("Finished running line #6")
74 }
75
76 {
77 // meta/dbs.yaml line #11
78 /* partial({'dbs_created':1}) */
79 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1})
80 /* r.db_create('a') */
81
82 suite.T().Log("About to run line #11: r.DBCreate('a')")
83
84 runAndAssert(suite.Suite, expected_, r.DBCreate("a"), suite.session, r.RunOpts{
85 GeometryFormat: "raw",
86 GroupFormat: "map",
87 })
88 suite.T().Log("Finished running line #11")
89 }
90
91 {
92 // meta/dbs.yaml line #13
93 /* partial({'dbs_created':1}) */
94 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1})
95 /* r.db_create('b') */
96
97 suite.T().Log("About to run line #13: r.DBCreate('b')")
98
99 runAndAssert(suite.Suite, expected_, r.DBCreate("b"), suite.session, r.RunOpts{
100 GeometryFormat: "raw",
101 GroupFormat: "map",
102 })
103 suite.T().Log("Finished running line #13")
104 }
105
106 {
107 // meta/dbs.yaml line #18
108 /* bag(['rethinkdb', 'a', 'b', 'test']) */
109 var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "a", "b", "db_dbs"})
110 /* r.db_list() */
111
112 suite.T().Log("About to run line #18: r.DBList()")
113
114 runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{
115 GeometryFormat: "raw",
116 GroupFormat: "map",
117 })
118 suite.T().Log("Finished running line #18")
119 }
120
121 {
122 // meta/dbs.yaml line #23
123 /* {'name':'a','id':uuid()} */
124 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"name": "a", "id": compare.IsUUID()}
125 /* r.db('a').config() */
126
127 suite.T().Log("About to run line #23: r.DB('a').Config()")
128
129 runAndAssert(suite.Suite, expected_, r.DB("a").Config(), suite.session, r.RunOpts{
130 GeometryFormat: "raw",
131 GroupFormat: "map",
132 })
133 suite.T().Log("Finished running line #23")
134 }
135
136 {
137 // meta/dbs.yaml line #28
138 /* partial({'dbs_dropped':1}) */
139 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1})
140 /* r.db_drop('b') */
141
142 suite.T().Log("About to run line #28: r.DBDrop('b')")
143
144 runAndAssert(suite.Suite, expected_, r.DBDrop("b"), suite.session, r.RunOpts{
145 GeometryFormat: "raw",
146 GroupFormat: "map",
147 })
148 suite.T().Log("Finished running line #28")
149 }
150
151 {
152 // meta/dbs.yaml line #31
153 /* bag(['rethinkdb', 'a', 'test']) */
154 var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "a", "db_dbs"})
155 /* r.db_list() */
156
157 suite.T().Log("About to run line #31: r.DBList()")
158
159 runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{
160 GeometryFormat: "raw",
161 GroupFormat: "map",
162 })
163 suite.T().Log("Finished running line #31")
164 }
165
166 {
167 // meta/dbs.yaml line #34
168 /* partial({'dbs_dropped':1}) */
169 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1})
170 /* r.db_drop('a') */
171
172 suite.T().Log("About to run line #34: r.DBDrop('a')")
173
174 runAndAssert(suite.Suite, expected_, r.DBDrop("a"), suite.session, r.RunOpts{
175 GeometryFormat: "raw",
176 GroupFormat: "map",
177 })
178 suite.T().Log("Finished running line #34")
179 }
180
181 {
182 // meta/dbs.yaml line #37
183 /* bag(['rethinkdb', 'test']) */
184 var expected_ compare.Expected = compare.PartialMatch([]interface{}{"rethinkdb", "db_dbs"})
185 /* r.db_list() */
186
187 suite.T().Log("About to run line #37: r.DBList()")
188
189 runAndAssert(suite.Suite, expected_, r.DBList(), suite.session, r.RunOpts{
190 GeometryFormat: "raw",
191 GroupFormat: "map",
192 })
193 suite.T().Log("Finished running line #37")
194 }
195
196 {
197 // meta/dbs.yaml line #41
198 /* partial({'dbs_created':1}) */
199 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_created": 1})
200 /* r.db_create('bar') */
201
202 suite.T().Log("About to run line #41: r.DBCreate('bar')")
203
204 runAndAssert(suite.Suite, expected_, r.DBCreate("bar"), suite.session, r.RunOpts{
205 GeometryFormat: "raw",
206 GroupFormat: "map",
207 })
208 suite.T().Log("Finished running line #41")
209 }
210
211 {
212 // meta/dbs.yaml line #44
213 /* err('ReqlOpFailedError', 'Database `bar` already exists.', [0]) */
214 var expected_ Err = err("ReqlOpFailedError", "Database `bar` already exists.")
215 /* r.db_create('bar') */
216
217 suite.T().Log("About to run line #44: r.DBCreate('bar')")
218
219 runAndAssert(suite.Suite, expected_, r.DBCreate("bar"), suite.session, r.RunOpts{
220 GeometryFormat: "raw",
221 GroupFormat: "map",
222 })
223 suite.T().Log("Finished running line #44")
224 }
225
226 {
227 // meta/dbs.yaml line #47
228 /* partial({'dbs_dropped':1}) */
229 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"dbs_dropped": 1})
230 /* r.db_drop('bar') */
231
232 suite.T().Log("About to run line #47: r.DBDrop('bar')")
233
234 runAndAssert(suite.Suite, expected_, r.DBDrop("bar"), suite.session, r.RunOpts{
235 GeometryFormat: "raw",
236 GroupFormat: "map",
237 })
238 suite.T().Log("Finished running line #47")
239 }
240
241 {
242 // meta/dbs.yaml line #50
243 /* err('ReqlOpFailedError', 'Database `bar` does not exist.', [0]) */
244 var expected_ Err = err("ReqlOpFailedError", "Database `bar` does not exist.")
245 /* r.db_drop('bar') */
246
247 suite.T().Log("About to run line #50: r.DBDrop('bar')")
248
249 runAndAssert(suite.Suite, expected_, r.DBDrop("bar"), suite.session, r.RunOpts{
250 GeometryFormat: "raw",
251 GroupFormat: "map",
252 })
253 suite.T().Log("Finished running line #50")
254 }
255 }