| 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 of conversion to and from the RQL null type |
| 17 | func TestDatumNullSuite(t *testing.T) { |
| 18 | suite.Run(t, new(DatumNullSuite)) |
| 19 | } |
| 20 | |
| 21 | type DatumNullSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *DatumNullSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up DatumNullSuite") |
| 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_dnull").Exec(suite.session) |
| 40 | err = r.DBCreate("db_dnull").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_dnull").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | } |
| 46 | |
| 47 | func (suite *DatumNullSuite) TearDownSuite() { |
| 48 | suite.T().Log("Tearing down DatumNullSuite") |
| 49 | |
| 50 | if suite.session != nil { |
| 51 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 52 | r.DBDrop("db_dnull").Exec(suite.session) |
| 53 | |
| 54 | suite.session.Close() |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func (suite *DatumNullSuite) TestCases() { |
| 59 | suite.T().Log("Running DatumNullSuite: Tests of conversion to and from the RQL null type") |
| 60 | |
| 61 | { |
| 62 | // datum/null.yaml line #6 |
| 63 | /* (null) */ |
| 64 | var expected_ interface{} = nil |
| 65 | /* r.expr(null) */ |
| 66 | |
| 67 | suite.T().Log("About to run line #6: r.Expr(nil)") |
| 68 | |
| 69 | runAndAssert(suite.Suite, expected_, r.Expr(nil), suite.session, r.RunOpts{ |
| 70 | GeometryFormat: "raw", |
| 71 | GroupFormat: "map", |
| 72 | }) |
| 73 | suite.T().Log("Finished running line #6") |
| 74 | } |
| 75 | |
| 76 | { |
| 77 | // datum/null.yaml line #9 |
| 78 | /* 'NULL' */ |
| 79 | var expected_ string = "NULL" |
| 80 | /* r.expr(null).type_of() */ |
| 81 | |
| 82 | suite.T().Log("About to run line #9: r.Expr(nil).TypeOf()") |
| 83 | |
| 84 | runAndAssert(suite.Suite, expected_, r.Expr(nil).TypeOf(), suite.session, r.RunOpts{ |
| 85 | GeometryFormat: "raw", |
| 86 | GroupFormat: "map", |
| 87 | }) |
| 88 | suite.T().Log("Finished running line #9") |
| 89 | } |
| 90 | |
| 91 | { |
| 92 | // datum/null.yaml line #14 |
| 93 | /* 'null' */ |
| 94 | var expected_ string = "null" |
| 95 | /* r.expr(null).coerce_to('string') */ |
| 96 | |
| 97 | suite.T().Log("About to run line #14: r.Expr(nil).CoerceTo('string')") |
| 98 | |
| 99 | runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("string"), suite.session, r.RunOpts{ |
| 100 | GeometryFormat: "raw", |
| 101 | GroupFormat: "map", |
| 102 | }) |
| 103 | suite.T().Log("Finished running line #14") |
| 104 | } |
| 105 | |
| 106 | { |
| 107 | // datum/null.yaml line #17 |
| 108 | /* null */ |
| 109 | var expected_ interface{} = nil |
| 110 | /* r.expr(null).coerce_to('null') */ |
| 111 | |
| 112 | suite.T().Log("About to run line #17: r.Expr(nil).CoerceTo('null')") |
| 113 | |
| 114 | runAndAssert(suite.Suite, expected_, r.Expr(nil).CoerceTo("null"), suite.session, r.RunOpts{ |
| 115 | GeometryFormat: "raw", |
| 116 | GroupFormat: "map", |
| 117 | }) |
| 118 | suite.T().Log("Finished running line #17") |
| 119 | } |
| 120 | } |