File: reql_sindex_nullsinstrings_test.go

package info (click to toggle)
golang-gopkg-rethinkdb-rethinkdb-go.v6 6.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,736 kB
  • sloc: python: 1,382; makefile: 16; sh: 9
file content (144 lines) | stat: -rw-r--r-- 5,415 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Code generated by gen_tests.py and process_polyglot.py.
// Do not edit this file directly.
// The template for this file is located at:
// ../template.go.tpl
package reql_tests

import (
	"testing"
	"time"

	"github.com/stretchr/testify/suite"
	r "gopkg.in/rethinkdb/rethinkdb-go.v6"
	"gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare"
)

// sindex nulls in strings
func TestSindexNullsinstringsSuite(t *testing.T) {
	suite.Run(t, new(SindexNullsinstringsSuite))
}

type SindexNullsinstringsSuite struct {
	suite.Suite

	session *r.Session
}

func (suite *SindexNullsinstringsSuite) SetupTest() {
	suite.T().Log("Setting up SindexNullsinstringsSuite")
	// Use imports to prevent errors
	_ = time.Time{}
	_ = compare.AnythingIsFine

	session, err := r.Connect(r.ConnectOpts{
		Address: url,
	})
	suite.Require().NoError(err, "Error returned when connecting to server")
	suite.session = session

	r.DBDrop("db_sindex_null").Exec(suite.session)
	err = r.DBCreate("db_sindex_null").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("db_sindex_null").Wait().Exec(suite.session)
	suite.Require().NoError(err)

	r.DB("db_sindex_null").TableDrop("table_test_sindex_nullstr").Exec(suite.session)
	err = r.DB("db_sindex_null").TableCreate("table_test_sindex_nullstr").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("db_sindex_null").Table("table_test_sindex_nullstr").Wait().Exec(suite.session)
	suite.Require().NoError(err)
}

func (suite *SindexNullsinstringsSuite) TearDownSuite() {
	suite.T().Log("Tearing down SindexNullsinstringsSuite")

	if suite.session != nil {
		r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
		r.DB("db_sindex_null").TableDrop("table_test_sindex_nullstr").Exec(suite.session)
		r.DBDrop("db_sindex_null").Exec(suite.session)

		suite.session.Close()
	}
}

func (suite *SindexNullsinstringsSuite) TestCases() {
	suite.T().Log("Running SindexNullsinstringsSuite: sindex nulls in strings")

	table_test_sindex_nullstr := r.DB("db_sindex_null").Table("table_test_sindex_nullstr")
	_ = table_test_sindex_nullstr // Prevent any noused variable errors

	{
		// sindex/nullsinstrings.yaml line #4
		/* ({"created":1}) */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"created": 1}
		/* table_test_sindex_nullstr.index_create("key") */

		suite.T().Log("About to run line #4: table_test_sindex_nullstr.IndexCreate('key')")

		runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.IndexCreate("key"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #4")
	}

	{
		// sindex/nullsinstrings.yaml line #6
		/* ([{"ready":true}]) */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"ready": true}}
		/* table_test_sindex_nullstr.index_wait().pluck("ready") */

		suite.T().Log("About to run line #6: table_test_sindex_nullstr.IndexWait().Pluck('ready')")

		runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.IndexWait().Pluck("ready"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #6")
	}

	{
		// sindex/nullsinstrings.yaml line #10
		/* ({"inserted":2}) */
		var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"inserted": 2}
		/* table_test_sindex_nullstr.insert([{"id":1,"key":["a","b"]},{"id":2,"key":["a\u0000Sb"]}]).pluck("inserted") */

		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')")

		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{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #10")
	}

	{
		// sindex/nullsinstrings.yaml line #13
		/* ([{"id":2}]) */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 2}}
		/* table_test_sindex_nullstr.get_all(["a\u0000Sb"], index="key").pluck("id") */

		suite.T().Log("About to run line #13: table_test_sindex_nullstr.GetAll([]interface{}{'a\\u0000Sb'}).OptArgs(r.GetAllOpts{Index: 'key', }).Pluck('id')")

		runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.GetAll([]interface{}{"a\u0000Sb"}).OptArgs(r.GetAllOpts{Index: "key"}).Pluck("id"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #13")
	}

	{
		// sindex/nullsinstrings.yaml line #18
		/* ([{"id":1}]) */
		var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"id": 1}}
		/* table_test_sindex_nullstr.get_all(["a","b"], index="key").pluck("id") */

		suite.T().Log("About to run line #18: table_test_sindex_nullstr.GetAll([]interface{}{'a', 'b'}).OptArgs(r.GetAllOpts{Index: 'key', }).Pluck('id')")

		runAndAssert(suite.Suite, expected_, table_test_sindex_nullstr.GetAll([]interface{}{"a", "b"}).OptArgs(r.GetAllOpts{Index: "key"}).Pluck("id"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #18")
	}
}