Revanth14 commented on code in PR #1239:
URL: https://github.com/apache/iceberg-go/pull/1239#discussion_r3470985237


##########
table/arrow_utils_internal_test.go:
##########
@@ -491,3 +492,128 @@ func TestIcebergCRSToGeoArrowMetadata(t *testing.T) {
                assert.Empty(t, meta.CRSType)
        })
 }
+
+func TestGeoArrowCRSToIcebergCRS(t *testing.T) {
+       stringCRS := func(s string) json.RawMessage {
+               raw, err := json.Marshal(s)
+               require.NoError(t, err)
+
+               return raw
+       }
+
+       t.Run("accepts long authority code string", func(t *testing.T) {
+               const crs = "EPSGAuthorityLongName:CODE-12345678901234567890"
+
+               got, err := geoArrowCRSToIcebergCRS(geoarrow.Metadata{CRS: 
stringCRS(crs)})
+               require.NoError(t, err)
+               assert.Equal(t, crs, got)
+       })
+
+       t.Run("accepts arbitrary string CRS", func(t *testing.T) {
+               got, err := geoArrowCRSToIcebergCRS(geoarrow.Metadata{CRS: 
stringCRS("custom")})
+               require.NoError(t, err)
+               assert.Equal(t, "custom", got)
+       })
+
+       t.Run("canonical string CRS wins over srid type annotation", func(t 
*testing.T) {
+               for _, crs := range []string{"EPSG:4326", "OGC:CRS84"} {
+                       t.Run(crs, func(t *testing.T) {
+                               got, err := 
geoArrowCRSToIcebergCRS(geoarrow.Metadata{
+                                       CRS:     stringCRS(crs),
+                                       CRSType: geoarrow.CRSTypeSRID,
+                               })
+                               require.NoError(t, err)
+                               assert.Equal(t, "OGC:CRS84", got)
+                       })
+               }
+       })
+
+       t.Run("numeric srid type annotation maps to srid", func(t *testing.T) {
+               got, err := geoArrowCRSToIcebergCRS(geoarrow.Metadata{
+                       CRS:     stringCRS("3857"),
+                       CRSType: geoarrow.CRSTypeSRID,
+               })
+               require.NoError(t, err)
+               assert.Equal(t, "srid:3857", got)
+       })
+
+       t.Run("rejects empty string CRS", func(t *testing.T) {
+               _, err := geoArrowCRSToIcebergCRS(geoarrow.Metadata{CRS: 
stringCRS("")})
+               require.Error(t, err)
+               assert.ErrorContains(t, err, "unsupported CRS: empty string 
CRS")
+       })
+
+       t.Run("rejects projjson string CRS", func(t *testing.T) {
+               _, err := geoArrowCRSToIcebergCRS(geoarrow.Metadata{
+                       CRS:     stringCRS("EPSG:4326"),
+                       CRSType: geoarrow.CRSTypePROJJSON,
+               })
+               require.Error(t, err)
+               assert.ErrorContains(t, err, "CRS type projjson not supported 
for string CRS")

Review Comment:
   Done. The internal tests now use `assert.ErrorIs` for both package-level 
sentinels: `errPROJJSONStringCRSNotSupported` and `errWKT2CRSNotSupported`. The 
external tests still use `ErrorContains` where the unexported sentinels are not 
visible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to