Files
seaweedfs/weed/s3api/s3tables/handler_view_test.go
T
Chris LuandGitHub 0403e47ef6 iceberg: support views (#10069)
* s3tables: tag table entries and exclude views from table listings

* s3tables: add view CRUD operations

* iceberg: support view create, load, exists, drop, and list

* iceberg: support view update

* iceberg: test view error classification and metadata round-trip

* iceberg: pre-check existence and write view metadata only after create

* iceberg: map view namespace-not-found to 404

* iceberg: test view create namespace-404 and duplicate no-clobber

* s3tables: tag view metadata and entry type atomically

CreateView wrote ExtendedKeyMetadata and ExtendedKeyEntryType in two
UpdateEntry calls, so a partial failure could leave a view directory
untagged. Add setExtendedAttributes to set both in one UpdateEntry.

* iceberg: roll back view registration when metadata write fails

The metadata file is written after the catalog registers the view. If
that write fails, drop the just-created view so it doesn't linger
pointing at a missing metadata.json. Reuse the DeleteView path via a
shared dropView helper.
2026-06-23 15:22:31 -07:00

34 lines
1.1 KiB
Go

package s3tables
import "testing"
func TestEntryType(t *testing.T) {
cases := []struct {
name string
extended map[string][]byte
want string
}{
{"nil extended is table", nil, EntryTypeTable},
{"absent marker is table", map[string][]byte{ExtendedKeyMetadata: []byte("{}")}, EntryTypeTable},
{"empty marker is table", map[string][]byte{ExtendedKeyEntryType: {}}, EntryTypeTable},
{"table marker", map[string][]byte{ExtendedKeyEntryType: []byte(EntryTypeTable)}, EntryTypeTable},
{"view marker", map[string][]byte{ExtendedKeyEntryType: []byte(EntryTypeView)}, EntryTypeView},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if got := entryType(c.extended); got != c.want {
t.Fatalf("entryType() = %q, want %q", got, c.want)
}
})
}
}
func TestGenerateViewARN(t *testing.T) {
h := NewS3TablesHandler()
got := h.generateViewARN(DefaultAccountID, "warehouse", "ns/v")
want := "arn:aws:s3tables:us-east-1:000000000000:bucket/warehouse/view/ns/v"
if got != want {
t.Fatalf("generateViewARN() = %q, want %q", got, want)
}
}