zeroshade commented on code in PR #2636:
URL: https://github.com/apache/iceberg-go/pull/2636#discussion_r4645547391


##########
table/reference_tables_test.go:
##########
@@ -0,0 +1,436 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package table_test
+
+import (
+       "bytes"
+       "encoding/json"
+       "fmt"
+       "maps"
+       "os"
+       "path/filepath"
+       "slices"
+       "strconv"
+       "strings"
+       "testing"
+       "time"
+
+       "github.com/apache/arrow-go/v18/arrow"
+       "github.com/apache/arrow-go/v18/arrow/array"
+       "github.com/apache/iceberg-go"
+       "github.com/apache/iceberg-go/io"
+       "github.com/apache/iceberg-go/table"
+       "github.com/stretchr/testify/require"
+)
+
+// referenceTablesSentinel is the absolute root every path in the
+// iceberg-verification fixtures is written under. CI symlinks it to the
+// checkout, as reference-tables/README.md describes.
+const referenceTablesSentinel = "/tmp/iceberg-verification"
+
+// referenceTablesSkip names tables iceberg-go cannot read yet, with the 
reason.
+var referenceTablesSkip = map[string]string{}
+
+type referenceTablesIndex struct {
+       Tables []struct {
+               Name     string `json:"name"`
+               Metadata string `json:"metadata"`
+       } `json:"tables"`
+}
+
+type referenceTablesExpected struct {
+       Snapshots []struct {
+               SnapshotID string            `json:"snapshot-id"`
+               Rows       []json.RawMessage `json:"rows"`
+       } `json:"snapshots"`
+}
+
+// TestReferenceTables scans every table of an iceberg-verification checkout
+// at every snapshot in its expected/scan.json and compares the rows.
+func TestReferenceTables(t *testing.T) {
+       dir := os.Getenv("ICEBERG_VERIFICATION_DIR")
+       if dir == "" {
+               t.Skip("ICEBERG_VERIFICATION_DIR is not set")
+       }
+       if _, err := os.Stat(filepath.Join(referenceTablesSentinel, 
"reference-tables", "index.json")); err != nil {
+               t.Skipf("%s does not resolve to the checkout; run ln -s %q %s: 
%v",

Review Comment:
   Once `ICEBERG_VERIFICATION_DIR` is set, could a missing or mismatched link 
fail instead of skip? Locally, with the env var set and no link, the run 
reports `ok` while testing nothing. CI is safe today because a failing `ln -s` 
fails the step, but that protection depends on the workflow. A link to a 
different checkout would also run against fixtures from another directory. 
Something like:
   
   ```go
   want, err := os.Stat(filepath.Join(dir, "reference-tables", "index.json"))
   require.NoError(t, err)
   got, err := os.Stat(filepath.Join(referenceTablesSentinel, 
"reference-tables", "index.json"))
   if err != nil || !os.SameFile(want, got) {
        t.Fatalf("%s must link to %q; run ln -s %q %s", 
referenceTablesSentinel, dir, dir, referenceTablesSentinel)
   }
   ```



-- 
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