Debian Codegraph @

internal/integration/reql_tests/reql_times_shim_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 // Test the native shims.
17 func TestTimesShimSuite(t *testing.T) {
18 suite.Run(t, new(TimesShimSuite))
19 }
20
21 type TimesShimSuite struct {
22 suite.Suite
23
24 session *r.Session
25 }
26
27 func (suite *TimesShimSuite) SetupTest() {
28 suite.T().Log("Setting up TimesShimSuite")
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_times_shim").Exec(suite.session)
40 err = r.DBCreate("db_times_shim").Exec(suite.session)
41 suite.Require().NoError(err)
42 err = r.DB("db_times_shim").Wait().Exec(suite.session)
43 suite.Require().NoError(err)
44
45 }
46
47 func (suite *TimesShimSuite) TearDownSuite() {
48 suite.T().Log("Tearing down TimesShimSuite")
49
50 if suite.session != nil {
51 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
52 r.DBDrop("db_times_shim").Exec(suite.session)
53
54 suite.session.Close()
55 }
56 }
57
58 func (suite *TimesShimSuite) TestCases() {
59 suite.T().Log("Running TimesShimSuite: Test the native shims.")
60
61 // times/shim.yaml line #4
62 // t = 1375147296.68
63 suite.T().Log("Possibly executing: var t float64 = 1375147296.68")
64
65 t := 1375147296.68
66 _ = t // Prevent any noused variable errors
67
68 {
69 // times/shim.yaml line #8
70 /* ("2013-07-29T18:21:36.680-07:00") */
71 var expected_ string = "2013-07-29T18:21:36.680-07:00"
72 /* r.expr(datetime.fromtimestamp(t, PacificTimeZone())).to_iso8601() */
73
74 suite.T().Log("About to run line #8: r.Expr(Ast.Fromtimestamp(t, PacificTimeZone())).ToISO8601()")
75
76 runAndAssert(suite.Suite, expected_, r.Expr(Ast.Fromtimestamp(t, PacificTimeZone())).ToISO8601(), suite.session, r.RunOpts{
77 GeometryFormat: "raw",
78 GroupFormat: "map",
79 })
80 suite.T().Log("Finished running line #8")
81 }
82
83 {
84 // times/shim.yaml line #12
85 /* ("2013-07-30T01:21:36.680+00:00") */
86 var expected_ string = "2013-07-30T01:21:36.680+00:00"
87 /* r.expr(datetime.fromtimestamp(t, UTCTimeZone())).to_iso8601() */
88
89 suite.T().Log("About to run line #12: r.Expr(Ast.Fromtimestamp(t, UTCTimeZone())).ToISO8601()")
90
91 runAndAssert(suite.Suite, expected_, r.Expr(Ast.Fromtimestamp(t, UTCTimeZone())).ToISO8601(), suite.session, r.RunOpts{
92 GeometryFormat: "raw",
93 GroupFormat: "map",
94 })
95 suite.T().Log("Finished running line #12")
96 }
97
98 {
99 // times/shim.yaml line #16
100 /* (1375147296.68) */
101 var expected_ float64 = 1375147296.68
102 /* r.expr(datetime.fromtimestamp(t, PacificTimeZone())).to_epoch_time() */
103
104 suite.T().Log("About to run line #16: r.Expr(Ast.Fromtimestamp(t, PacificTimeZone())).ToEpochTime()")
105
106 runAndAssert(suite.Suite, expected_, r.Expr(Ast.Fromtimestamp(t, PacificTimeZone())).ToEpochTime(), suite.session, r.RunOpts{
107 GeometryFormat: "raw",
108 GroupFormat: "map",
109 })
110 suite.T().Log("Finished running line #16")
111 }
112
113 {
114 // times/shim.yaml line #20
115 /* (1375147296.68) */
116 var expected_ float64 = 1375147296.68
117 /* r.expr(datetime.fromtimestamp(t, UTCTimeZone())).to_epoch_time() */
118
119 suite.T().Log("About to run line #20: r.Expr(Ast.Fromtimestamp(t, UTCTimeZone())).ToEpochTime()")
120
121 runAndAssert(suite.Suite, expected_, r.Expr(Ast.Fromtimestamp(t, UTCTimeZone())).ToEpochTime(), suite.session, r.RunOpts{
122 GeometryFormat: "raw",
123 GroupFormat: "map",
124 })
125 suite.T().Log("Finished running line #20")
126 }
127 }