Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

1.1 KB
Raw Blame
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)
	}
}