gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/internal/integration/reql_tests/reql_geo_primitives_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 geometric primitive constructors 17 func TestGeoPrimitivesSuite(t *testing.T) { 18 suite.Run(t, new(GeoPrimitivesSuite)) 19 } 20 21 type GeoPrimitivesSuite struct { 22 suite.Suite 23 24 session *r.Session 25 } 26 27 func (suite *GeoPrimitivesSuite) SetupTest() { 28 suite.T().Log("Setting up GeoPrimitivesSuite") 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 *GeoPrimitivesSuite) TearDownSuite() { 48 suite.T().Log("Tearing down GeoPrimitivesSuite") 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 *GeoPrimitivesSuite) TestCases() { 59 suite.T().Log("Running GeoPrimitivesSuite: Test geometric primitive constructors") 60 61 { 62 // geo/primitives.yaml line #5 63 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ 64 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} 65 /* r.circle([0,0], 1, num_vertices=3) */ 66 67 suite.T().Log("About to run line #5: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, })") 68 69 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3}), suite.session, r.RunOpts{ 70 GeometryFormat: "raw", 71 GroupFormat: "map", 72 }) 73 suite.T().Log("Finished running line #5") 74 } 75 76 { 77 // geo/primitives.yaml line #10 78 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ 79 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} 80 /* r.circle(r.point(0,0), 1, num_vertices=3) */ 81 82 suite.T().Log("About to run line #10: r.Circle(r.Point(0, 0), 1).OptArgs(r.CircleOpts{NumVertices: 3, })") 83 84 runAndAssert(suite.Suite, expected_, r.Circle(r.Point(0, 0), 1).OptArgs(r.CircleOpts{NumVertices: 3}), suite.session, r.RunOpts{ 85 GeometryFormat: "raw", 86 GroupFormat: "map", 87 }) 88 suite.T().Log("Finished running line #10") 89 } 90 91 { 92 // geo/primitives.yaml line #15 93 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]], 'type':'LineString'}) */ 94 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}, "type": "LineString"} 95 /* r.circle([0,0], 1, num_vertices=3, fill=false) */ 96 97 suite.T().Log("About to run line #15: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, Fill: false, })") 98 99 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, Fill: false}), suite.session, r.RunOpts{ 100 GeometryFormat: "raw", 101 GroupFormat: "map", 102 }) 103 suite.T().Log("Finished running line #15") 104 } 105 106 { 107 // geo/primitives.yaml line #20 108 /* err('ReqlQueryLogicError', 'Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 14000000m, but must be smaller than 9985163.1855612862855m.', [0]) */ 109 var expected_ Err = err("ReqlQueryLogicError", "Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 14000000m, but must be smaller than 9985163.1855612862855m.") 110 /* r.circle([0,0], 14000000, num_vertices=3) */ 111 112 suite.T().Log("About to run line #20: r.Circle([]interface{}{0, 0}, 14000000).OptArgs(r.CircleOpts{NumVertices: 3, })") 113 114 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 14000000).OptArgs(r.CircleOpts{NumVertices: 3}), suite.session, r.RunOpts{ 115 GeometryFormat: "raw", 116 GroupFormat: "map", 117 }) 118 suite.T().Log("Finished running line #20") 119 } 120 121 { 122 // geo/primitives.yaml line #25 123 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ 124 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} 125 /* r.circle([0,0], 1, num_vertices=3, geo_system='WGS84') */ 126 127 suite.T().Log("About to run line #25: r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: 'WGS84', })") 128 129 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: "WGS84"}), suite.session, r.RunOpts{ 130 GeometryFormat: "raw", 131 GroupFormat: "map", 132 }) 133 suite.T().Log("Finished running line #25") 134 } 135 136 { 137 // geo/primitives.yaml line #30 138 /* err('ReqlQueryLogicError', 'Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 2m, but must be smaller than 1.570796326794896558m.', [0]) */ 139 var expected_ Err = err("ReqlQueryLogicError", "Radius must be smaller than a quarter of the circumference along the minor axis of the reference ellipsoid. Got 2m, but must be smaller than 1.570796326794896558m.") 140 /* r.circle([0,0], 2, num_vertices=3, geo_system='unit_sphere') */ 141 142 suite.T().Log("About to run line #30: r.Circle([]interface{}{0, 0}, 2).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: 'unit_sphere', })") 143 144 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 2).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: "unit_sphere"}), suite.session, r.RunOpts{ 145 GeometryFormat: "raw", 146 GroupFormat: "map", 147 }) 148 suite.T().Log("Finished running line #30") 149 } 150 151 { 152 // geo/primitives.yaml line #35 153 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -5.729577951308232], [-4.966092947444857, 2.861205754495701], [4.966092947444857, 2.861205754495701], [0, -5.729577951308232]]], 'type':'Polygon'}) */ 154 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -5.729577951308232}, []interface{}{-4.966092947444857, 2.861205754495701}, []interface{}{4.966092947444857, 2.861205754495701}, []interface{}{0, -5.729577951308232}}}, "type": "Polygon"} 155 /* r.circle([0,0], 0.1, num_vertices=3, geo_system='unit_sphere') */ 156 157 suite.T().Log("About to run line #35: r.Circle([]interface{}{0, 0}, 0.1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: 'unit_sphere', })") 158 159 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, 0.1).OptArgs(r.CircleOpts{NumVertices: 3, GeoSystem: "unit_sphere"}), suite.session, r.RunOpts{ 160 GeometryFormat: "raw", 161 GroupFormat: "map", 162 }) 163 suite.T().Log("Finished running line #35") 164 } 165 166 { 167 // geo/primitives.yaml line #42 168 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ 169 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} 170 /* r.circle([0,0], 1.0/1000.0, num_vertices=3, unit='km') */ 171 172 suite.T().Log("About to run line #42: r.Circle([]interface{}{0, 0}, r.Div(1.0, 1000.0)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: 'km', })") 173 174 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, r.Div(1.0, 1000.0)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: "km"}), suite.session, r.RunOpts{ 175 GeometryFormat: "raw", 176 GroupFormat: "map", 177 }) 178 suite.T().Log("Finished running line #42") 179 } 180 181 { 182 // geo/primitives.yaml line #47 183 /* ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0, -9.04369477050382e-06], [-7.779638566553426e-06, 4.5218473852518965e-06], [7.779638566553426e-06, 4.5218473852518965e-06], [0, -9.04369477050382e-06]]], 'type':'Polygon'}) */ 184 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"$reql_type$": "GEOMETRY", "coordinates": []interface{}{[]interface{}{[]interface{}{0, -9.04369477050382e-06}, []interface{}{-7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{7.779638566553426e-06, 4.5218473852518965e-06}, []interface{}{0, -9.04369477050382e-06}}}, "type": "Polygon"} 185 /* r.circle([0,0], 1.0/1609.344, num_vertices=3, unit='mi') */ 186 187 suite.T().Log("About to run line #47: r.Circle([]interface{}{0, 0}, r.Div(1.0, 1609.344)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: 'mi', })") 188 189 runAndAssert(suite.Suite, expected_, r.Circle([]interface{}{0, 0}, r.Div(1.0, 1609.344)).OptArgs(r.CircleOpts{NumVertices: 3, Unit: "mi"}), suite.session, r.RunOpts{ 190 GeometryFormat: "raw", 191 GroupFormat: "map", 192 }) 193 suite.T().Log("Finished running line #47") 194 } 195 }