gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_times_timezones_test.go (about) 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 basic timezone manipulation 17 func TestTimesTimezonesSuite(t *testing.T) { 18 suite.Run(t, new(TimesTimezonesSuite)) 19 } 20 21 type TimesTimezonesSuite struct { 22 suite.Suite 23 24 session *r.Session 25 } 26 27 func (suite *TimesTimezonesSuite) SetupTest() { 28 suite.T().Log("Setting up TimesTimezonesSuite") 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("test").Exec(suite.session) 40 err = r.DBCreate("test").Exec(suite.session) 41 suite.Require().NoError(err) 42 err = r.DB("test").Wait().Exec(suite.session) 43 suite.Require().NoError(err) 44 45 } 46 47 func (suite *TimesTimezonesSuite) TearDownSuite() { 48 suite.T().Log("Tearing down TimesTimezonesSuite") 49 50 if suite.session != nil { 51 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) 52 r.DBDrop("test").Exec(suite.session) 53 54 suite.session.Close() 55 } 56 } 57 58 func (suite *TimesTimezonesSuite) TestCases() { 59 suite.T().Log("Running TimesTimezonesSuite: Test basic timezone manipulation") 60 61 // times/timezones.yaml line #3 62 // t1 = r.time(2013, r.july, 29, 23, 30, 0, "+00:00") 63 suite.T().Log("Possibly executing: var t1 r.Term = r.Time(2013, r.July, 29, 23, 30, 0, '+00:00')") 64 65 t1 := r.Time(2013, r.July, 29, 23, 30, 0, "+00:00") 66 _ = t1 // Prevent any noused variable errors 67 68 // times/timezones.yaml line #5 69 // tutc1 = t1.in_timezone("Z") 70 suite.T().Log("Possibly executing: var tutc1 r.Term = t1.InTimezone('Z')") 71 72 tutc1 := t1.InTimezone("Z") 73 _ = tutc1 // Prevent any noused variable errors 74 75 // times/timezones.yaml line #6 76 // tutc2 = t1.in_timezone("+00:00") 77 suite.T().Log("Possibly executing: var tutc2 r.Term = t1.InTimezone('+00:00')") 78 79 tutc2 := t1.InTimezone("+00:00") 80 _ = tutc2 // Prevent any noused variable errors 81 82 // times/timezones.yaml line #7 83 // tutc3 = t1.in_timezone("+00") 84 suite.T().Log("Possibly executing: var tutc3 r.Term = t1.InTimezone('+00')") 85 86 tutc3 := t1.InTimezone("+00") 87 _ = tutc3 // Prevent any noused variable errors 88 89 // times/timezones.yaml line #8 90 // tutcs = r.expr([tutc1, tutc2, tutc3]) 91 suite.T().Log("Possibly executing: var tutcs r.Term = r.Expr([]interface{}{tutc1, tutc2, tutc3})") 92 93 tutcs := r.Expr([]interface{}{tutc1, tutc2, tutc3}) 94 _ = tutcs // Prevent any noused variable errors 95 96 // times/timezones.yaml line #10 97 // tm1 = t1.in_timezone("-00:59") 98 suite.T().Log("Possibly executing: var tm1 r.Term = t1.InTimezone('-00:59')") 99 100 tm1 := t1.InTimezone("-00:59") 101 _ = tm1 // Prevent any noused variable errors 102 103 // times/timezones.yaml line #11 104 // tm2 = t1.in_timezone("-01:00") 105 suite.T().Log("Possibly executing: var tm2 r.Term = t1.InTimezone('-01:00')") 106 107 tm2 := t1.InTimezone("-01:00") 108 _ = tm2 // Prevent any noused variable errors 109 110 // times/timezones.yaml line #12 111 // tm3 = t1.in_timezone("-01:01") 112 suite.T().Log("Possibly executing: var tm3 r.Term = t1.InTimezone('-01:01')") 113 114 tm3 := t1.InTimezone("-01:01") 115 _ = tm3 // Prevent any noused variable errors 116 117 // times/timezones.yaml line #13 118 // tms = r.expr([tm1, tm2, tm3]) 119 suite.T().Log("Possibly executing: var tms r.Term = r.Expr([]interface{}{tm1, tm2, tm3})") 120 121 tms := r.Expr([]interface{}{tm1, tm2, tm3}) 122 _ = tms // Prevent any noused variable errors 123 124 // times/timezones.yaml line #15 125 // tp1 = t1.in_timezone("+00:59") 126 suite.T().Log("Possibly executing: var tp1 r.Term = t1.InTimezone('+00:59')") 127 128 tp1 := t1.InTimezone("+00:59") 129 _ = tp1 // Prevent any noused variable errors 130 131 // times/timezones.yaml line #16 132 // tp2 = t1.in_timezone("+01:00") 133 suite.T().Log("Possibly executing: var tp2 r.Term = t1.InTimezone('+01:00')") 134 135 tp2 := t1.InTimezone("+01:00") 136 _ = tp2 // Prevent any noused variable errors 137 138 // times/timezones.yaml line #17 139 // tp3 = t1.in_timezone("+01:01") 140 suite.T().Log("Possibly executing: var tp3 r.Term = t1.InTimezone('+01:01')") 141 142 tp3 := t1.InTimezone("+01:01") 143 _ = tp3 // Prevent any noused variable errors 144 145 // times/timezones.yaml line #18 146 // tps = r.expr([tp1, tp2, tp3]) 147 suite.T().Log("Possibly executing: var tps r.Term = r.Expr([]interface{}{tp1, tp2, tp3})") 148 149 tps := r.Expr([]interface{}{tp1, tp2, tp3}) 150 _ = tps // Prevent any noused variable errors 151 152 // times/timezones.yaml line #20 153 // ts = tutcs.union(tms).union(tps).union([t1]) 154 suite.T().Log("Possibly executing: var ts r.Term = tutcs.Union(tms).Union(tps).Union([]interface{}{t1})") 155 156 ts := tutcs.Union(tms).Union(tps).Union([]interface{}{t1}) 157 _ = ts // Prevent any noused variable errors 158 159 { 160 // times/timezones.yaml line #23 161 /* ([["+00:00", 29], ["+00:00", 29], ["+00:00", 29]]) */ 162 var expected_ []interface{} = []interface{}{[]interface{}{"+00:00", 29}, []interface{}{"+00:00", 29}, []interface{}{"+00:00", 29}} 163 /* tutcs.map(lambda x:[x.timezone(), x.day()]) */ 164 165 suite.T().Log("About to run line #23: tutcs.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()}})") 166 167 runAndAssert(suite.Suite, expected_, tutcs.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()} }), suite.session, r.RunOpts{ 168 GeometryFormat: "raw", 169 GroupFormat: "map", 170 }) 171 suite.T().Log("Finished running line #23") 172 } 173 174 { 175 // times/timezones.yaml line #27 176 /* ([["-00:59", 29], ["-01:00", 29], ["-01:01", 29]]) */ 177 var expected_ []interface{} = []interface{}{[]interface{}{"-00:59", 29}, []interface{}{"-01:00", 29}, []interface{}{"-01:01", 29}} 178 /* tms.map(lambda x:[x.timezone(), x.day()]) */ 179 180 suite.T().Log("About to run line #27: tms.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()}})") 181 182 runAndAssert(suite.Suite, expected_, tms.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()} }), suite.session, r.RunOpts{ 183 GeometryFormat: "raw", 184 GroupFormat: "map", 185 }) 186 suite.T().Log("Finished running line #27") 187 } 188 189 { 190 // times/timezones.yaml line #31 191 /* ([["+00:59", 30], ["+01:00", 30], ["+01:01", 30]]) */ 192 var expected_ []interface{} = []interface{}{[]interface{}{"+00:59", 30}, []interface{}{"+01:00", 30}, []interface{}{"+01:01", 30}} 193 /* tps.map(lambda x:[x.timezone(), x.day()]) */ 194 195 suite.T().Log("About to run line #31: tps.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()}})") 196 197 runAndAssert(suite.Suite, expected_, tps.Map(func(x r.Term) interface{} { return []interface{}{x.Timezone(), x.Day()} }), suite.session, r.RunOpts{ 198 GeometryFormat: "raw", 199 GroupFormat: "map", 200 }) 201 suite.T().Log("Finished running line #31") 202 } 203 204 { 205 // times/timezones.yaml line #38 206 /* ([0]) */ 207 var expected_ []interface{} = []interface{}{0} 208 /* ts.concat_map(lambda x:ts.map(lambda y:x - y)).distinct() */ 209 210 suite.T().Log("About to run line #38: ts.ConcatMap(func(x r.Term) interface{} { return ts.Map(func(y r.Term) interface{} { return r.Sub(x, y)})}).Distinct()") 211 212 runAndAssert(suite.Suite, expected_, ts.ConcatMap(func(x r.Term) interface{} { return ts.Map(func(y r.Term) interface{} { return r.Sub(x, y) }) }).Distinct(), suite.session, r.RunOpts{ 213 GeometryFormat: "raw", 214 GroupFormat: "map", 215 }) 216 suite.T().Log("Finished running line #38") 217 } 218 219 { 220 // times/timezones.yaml line #44 221 /* err('ReqlQueryLogicError', 'Timezone `` does not start with `-` or `+`.') */ 222 var expected_ Err = err("ReqlQueryLogicError", "Timezone `` does not start with `-` or `+`.") 223 /* r.now().in_timezone("") */ 224 225 suite.T().Log("About to run line #44: r.Now().InTimezone('')") 226 227 runAndAssert(suite.Suite, expected_, r.Now().InTimezone(""), suite.session, r.RunOpts{ 228 GeometryFormat: "raw", 229 GroupFormat: "map", 230 }) 231 suite.T().Log("Finished running line #44") 232 } 233 234 { 235 // times/timezones.yaml line #47 236 /* err('ReqlQueryLogicError', '`-00` is not a valid time offset.') */ 237 var expected_ Err = err("ReqlQueryLogicError", "`-00` is not a valid time offset.") 238 /* r.now().in_timezone("-00") */ 239 240 suite.T().Log("About to run line #47: r.Now().InTimezone('-00')") 241 242 runAndAssert(suite.Suite, expected_, r.Now().InTimezone("-00"), suite.session, r.RunOpts{ 243 GeometryFormat: "raw", 244 GroupFormat: "map", 245 }) 246 suite.T().Log("Finished running line #47") 247 } 248 249 { 250 // times/timezones.yaml line #50 251 /* err('ReqlQueryLogicError', '`-00:00` is not a valid time offset.') */ 252 var expected_ Err = err("ReqlQueryLogicError", "`-00:00` is not a valid time offset.") 253 /* r.now().in_timezone("-00:00") */ 254 255 suite.T().Log("About to run line #50: r.Now().InTimezone('-00:00')") 256 257 runAndAssert(suite.Suite, expected_, r.Now().InTimezone("-00:00"), suite.session, r.RunOpts{ 258 GeometryFormat: "raw", 259 GroupFormat: "map", 260 }) 261 suite.T().Log("Finished running line #50") 262 } 263 264 { 265 // times/timezones.yaml line #53 266 /* err('ReqlQueryLogicError', 'Timezone `UTC+00` does not start with `-` or `+`.') */ 267 var expected_ Err = err("ReqlQueryLogicError", "Timezone `UTC+00` does not start with `-` or `+`.") 268 /* r.now().in_timezone("UTC+00") */ 269 270 suite.T().Log("About to run line #53: r.Now().InTimezone('UTC+00')") 271 272 runAndAssert(suite.Suite, expected_, r.Now().InTimezone("UTC+00"), suite.session, r.RunOpts{ 273 GeometryFormat: "raw", 274 GroupFormat: "map", 275 }) 276 suite.T().Log("Finished running line #53") 277 } 278 279 { 280 // times/timezones.yaml line #56 281 /* err('ReqlQueryLogicError', 'Minutes out of range in `+00:60`.') */ 282 var expected_ Err = err("ReqlQueryLogicError", "Minutes out of range in `+00:60`.") 283 /* r.now().in_timezone("+00:60") */ 284 285 suite.T().Log("About to run line #56: r.Now().InTimezone('+00:60')") 286 287 runAndAssert(suite.Suite, expected_, r.Now().InTimezone("+00:60"), suite.session, r.RunOpts{ 288 GeometryFormat: "raw", 289 GroupFormat: "map", 290 }) 291 suite.T().Log("Finished running line #56") 292 } 293 294 { 295 // times/timezones.yaml line #59 296 /* err('ReqlQueryLogicError', 'Hours out of range in `+25:00`.') */ 297 var expected_ Err = err("ReqlQueryLogicError", "Hours out of range in `+25:00`.") 298 /* r.now().in_timezone("+25:00") */ 299 300 suite.T().Log("About to run line #59: r.Now().InTimezone('+25:00')") 301 302 runAndAssert(suite.Suite, expected_, r.Now().InTimezone("+25:00"), suite.session, r.RunOpts{ 303 GeometryFormat: "raw", 304 GroupFormat: "map", 305 }) 306 suite.T().Log("Finished running line #59") 307 } 308 309 { 310 // times/timezones.yaml line #63 311 /* err('ReqlQueryLogicError', 'Timezone `` does not start with `-` or `+`.') */ 312 var expected_ Err = err("ReqlQueryLogicError", "Timezone `` does not start with `-` or `+`.") 313 /* r.time(2013, 1, 1, "") */ 314 315 suite.T().Log("About to run line #63: r.Time(2013, 1, 1, '')") 316 317 runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, ""), suite.session, r.RunOpts{ 318 GeometryFormat: "raw", 319 GroupFormat: "map", 320 }) 321 suite.T().Log("Finished running line #63") 322 } 323 324 { 325 // times/timezones.yaml line #66 326 /* err('ReqlQueryLogicError', '`-00` is not a valid time offset.') */ 327 var expected_ Err = err("ReqlQueryLogicError", "`-00` is not a valid time offset.") 328 /* r.time(2013, 1, 1, "-00") */ 329 330 suite.T().Log("About to run line #66: r.Time(2013, 1, 1, '-00')") 331 332 runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "-00"), suite.session, r.RunOpts{ 333 GeometryFormat: "raw", 334 GroupFormat: "map", 335 }) 336 suite.T().Log("Finished running line #66") 337 } 338 339 { 340 // times/timezones.yaml line #69 341 /* err('ReqlQueryLogicError', '`-00:00` is not a valid time offset.') */ 342 var expected_ Err = err("ReqlQueryLogicError", "`-00:00` is not a valid time offset.") 343 /* r.time(2013, 1, 1, "-00:00") */ 344 345 suite.T().Log("About to run line #69: r.Time(2013, 1, 1, '-00:00')") 346 347 runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "-00:00"), suite.session, r.RunOpts{ 348 GeometryFormat: "raw", 349 GroupFormat: "map", 350 }) 351 suite.T().Log("Finished running line #69") 352 } 353 354 { 355 // times/timezones.yaml line #72 356 /* err('ReqlQueryLogicError', 'Timezone `UTC+00` does not start with `-` or `+`.') */ 357 var expected_ Err = err("ReqlQueryLogicError", "Timezone `UTC+00` does not start with `-` or `+`.") 358 /* r.time(2013, 1, 1, "UTC+00") */ 359 360 suite.T().Log("About to run line #72: r.Time(2013, 1, 1, 'UTC+00')") 361 362 runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "UTC+00"), suite.session, r.RunOpts{ 363 GeometryFormat: "raw", 364 GroupFormat: "map", 365 }) 366 suite.T().Log("Finished running line #72") 367 } 368 369 { 370 // times/timezones.yaml line #75 371 /* err('ReqlQueryLogicError', 'Minutes out of range in `+00:60`.') */ 372 var expected_ Err = err("ReqlQueryLogicError", "Minutes out of range in `+00:60`.") 373 /* r.time(2013, 1, 1, "+00:60") */ 374 375 suite.T().Log("About to run line #75: r.Time(2013, 1, 1, '+00:60')") 376 377 runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "+00:60"), suite.session, r.RunOpts{ 378 GeometryFormat: "raw", 379 GroupFormat: "map", 380 }) 381 suite.T().Log("Finished running line #75") 382 } 383 384 { 385 // times/timezones.yaml line #78 386 /* err('ReqlQueryLogicError', 'Hours out of range in `+25:00`.') */ 387 var expected_ Err = err("ReqlQueryLogicError", "Hours out of range in `+25:00`.") 388 /* r.time(2013, 1, 1, "+25:00") */ 389 390 suite.T().Log("About to run line #78: r.Time(2013, 1, 1, '+25:00')") 391 392 runAndAssert(suite.Suite, expected_, r.Time(2013, 1, 1, "+25:00"), suite.session, r.RunOpts{ 393 GeometryFormat: "raw", 394 GroupFormat: "map", 395 }) 396 suite.T().Log("Finished running line #78") 397 } 398 399 { 400 // times/timezones.yaml line #81 401 /* ("2015-07-08T00:00:00-08:00") */ 402 var expected_ string = "2015-07-08T00:00:00-08:00" 403 /* r.epoch_time(1436428422.339).in_timezone('-08:00').date().to_iso8601() */ 404 405 suite.T().Log("About to run line #81: r.EpochTime(1436428422.339).InTimezone('-08:00').Date().ToISO8601()") 406 407 runAndAssert(suite.Suite, expected_, r.EpochTime(1436428422.339).InTimezone("-08:00").Date().ToISO8601(), suite.session, r.RunOpts{ 408 GeometryFormat: "raw", 409 GroupFormat: "map", 410 }) 411 suite.T().Log("Finished running line #81") 412 } 413 414 { 415 // times/timezones.yaml line #85 416 /* ("2015-07-09T00:00:00-07:00") */ 417 var expected_ string = "2015-07-09T00:00:00-07:00" 418 /* r.epoch_time(1436428422.339).in_timezone('-07:00').date().to_iso8601() */ 419 420 suite.T().Log("About to run line #85: r.EpochTime(1436428422.339).InTimezone('-07:00').Date().ToISO8601()") 421 422 runAndAssert(suite.Suite, expected_, r.EpochTime(1436428422.339).InTimezone("-07:00").Date().ToISO8601(), suite.session, r.RunOpts{ 423 GeometryFormat: "raw", 424 GroupFormat: "map", 425 }) 426 suite.T().Log("Finished running line #85") 427 } 428 }