File: reql_datum_null_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 (120 lines) | stat: -rw-r--r-- 2,981 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
// 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"
)

// Tests of conversion to and from the RQL null type
func TestDatumNullSuite(t *testing.T) {
	suite.Run(t, new(DatumNullSuite))
}

type DatumNullSuite struct {
	suite.Suite

	session *r.Session
}

func (suite *DatumNullSuite) SetupTest() {
	suite.T().Log("Setting up DatumNullSuite")
	// 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_dnull").Exec(suite.session)
	err = r.DBCreate("db_dnull").Exec(suite.session)
	suite.Require().NoError(err)
	err = r.DB("db_dnull").Wait().Exec(suite.session)
	suite.Require().NoError(err)

}

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

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

		suite.session.Close()
	}
}

func (suite *DatumNullSuite) TestCases() {
	suite.T().Log("Running DatumNullSuite: Tests of conversion to and from the RQL null type")

	{
		// datum/null.yaml line #6
		/* (null) */
		var expected_ interface{} = nil
		/* r.expr(null) */

		suite.T().Log("About to run line #6: r.Expr(nil)")

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

	{
		// datum/null.yaml line #9
		/* 'NULL' */
		var expected_ string = "NULL"
		/* r.expr(null).type_of() */

		suite.T().Log("About to run line #9: r.Expr(nil).TypeOf()")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).TypeOf(), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #9")
	}

	{
		// datum/null.yaml line #14
		/* 'null' */
		var expected_ string = "null"
		/* r.expr(null).coerce_to('string') */

		suite.T().Log("About to run line #14: r.Expr(nil).CoerceTo('string')")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("string"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #14")
	}

	{
		// datum/null.yaml line #17
		/* null */
		var expected_ interface{} = nil
		/* r.expr(null).coerce_to('null') */

		suite.T().Log("About to run line #17: r.Expr(nil).CoerceTo('null')")

		runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("null"), suite.session, r.RunOpts{
			GeometryFormat: "raw",
			GroupFormat:    "map",
		})
		suite.T().Log("Finished running line #17")
	}
}