package system

import (
	"context"
	"testing"

	"kra/internal/biz"
)

func TestMediaListKeepsZeroPageSizeContract(t *testing.T) {
	data := newTransactionTestData(t)
	repo := &mediaRepo{data: data}
	ctx := context.Background()
	if err := repo.CreateMedia(ctx, &biz.MediaFile{Name: "one.txt"}); err != nil {
		t.Fatal(err)
	}

	items, total, err := repo.ListMedia(ctx, biz.MediaFilter{})
	if err != nil {
		t.Fatal(err)
	}
	if total != 1 || len(items) != 0 {
		t.Fatalf("zero-size media page = %d items with total %d, want 0/1", len(items), total)
	}
}

func TestMediaBatchImportRejectsEmptySlice(t *testing.T) {
	data := newTransactionTestData(t)
	err := (&mediaRepo{data: data}).CreateMediaBatch(context.Background(), nil)
	if err == nil {
		t.Fatal("empty media import unexpectedly succeeded")
	}
}
